saga-2.2.3/0000775000175000017500000000000012634325731013575 5ustar00oconradoconrad00000000000000saga-2.2.3/m4/0000775000175000017500000000000012634325731014115 5ustar00oconradoconrad00000000000000saga-2.2.3/m4/ax_python_devel.m40000664000175000017500000002557712565125403017564 0ustar00oconradoconrad00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_python_devel.html # =========================================================================== # # SYNOPSIS # # AX_PYTHON_DEVEL([version]) # # DESCRIPTION # # Note: Defines as a precious variable "PYTHON_VERSION". Don't override it # in your configure.ac. # # This macro checks for Python and tries to get the include path to # 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) # output variables. It also exports $(PYTHON_EXTRA_LIBS) and # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. # # You can search for some particular version of Python by passing a # parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please # note that you *have* to pass also an operator along with the version to # match, and pay special attention to the single quotes surrounding the # version number. Don't use "PYTHON_VERSION" for this: that environment # variable is declared as precious and thus reserved for the end-user. # # This macro should work for all versions of Python >= 2.1.0. As an end # user, you can disable the check for the python version by setting the # PYTHON_NOVERSIONCHECK environment variable to something else than the # empty string. # # If you need to use this macro for an older Python version, please # contact the authors. We're always open for feedback. # # LICENSE # # Copyright (c) 2009 Sebastian Huber # Copyright (c) 2009 Alan W. Irwin # Copyright (c) 2009 Rafael Laboissiere # Copyright (c) 2009 Andrew Collier # Copyright (c) 2009 Matteo Settenvini # Copyright (c) 2009 Horst Knorr # Copyright (c) 2013 Daniel Mullner # # 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 3 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, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 16 AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) AC_DEFUN([AX_PYTHON_DEVEL],[ # # Allow the use of a (user set) custom python version # AC_ARG_VAR([PYTHON_VERSION],[The installed Python version to use, for example '2.3'. This string will be appended to the Python interpreter canonical name.]) AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) if test -z "$PYTHON"; then AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path]) PYTHON_VERSION="" fi # # Check for a version of Python >= 2.1.0 # AC_MSG_CHECKING([for a version of Python >= '2.1.0']) ac_supports_python_ver=`$PYTHON -c "import sys; \ ver = sys.version.split ()[[0]]; \ print (ver >= '2.1.0')"` if test "$ac_supports_python_ver" != "True"; then if test -z "$PYTHON_NOVERSIONCHECK"; then AC_MSG_RESULT([no]) AC_MSG_FAILURE([ This version of the AC@&t@_PYTHON_DEVEL macro doesn't work properly with versions of Python before 2.1.0. You may need to re-run configure, setting the variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. Moreover, to disable this check, set PYTHON_NOVERSIONCHECK to something else than an empty string. ]) else AC_MSG_RESULT([skip at user request]) fi else AC_MSG_RESULT([yes]) fi # # if the macro parameter ``version'' is set, honour it # if test -n "$1"; then AC_MSG_CHECKING([for a version of Python $1]) ac_supports_python_ver=`$PYTHON -c "import sys; \ ver = sys.version.split ()[[0]]; \ print (ver $1)"` if test "$ac_supports_python_ver" = "True"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_ERROR([this package requires Python $1. If you have it installed, but it isn't the default Python interpreter in your system path, please pass the PYTHON_VERSION variable to configure. See ``configure --help'' for reference. ]) PYTHON_VERSION="" fi fi # # Check if you have distutils, else fail # AC_MSG_CHECKING([for the distutils Python package]) ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` if test -z "$ac_distutils_result"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_ERROR([cannot import Python module "distutils". Please check your Python installation. The error was: $ac_distutils_result]) PYTHON_VERSION="" fi # # Check for Python include path # AC_MSG_CHECKING([for Python include path]) if test -z "$PYTHON_CPPFLAGS"; then python_path=`$PYTHON -c "import distutils.sysconfig; \ print (distutils.sysconfig.get_python_inc ());"` plat_python_path=`$PYTHON -c "import distutils.sysconfig; \ print (distutils.sysconfig.get_python_inc (plat_specific=1));"` if test -n "${python_path}"; then if test "${plat_python_path}" != "${python_path}"; then python_path="-I$python_path -I$plat_python_path" else python_path="-I$python_path" fi fi PYTHON_CPPFLAGS=$python_path fi AC_MSG_RESULT([$PYTHON_CPPFLAGS]) AC_SUBST([PYTHON_CPPFLAGS]) # # Check for Python library path # AC_MSG_CHECKING([for Python library path]) if test -z "$PYTHON_LDFLAGS"; then # (makes two attempts to ensure we've got a version number # from the interpreter) ac_python_version=`cat<]], [[Py_Initialize();]]) ],[pythonexists=yes],[pythonexists=no]) AC_LANG_POP([C]) # turn back to default flags CPPFLAGS="$ac_save_CPPFLAGS" LIBS="$ac_save_LIBS" AC_MSG_RESULT([$pythonexists]) if test ! "x$pythonexists" = "xyes"; then AC_MSG_FAILURE([ Could not link test program to Python. Maybe the main Python library has been installed in some non-standard library path. If so, pass it to configure, via the LDFLAGS environment variable. Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib" ============================================================================ ERROR! You probably have to install the development version of the Python package for your distribution. The exact name of this package varies among them. ============================================================================ ]) PYTHON_VERSION="" fi # # all done! # ]) saga-2.2.3/m4/ax_pkg_swig.m40000664000175000017500000001515312565125403016663 0ustar00oconradoconrad00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html # =========================================================================== # # SYNOPSIS # # AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found]) # # DESCRIPTION # # This macro searches for a SWIG installation on your system. If found, # then SWIG is AC_SUBST'd; if not found, then $SWIG is empty. If SWIG is # found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd. # # You can use the optional first argument to check if the version of the # available SWIG is greater than or equal to the value of the argument. It # should have the format: N[.N[.N]] (N is a number between 0 and 999. Only # the first N is mandatory.) If the version argument is given (e.g. # 1.3.17), AX_PKG_SWIG checks that the swig package is this version number # or higher. # # As usual, action-if-found is executed if SWIG is found, otherwise # action-if-not-found is executed. # # In configure.in, use as: # # AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ]) # AX_SWIG_ENABLE_CXX # AX_SWIG_MULTI_MODULE_SUPPORT # AX_SWIG_PYTHON # # LICENSE # # Copyright (c) 2008 Sebastian Huber # Copyright (c) 2008 Alan W. Irwin # Copyright (c) 2008 Rafael Laboissiere # Copyright (c) 2008 Andrew Collier # Copyright (c) 2011 Murray Cumming # # 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, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 11 AC_DEFUN([AX_PKG_SWIG],[ # Ubuntu has swig 2.0 as /usr/bin/swig2.0 AC_PATH_PROGS([SWIG],[swig swig2.0]) if test -z "$SWIG" ; then m4_ifval([$3],[$3],[:]) elif test -n "$1" ; then AC_MSG_CHECKING([SWIG version]) [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] AC_MSG_RESULT([$swig_version]) if test -n "$swig_version" ; then # Calculate the required version number components [required=$1] [required_major=`echo $required | sed 's/[^0-9].*//'`] if test -z "$required_major" ; then [required_major=0] fi [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] [required_minor=`echo $required | sed 's/[^0-9].*//'`] if test -z "$required_minor" ; then [required_minor=0] fi [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] [required_patch=`echo $required | sed 's/[^0-9].*//'`] if test -z "$required_patch" ; then [required_patch=0] fi # Calculate the available version number components [available=$swig_version] [available_major=`echo $available | sed 's/[^0-9].*//'`] if test -z "$available_major" ; then [available_major=0] fi [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] [available_minor=`echo $available | sed 's/[^0-9].*//'`] if test -z "$available_minor" ; then [available_minor=0] fi [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] [available_patch=`echo $available | sed 's/[^0-9].*//'`] if test -z "$available_patch" ; then [available_patch=0] fi # Convert the version tuple into a single number for easier comparison. # Using base 100 should be safe since SWIG internally uses BCD values # to encode its version number. required_swig_vernum=`expr $required_major \* 10000 \ \+ $required_minor \* 100 \+ $required_patch` available_swig_vernum=`expr $available_major \* 10000 \ \+ $available_minor \* 100 \+ $available_patch` if test $available_swig_vernum -lt $required_swig_vernum; then AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version.]) SWIG='' m4_ifval([$3],[$3],[]) else AC_MSG_CHECKING([for SWIG library]) SWIG_LIB=`$SWIG -swiglib` AC_MSG_RESULT([$SWIG_LIB]) m4_ifval([$2],[$2],[]) fi else AC_MSG_WARN([cannot determine SWIG version]) SWIG='' m4_ifval([$3],[$3],[]) fi fi AC_SUBST([SWIG_LIB]) ]) saga-2.2.3/m4/libtool.m40000644000175000017500000106011112565125510016015 0ustar00oconradoconrad00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 57 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -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:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD 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. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -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:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi _LT_TAGVAR(link_all_deplibs, $1)=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS saga-2.2.3/m4/ax_lib_postgresql.m40000664000175000017500000001302012565125403020071 0ustar00oconradoconrad00000000000000# !! # ATTENTION: this file was modified for usage with SAGA # !! # # # =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_lib_postgresql.html # =========================================================================== # # SYNOPSIS # # AX_LIB_POSTGRESQL([MINIMUM-VERSION]) # # DESCRIPTION # # This macro provides tests of availability of PostgreSQL 'libpq' library # of particular version or newer. # # AX_LIB_POSTGRESQL macro takes only one argument which is optional. If # there is no required version passed, then macro does not run version # test. # # The --with-postgresql option takes one of three possible values: # # no - do not check for PostgreSQL client library # # yes - do check for PostgreSQL library in standard locations (pg_config # should be in the PATH) # # path - complete path to pg_config utility, use this option if pg_config # can't be found in the PATH # # This macro calls: # # AC_SUBST(POSTGRESQL_CFLAGS) # AC_SUBST(POSTGRESQL_LDFLAGS) # AC_SUBST(POSTGRESQL_VERSION) # # And sets: # # HAVE_POSTGRESQL # # LICENSE # # Copyright (c) 2008 Mateusz Loskot # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 9 AC_DEFUN([AX_LIB_POSTGRESQL], [ AC_ARG_WITH([postgresql], AS_HELP_STRING([--with-postgresql=@<:@ARG@:>@], [use PostgreSQL library @<:@default=yes@:>@, optionally specify path to pg_config] ), [ if test "$withval" = "no"; then want_postgresql="no" elif test "$withval" = "yes"; then want_postgresql="yes" else want_postgresql="yes" PG_CONFIG="$withval" fi ], [want_postgresql="yes"] ) POSTGRESQL_CFLAGS="" POSTGRESQL_LDFLAGS="" POSTGRESQL_VERSION="" dnl dnl Check PostgreSQL libraries (libpq) dnl if test "$want_postgresql" = "yes"; then if test -z "$PG_CONFIG" -o test; then AC_PATH_PROG([PG_CONFIG], [pg_config], []) fi if test ! -x "$PG_CONFIG"; then AC_MSG_WARN([$PG_CONFIG does not exist or it is not an executable file]) AC_MSG_WARN([PostgreSQL support disabled]) AC_MSG_WARN([In case you like to enable it, verify that you have the]) AC_MSG_WARN([PostgreSQL development package installed; in case you have,]) AC_MSG_WARN([but your pg_config is stored in a special location, provide]) AC_MSG_WARN([the full path with configure, e.g.:]) AC_MSG_WARN(['--with-postgresql=/usr/pgsql-9.1/bin/pg_config']) PG_CONFIG="no" found_postgresql="no" fi if test "$PG_CONFIG" != "no"; then AC_MSG_CHECKING([for PostgreSQL libraries]) POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`" POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir` -lpq" POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` AC_DEFINE([HAVE_POSTGRESQL], [1], [Define to 1 if PostgreSQL libraries are available]) found_postgresql="yes" AC_MSG_RESULT([yes]) else found_postgresql="no" # AC_MSG_RESULT([no]) fi fi dnl dnl Check if required version of PostgreSQL is available dnl postgresql_version_req=ifelse([$1], [], [], [$1]) if test "$found_postgresql" = "yes" -a -n "$postgresql_version_req"; then AC_MSG_CHECKING([if PostgreSQL version is >= $postgresql_version_req]) dnl Decompose required version string of PostgreSQL dnl and calculate its number representation postgresql_version_req_major=`expr $postgresql_version_req : '\([[0-9]]*\)'` postgresql_version_req_minor=`expr $postgresql_version_req : '[[0-9]]*\.\([[0-9]]*\)'` postgresql_version_req_micro=`expr $postgresql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` if test "x$postgresql_version_req_micro" = "x"; then postgresql_version_req_micro="0" fi postgresql_version_req_number=`expr $postgresql_version_req_major \* 1000000 \ \+ $postgresql_version_req_minor \* 1000 \ \+ $postgresql_version_req_micro` dnl Decompose version string of installed PostgreSQL dnl and calculate its number representation postgresql_version_major=`expr $POSTGRESQL_VERSION : '\([[0-9]]*\)'` postgresql_version_minor=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'` postgresql_version_micro=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` if test "x$postgresql_version_micro" = "x"; then postgresql_version_micro="0" fi postgresql_version_number=`expr $postgresql_version_major \* 1000000 \ \+ $postgresql_version_minor \* 1000 \ \+ $postgresql_version_micro` postgresql_version_check=`expr $postgresql_version_number \>\= $postgresql_version_req_number` if test "$postgresql_version_check" = "1"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi fi AC_SUBST([POSTGRESQL_VERSION]) AC_SUBST([POSTGRESQL_CFLAGS]) AC_SUBST([POSTGRESQL_LDFLAGS]) ]) saga-2.2.3/m4/ltsugar.m40000644000175000017500000001042412565125510016033 0ustar00oconradoconrad00000000000000# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) saga-2.2.3/m4/ltversion.m40000644000175000017500000000126212565125510016377 0ustar00oconradoconrad00000000000000# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 3337 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.2' macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) saga-2.2.3/m4/lt~obsolete.m40000644000175000017500000001375612565125510016737 0ustar00oconradoconrad00000000000000# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) saga-2.2.3/m4/ax_swig_enable_cxx.m40000664000175000017500000000427412565125403020214 0ustar00oconradoconrad00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_swig_enable_cxx.html # =========================================================================== # # SYNOPSIS # # AX_SWIG_ENABLE_CXX # # DESCRIPTION # # Enable SWIG C++ support. This affects all invocations of $(SWIG). # # LICENSE # # Copyright (c) 2008 Sebastian Huber # Copyright (c) 2008 Alan W. Irwin # Copyright (c) 2008 Rafael Laboissiere # Copyright (c) 2008 Andrew Collier # # 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, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 9 AU_ALIAS([SWIG_ENABLE_CXX], [AX_SWIG_ENABLE_CXX]) AC_DEFUN([AX_SWIG_ENABLE_CXX],[ AC_REQUIRE([AX_PKG_SWIG]) AC_REQUIRE([AC_PROG_CXX]) SWIG="$SWIG -c++" ]) saga-2.2.3/m4/ltoptions.m40000644000175000017500000003007312565125510016407 0ustar00oconradoconrad00000000000000# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 7 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) saga-2.2.3/m4/ax_swig_python.m40000664000175000017500000000554312565125403017425 0ustar00oconradoconrad00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_swig_python.html # =========================================================================== # # SYNOPSIS # # AX_SWIG_PYTHON([use-shadow-classes = {no, yes}]) # # DESCRIPTION # # Checks for Python and provides the $(AX_SWIG_PYTHON_CPPFLAGS), and # $(AX_SWIG_PYTHON_OPT) output variables. # # $(AX_SWIG_PYTHON_OPT) contains all necessary SWIG options to generate # code for Python. Shadow classes are enabled unless the value of the # optional first argument is exactly 'no'. If you need multi module # support (provided by the AX_SWIG_MULTI_MODULE_SUPPORT macro) use # $(AX_SWIG_PYTHON_LIBS) to link against the appropriate library. It # contains the SWIG Python runtime library that is needed by the type # check system for example. # # LICENSE # # Copyright (c) 2008 Sebastian Huber # Copyright (c) 2008 Alan W. Irwin # Copyright (c) 2008 Rafael Laboissiere # Copyright (c) 2008 Andrew Collier # # 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, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 10 AU_ALIAS([SWIG_PYTHON], [AX_SWIG_PYTHON]) AC_DEFUN([AX_SWIG_PYTHON],[ AC_REQUIRE([AX_PKG_SWIG]) AC_REQUIRE([AX_PYTHON_DEVEL]) test "x$1" != "xno" || swig_shadow=" -noproxy" AC_SUBST([AX_SWIG_PYTHON_OPT],[-python$swig_shadow]) AC_SUBST([AX_SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS]) ]) saga-2.2.3/README0000664000175000017500000000146612607764105014466 0ustar00oconradoconrad00000000000000_______________________________________________________________________________ SAGA 2.2.3 - System for Automated Geoscientific Analyses _______________________________________________________________________________ * Introduction SAGA - System for Automated Geoscientific Analyses - is a Free Open Source Software for the analysis of spatial data. * Internet - www.saga-gis.org - sourceforge.net/projects/saga-gis * Supported Platforms - Windows (Microsoft Visual C++ 10.0) - Linux (gcc) - FreeBSD * Required Libraries - wxWidgets 3.0.0 - GDAL 1.8.0 - Proj4 - Haru Free PDF Library (optional) - libLAS 1.2 (optional) - opencv (optional) - vigra (optional) _______________________________________________________________________________ Date: November, 3th 2013 saga-2.2.3/config.guess0000755000175000017500000013036112565125521016115 0ustar00oconradoconrad00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2013 Free Software Foundation, Inc. timestamp='2013-06-10' # This file 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 3 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, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches with a ChangeLog entry to config-patches@gnu.org. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; or1k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: saga-2.2.3/ltmain.sh0000644000175000017500000105204412565125510015415 0ustar00oconradoconrad00000000000000 # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1" TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type \`$version_type'" ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 saga-2.2.3/AUTHORS0000664000175000017500000000236012565125403014643 0ustar00oconradoconrad00000000000000_______________________________________________________________________________ SAGA 2.1.2 - System for Automated Geoscientific Analyses http://www.saga-gis.org _______________________________________________________________________________ AUTHORS _______________________________________________________________________________ Date: January, 10th 2014 A. SAGA GUI - SAGA Graphical User Interface ------------------------------------------- Copyrights (c) 2005-2014 by Olaf Conrad Portions (c) 2008-2014 by Volker Wichmann GNU General Public License (GPL) B. SAGA CMD - SAGA Command Line Processor ----------------------------------------- Copyrights (c) 2005-2014 by Olaf Conrad GNU General Public License (GPL) C. SAGA API - SAGA Application Programming Interface ---------------------------------------------------- Copyrights (c) 2002-2014 by Olaf Conrad Portions (c) 2008-2014 by Volker Wichmann Portions (c) 2005-2006 by Victor Olaya Portions (c) 2002 by Andre Ringeler GNU Lesser General Public License (LGPL) D. SAGA Modules --------------- Please have a look at the module descriptions supplied with each module on information about the responsible authors. saga-2.2.3/py-compile0000755000175000017500000001107612565125533015605 0ustar00oconradoconrad00000000000000#!/bin/sh # py-compile - Compile a Python program scriptversion=2011-06-08.12; # UTC # Copyright (C) 2000-2013 Free Software Foundation, Inc. # 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, 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . if [ -z "$PYTHON" ]; then PYTHON=python fi me=py-compile usage_error () { echo "$me: $*" >&2 echo "Try '$me --help' for more information." >&2 exit 1 } basedir= destdir= while test $# -ne 0; do case "$1" in --basedir) if test $# -lt 2; then usage_error "option '--basedir' requires an argument" else basedir=$2 fi shift ;; --destdir) if test $# -lt 2; then usage_error "option '--destdir' requires an argument" else destdir=$2 fi shift ;; -h|--help) cat <<\EOF Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..." Byte compile some python scripts FILES. Use --destdir to specify any leading directory path to the FILES that you don't want to include in the byte compiled file. Specify --basedir for any additional path information you do want to be shown in the byte compiled file. Example: py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py Report bugs to . EOF exit $? ;; -v|--version) echo "$me $scriptversion" exit $? ;; --) shift break ;; -*) usage_error "unrecognized option '$1'" ;; *) break ;; esac shift done files=$* if test -z "$files"; then usage_error "no files given" fi # if basedir was given, then it should be prepended to filenames before # byte compilation. if [ -z "$basedir" ]; then pathtrans="path = file" else pathtrans="path = os.path.join('$basedir', file)" fi # if destdir was given, then it needs to be prepended to the filename to # byte compile but not go into the compiled file. if [ -z "$destdir" ]; then filetrans="filepath = path" else filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)" fi $PYTHON -c " import sys, os, py_compile, imp files = '''$files''' sys.stdout.write('Byte-compiling python modules...\n') for file in files.split(): $pathtrans $filetrans if not os.path.exists(filepath) or not (len(filepath) >= 3 and filepath[-3:] == '.py'): continue sys.stdout.write(file) sys.stdout.flush() if hasattr(imp, 'get_tag'): py_compile.compile(filepath, imp.cache_from_source(filepath), path) else: py_compile.compile(filepath, filepath + 'c', path) sys.stdout.write('\n')" || exit $? # this will fail for python < 1.5, but that doesn't matter ... $PYTHON -O -c " import sys, os, py_compile, imp # pypy does not use .pyo optimization if hasattr(sys, 'pypy_translation_info'): sys.exit(0) files = '''$files''' sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n') for file in files.split(): $pathtrans $filetrans if not os.path.exists(filepath) or not (len(filepath) >= 3 and filepath[-3:] == '.py'): continue sys.stdout.write(file) sys.stdout.flush() if hasattr(imp, 'get_tag'): py_compile.compile(filepath, imp.cache_from_source(filepath, False), path) else: py_compile.compile(filepath, filepath + 'o', path) sys.stdout.write('\n')" 2>/dev/null || : # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: saga-2.2.3/config.sub0000755000175000017500000010535412565125521015564 0ustar00oconradoconrad00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2013 Free Software Foundation, Inc. timestamp='2013-08-10' # This file 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 3 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, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches with a ChangeLog entry to config-patches@gnu.org. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 \ | or1k | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or1k-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: saga-2.2.3/COPYING0000664000175000017500000000460312565125417014635 0ustar00oconradoconrad00000000000000Copyright and License Statement _______________________________________________________________________________ The System for Automated Geoscientific Analyses (SAGA) is copyright by the authors listed below. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) and the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation. _______________________________________________________________________________ ------------------------------------------ SAGA GUI - SAGA Graphical User Interface ------------------------------------------ Copyrights (c) 2005-2014 by Olaf Conrad Portions (c) 2008-2014 by Volker Wichmann GNU General Public License (GPL) ---------------------------------------- SAGA CMD - SAGA Command Line Processor ---------------------------------------- Copyrights (c) 2005-2014 by Olaf Conrad GNU General Public License (GPL) --------------------------------------------------- SAGA API - SAGA Application Programming Interface --------------------------------------------------- Copyrights (c) 2002-2014 by Olaf Conrad Portions (c) 2008-2014 by Volker Wichmann Portions (c) 2005-2006 by Victor Olaya Portions (c) 2002 by Andre Ringeler GNU Lesser General Public License (LGPL) -------------- SAGA Modules -------------- Please have a look at the module descriptions supplied with each module on information about the responsible authors and the licenses used. Most modules are licensed under the GNU General Public License (GPL). _______________________________________________________________________________ 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 (GPL) and GNU Lesser General Public License (LGPL) for more details. You should have received a copy of both licenses along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA _______________________________________________________________________________ Questions regarding SAGA GIS should be directed to one of the SAGA forums or the developer mailing list available here: https://sourceforge.net/projects/saga-gis/ Project homepage: http://www.saga-gis.org/ saga-2.2.3/config.h.in0000664000175000017500000001150412622651210015610 0ustar00oconradoconrad00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* Define to 1 if you have the header file. */ #undef HAVE_FLOAT_H /* Define to 1 if you have the `floor' function. */ #undef HAVE_FLOOR /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `geotrans' library (-lgeotrans). */ #undef HAVE_LIBGEOTRANS /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H /* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMMOVE /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `modf' function. */ #undef HAVE_MODF /* Define to 1 if PostgreSQL libraries are available */ #undef HAVE_POSTGRESQL /* Define to 1 if you have the `pow' function. */ #undef HAVE_POW /* If available, contains the Python version number currently in use. */ #undef HAVE_PYTHON /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC /* Define to 1 if you have the `sqrt' function. */ #undef HAVE_SQRT /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Define to 1 if `lstat' dereferences a symlink specified with a trailing slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME /* Version number of package */ #undef VERSION /* "built with GUI and interactive modules" */ #undef WITH_GUI /* "built with ODBC support" */ #undef WITH_ODBC /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc /* Define to `unsigned int' if does not define. */ #undef size_t saga-2.2.3/ChangeLog0000664000175000017500000000022012565125403015336 0ustar00oconradoconrad00000000000000Changelogs and other release information are available in the SAGA wiki: http://sourceforge.net/p/saga-gis/wiki/SAGA%20Release%20Information/ saga-2.2.3/Makefile.in0000664000175000017500000006365612622651156015662 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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 = . DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config.h.in AUTHORS COPYING ChangeLog NEWS README \ compile config.guess config.sub depcomp install-sh missing \ py-compile ltmain.sh ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) 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" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 = . src @DEBUG_TRUE@AM_CFLAGS = -g -DDEBUG @DEBUG_TRUE@AM_CXXFLAGS = -g -DDEBUG $(GOMPFLAGS) ACLOCAL_AMFLAGS = -I m4 # additional directories to package EXTRA_DIST = ./src/scripting all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 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 clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt # 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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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 -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile config.h 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr \ distclean-libtool 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 $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -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: $(am__recursive_targets) all install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-hook dist-lzip 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-am uninstall uninstall-am dist-hook: rm -rf `find $(distdir)/src/scripting -type d -name .svn` # 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: saga-2.2.3/configure.ac0000775000175000017500000002376212622651133016073 0ustar00oconradoconrad00000000000000# $Id: configure.ac 2692 2015-11-17 16:13:05Z oconrad $ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) AC_INIT(saga, 2.2.3, BUG-REPORT-ADDRESS) AC_CONFIG_SRCDIR([src/saga_core/saga_gui/wksp_data_menu_files.cpp]) AC_CONFIG_HEADER([config.h]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([foreign tar-ustar subdir-objects]) # Checks for programs. AC_PROG_CXX AC_PROG_CC AC_PROG_INSTALL AC_PROG_LIBTOOL # Checks for libraries. AC_CHECK_LIB([cv], [cvGetRows], CVFOUND=1,,) AC_CHECK_LIB([geotrans], [Set_Mercator_Coordinates]) AC_CHECK_LIB([fftw3],[fftw_execute],FFTWFOUND=1,) AC_CHECK_LIB([jasper], [jas_calloc],JASPERFOUND=1,,) AC_CHECK_LIB([las], [LAS_GetVersion], LASFOUND=1,,) AC_CHECK_LIB(hpdf, HPDF_Pages_New, HARUFOUND=1,,) AC_CHECK_LIB([odbc], [SQLFetch], ODBCFOUND=1,[ODBC \(libodbc\) library not found]) AC_CHECK_LIB([proj], [pj_is_latlong], PROJFOUND=1,,) AC_CHECK_LIB([vigraimpex], [VIGRA_RGBE_ReadPixels_Raw],VIGRAFOUND=1,) AC_CHECK_LIB([gomp], [omp_get_num_threads], GOMPFOUND=1,,) # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([float.h malloc.h memory.h stdlib.h string.h unistd.h]) AC_CHECK_HEADERS([wchar.h]) # todo: check for headers of the libraries above # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T AC_STRUCT_TM # Checks for platform characteristics. AC_C_BIGENDIAN # Checks for library functions. AC_FUNC_MALLOC AC_FUNC_MEMCMP AC_FUNC_REALLOC AC_FUNC_STAT AC_FUNC_STRTOD AC_FUNC_VPRINTF AC_CHECK_FUNCS([floor memmove memset modf pow sqrt strchr strdup strerror strrchr strstr strtol]) # add a local directory as base for libs and include files AC_MSG_CHECKING([for local include/lib path]) AC_ARG_WITH(local,[ --with-local[=dir] search /usr/local or other directory for includes and libs],,) if test "$with_local" != "no" -a "$with_local" != "" ; then if test "$with_local" = "yes" ; then ADD_PREFIX=/usr/local else ADD_PREFIX=$with_local fi AC_MSG_RESULT(adding $ADD_PREFIX) LOCAL_LIBS="-L$ADD_PREFIX/lib" LOCAL_INCS="-I$ADD_PREFIX/include" AC_SUBST(LOCAL_LIBS,$LOCAL_LIBS) AC_SUBST(LOCAL_INCS,$LOCAL_INCS) else AC_MSG_RESULT([none]) fi # conditionals # wxwidgets # the test could be extended to check for wx-config --version too if test "`wx-config --list | grep unicode`" != "" ; then AM_CONDITIONAL(SAGA_UNICODE, true) else AC_MSG_ERROR(SAGA requires a unicode build of wxGTK) exit fi # postgresql/postgis AX_LIB_POSTGRESQL([8.0]) if test "x$found_postgresql" = "xyes"; then echo "checking whether to enable postgresql... yes" else echo "checking whether to enable postgresql... no" fi AM_CONDITIONAL(HAVE_POSTGRESQL, test "x$found_postgresql" = "xyes") # debug AC_ARG_ENABLE(debug, [ --enable-debug Turn on debugging], [case "${enableval}" in yes) debug=true ;; no) debug=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; esac],[debug=false]) AM_CONDITIONAL(DEBUG, test x$debug = xtrue) # gui AC_ARG_ENABLE(gui, [ --disable-gui Do not build GUI and interactive modules], [case "${enableval}" in yes) gui=true ;; no) gui=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --disable-gui) ;; esac],[gui=true]) AM_CONDITIONAL(WITH_GUI, test x$gui = xtrue) if test $gui = "false" ; then AC_MSG_RESULT([ GUI and interactive modules will NOT be built]) else AC_DEFINE([WITH_GUI], [1], ["built with GUI and interactive modules"]) AC_MSG_RESULT([ GUI and interactive modules will be built]) fi # odbc AC_ARG_ENABLE(odbc, [ --disable-odbc Build without ODBC support], [case "${enableval}" in yes) odbc=true ;; no) odbc=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --disable-odbc) ;; esac],[odbc=true]) AM_CONDITIONAL(WITH_ODBC, test x$odbc = xtrue) if test $odbc = "false" ; then AC_MSG_RESULT([ ODBC support will NOT be built]) else AC_DEFINE([WITH_ODBC], [1], ["built with ODBC support"]) AC_MSG_RESULT([ ODBC support will be built]) fi # openmp AC_ARG_ENABLE(openmp, [ --disable-openmp Build without OpenMP support], [case "${enableval}" in yes) openmp=true ;; no) openmp=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --disable-openmp) ;; esac],[openmp=true]) AM_CONDITIONAL(OPENMP, test x$openmp = xtrue) if test $openmp = "false" ; then AC_MSG_RESULT([ OpenMP support disabled]) GOMPFLAGS="" else if test -n "$GOMPFOUND" ; then AC_MSG_RESULT([ Building with OpenMP support using libgomp]) GOMPFLAGS="-fopenmp -lgomp" else AC_MSG_RESULT([ libgomp not found, OpenMP support disabled]) GOMPFLAGS="" fi fi AC_SUBST(GOMPFLAGS) #AM_CONDITIONAL(X86_64, test "`uname -m`" = "x86_64") AM_CONDITIONAL(HAVE_CV, test -n "$CVFOUND") AM_CONDITIONAL(HAVE_LLAS, test -n "$LASFOUND") AM_CONDITIONAL(HAVE_VIGRA, test -n "$VIGRAFOUND" -a -n "$FFTWFOUND") AM_CONDITIONAL(HAVE_HARU, test -n "$HARUFOUND") 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_ARG_ENABLE(python, [ --enable-python Build python bindings for the saga api], [case "${enableval}" in yes) python=true ;; no) python=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-python) ;; esac],[python=false]) AM_CONDITIONAL(SAGA_PYTHON, test x$python = xtrue) if test x$python = xtrue; then AM_PATH_PYTHON AX_PYTHON_DEVEL([]) AX_PKG_SWIG(1.3.17,[],[]) AX_SWIG_ENABLE_CXX AX_SWIG_PYTHON fi #AC_CONFIG_FILES([Makefile]) AC_OUTPUT(Makefile \ src/Makefile \ src/saga_core/Makefile \ src/saga_core/saga_api/Makefile \ src/saga_core/saga_gdi/Makefile \ src/saga_core/saga_gui/Makefile \ src/saga_core/saga_gui/man/Makefile \ src/saga_core/saga_cmd/Makefile \ src/saga_core/saga_cmd/man/Makefile \ src/modules/Makefile \ src/modules/climate/Makefile \ src/modules/climate/climate_tools/Makefile \ src/modules/contrib/Makefile \ src/modules/contrib/contrib_peregro/Makefile \ src/modules/db/Makefile \ src/modules/db/db_odbc/Makefile \ src/modules/db/db_pgsql/Makefile \ src/modules/docs/Makefile \ src/modules/docs/docs_html/Makefile \ src/modules/docs/docs_pdf/Makefile \ src/modules/garden/Makefile \ src/modules/garden/garden_3d_viewer/Makefile \ src/modules/garden/garden_fractals/Makefile \ src/modules/garden/garden_games/Makefile \ src/modules/garden/garden_learn_to_program/Makefile \ src/modules/garden/garden_webservices/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_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/imagery/Makefile \ src/modules/imagery/imagery_classification/Makefile \ src/modules/imagery/imagery_opencv/Makefile \ src/modules/imagery/imagery_maxent/Makefile \ src/modules/imagery/imagery_photogrammetry/Makefile \ src/modules/imagery/imagery_segmentation/Makefile \ src/modules/imagery/imagery_svm/Makefile \ src/modules/imagery/imagery_tools/Makefile \ src/modules/imagery/imagery_vigra/Makefile \ src/modules/io/Makefile \ src/modules/io/io_esri_e00/Makefile \ src/modules/io/io_gdal/Makefile \ src/modules/io/io_gps/Makefile \ src/modules/io/io_grid/Makefile \ src/modules/io/io_grid_grib2/Makefile \ src/modules/io/io_grid_image/Makefile \ src/modules/io/io_shapes/Makefile \ src/modules/io/io_shapes_dxf/Makefile \ src/modules/io/io_shapes_las/Makefile \ src/modules/io/io_table/Makefile \ src/modules/io/io_virtual/Makefile \ src/modules/pointcloud/Makefile \ src/modules/pointcloud/pointcloud_tools/Makefile \ src/modules/pointcloud/pointcloud_viewer/Makefile \ src/modules/projection/Makefile \ src/modules/projection/pj_georeference/Makefile \ src/modules/projection/pj_proj4/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/simulation/Makefile \ src/modules/simulation/sim_cellular_automata/Makefile \ src/modules/simulation/sim_ecosystems_hugget/Makefile \ src/modules/simulation/sim_erosion/Makefile \ src/modules/simulation/sim_fire_spreading/Makefile \ src/modules/simulation/sim_hydrology/Makefile \ src/modules/simulation/sim_ihacres/Makefile \ src/modules/simulation/sim_qm_of_esp/Makefile \ src/modules/simulation/sim_rivflow/Makefile \ src/modules/statistics/Makefile \ src/modules/statistics/statistics_grid/Makefile \ src/modules/statistics/statistics_kriging/Makefile \ src/modules/statistics/statistics_points/Makefile \ src/modules/statistics/statistics_regression/Makefile \ src/modules/table/Makefile \ src/modules/table/table_calculus/Makefile \ src/modules/table/table_tools/Makefile \ src/modules/terrain_analysis/Makefile \ src/modules/terrain_analysis/ta_channels/Makefile \ src/modules/terrain_analysis/ta_compound/Makefile \ src/modules/terrain_analysis/ta_hydrology/Makefile \ src/modules/terrain_analysis/ta_lighting/Makefile \ src/modules/terrain_analysis/ta_morphometry/Makefile \ src/modules/terrain_analysis/ta_preprocessor/Makefile \ src/modules/terrain_analysis/ta_profiles/Makefile \ src/modules/terrain_analysis/ta_slope_stability/Makefile \ src/modules/tin/Makefile \ src/modules/tin/tin_tools/Makefile \ src/modules/tin/tin_viewer/Makefile \ ) saga-2.2.3/aclocal.m40000664000175000017500000014372512622651153015446 0ustar00oconradoconrad00000000000000# generated automatically by aclocal 1.14.1 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # 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. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.14.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.14.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _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"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # --------------------------------------------------------------------------- # Adds support for distributing Python modules and packages. To # install modules, copy them to $(pythondir), using the python_PYTHON # automake variable. To install a package with the same name as the # automake package, install to $(pkgpythondir), or use the # pkgpython_PYTHON automake variable. # # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as # locations to install python extension modules (shared libraries). # Another macro is required to find the appropriate flags to compile # extension modules. # # If your package is configured with a different prefix to python, # users will have to add the install directory to the PYTHONPATH # environment variable, or create a .pth file (see the python # documentation for details). # # If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will # cause an error if the version of python installed on the system # doesn't meet the requirement. MINIMUM-VERSION should consist of # numbers and dots only. AC_DEFUN([AM_PATH_PYTHON], [ dnl Find a Python interpreter. Python versions prior to 2.0 are not dnl supported. (2.0 was released on October 16, 2000). m4_define_default([_AM_PYTHON_INTERPRETER_LIST], [python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 dnl python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0]) AC_ARG_VAR([PYTHON], [the Python interpreter]) m4_if([$1],[],[ dnl No version check is needed. # Find any Python interpreter. if test -z "$PYTHON"; then AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :) fi am_display_PYTHON=python ], [ dnl A version check is needed. if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. AC_MSG_CHECKING([whether $PYTHON version is >= $1]) AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_MSG_ERROR([Python interpreter is too old])]) am_display_PYTHON=$PYTHON else # Otherwise, try each interpreter until we find one that satisfies # VERSION. AC_CACHE_CHECK([for a Python interpreter with version >= $1], [am_cv_pathless_PYTHON],[ for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do test "$am_cv_pathless_PYTHON" = none && break AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) done]) # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. if test "$am_cv_pathless_PYTHON" = none; then PYTHON=: else AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON]) fi am_display_PYTHON=$am_cv_pathless_PYTHON fi ]) if test "$PYTHON" = :; then dnl Run any user-specified action, or abort. m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])]) else dnl Query Python for its version number. Getting [:3] seems to be dnl the best way to do this; it's what "site.py" does in the standard dnl library. AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version], [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`]) AC_SUBST([PYTHON_VERSION], [$am_cv_python_version]) dnl Use the values of $prefix and $exec_prefix for the corresponding dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made dnl distinct variables so they can be overridden if need be. However, dnl general consensus is that you shouldn't need this ability. AC_SUBST([PYTHON_PREFIX], ['${prefix}']) AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}']) dnl At times (like when building shared libraries) you may want dnl to know which OS platform Python thinks this is. AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform], [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`]) AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform]) # Just factor out some code duplication. am_python_setup_sysconfig="\ import sys # Prefer sysconfig over distutils.sysconfig, for better compatibility # with python 3.x. See automake bug#10227. try: import sysconfig except ImportError: can_use_sysconfig = 0 else: can_use_sysconfig = 1 # Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs: # try: from platform import python_implementation if python_implementation() == 'CPython' and sys.version[[:3]] == '2.7': can_use_sysconfig = 0 except ImportError: pass" dnl Set up 4 directories: dnl pythondir -- where to install python scripts. This is the dnl site-packages directory, not the python standard library dnl directory like in previous automake betas. This behavior dnl is more consistent with lispdir.m4 for example. dnl Query distutils for this directory. AC_CACHE_CHECK([for $am_display_PYTHON script directory], [am_cv_python_pythondir], [if test "x$prefix" = xNONE then am_py_prefix=$ac_default_prefix else am_py_prefix=$prefix fi am_cv_python_pythondir=`$PYTHON -c " $am_python_setup_sysconfig if can_use_sysconfig: sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'}) else: from distutils import sysconfig sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix') sys.stdout.write(sitedir)"` case $am_cv_python_pythondir in $am_py_prefix*) am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'` am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"` ;; *) case $am_py_prefix in /usr|/System*) ;; *) am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages ;; esac ;; esac ]) AC_SUBST([pythondir], [$am_cv_python_pythondir]) dnl pkgpythondir -- $PACKAGE directory under pythondir. Was dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is dnl more consistent with the rest of automake. AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE]) dnl pyexecdir -- directory for installing python extension modules dnl (shared libraries) dnl Query distutils for this directory. AC_CACHE_CHECK([for $am_display_PYTHON extension module directory], [am_cv_python_pyexecdir], [if test "x$exec_prefix" = xNONE then am_py_exec_prefix=$am_py_prefix else am_py_exec_prefix=$exec_prefix fi am_cv_python_pyexecdir=`$PYTHON -c " $am_python_setup_sysconfig if can_use_sysconfig: sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'}) else: from distutils import sysconfig sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix') sys.stdout.write(sitedir)"` case $am_cv_python_pyexecdir in $am_py_exec_prefix*) am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'` am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"` ;; *) case $am_py_exec_prefix in /usr|/System*) ;; *) am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages ;; esac ;; esac ]) AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir]) dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE) AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE]) dnl Run any user-specified action. $2 fi ]) # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # --------------------------------------------------------------------------- # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. # Run ACTION-IF-FALSE otherwise. # This test uses sys.hexversion instead of the string equivalent (first # word of sys.version), in order to cope with versions such as 2.2c1. # This supports Python 2.0 or higher. (2.0 was released on October 16, 2000). AC_DEFUN([AM_PYTHON_CHECK_VERSION], [prog="import sys # split strings by '.' and convert to numeric. Append some zeros # because we need at least 4 digits for the hex conversion. # map returns an iterator in Python 3.0 and a list in 2.x minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]] minverhex = 0 # xrange is not present in Python 3.0 and range returns an iterator for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]] sys.exit(sys.hexversion < minverhex)" AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/ax_lib_postgresql.m4]) m4_include([m4/ax_pkg_swig.m4]) m4_include([m4/ax_python_devel.m4]) m4_include([m4/ax_swig_enable_cxx.m4]) m4_include([m4/ax_swig_python.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) saga-2.2.3/src/0000775000175000017500000000000012634325735014370 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/0000775000175000017500000000000012634325752016037 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/simulation/0000775000175000017500000000000012634325747020227 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/simulation/sim_ecosystems_hugget/0000775000175000017500000000000012634325746024637 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/simulation/sim_ecosystems_hugget/Hugget_02.h0000664000175000017500000001045012565125410026521 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hugget_02.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // Hugget_02.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Hugget_02_H #define HEADER_INCLUDED__Hugget_02_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CHugget_02 : public CSG_Module { public: CHugget_02(void); virtual ~CHugget_02(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Hugget_02_H saga-2.2.3/src/modules/simulation/sim_ecosystems_hugget/Hugget_01.cpp0000664000175000017500000001640712565125410027063 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hugget_01.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // Hugget_01.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Hugget_01.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CHugget_01::CHugget_01(void) { Set_Name (_TL("01: A Simple Litter System")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "A simple litter system model using the euler method. " "Carbon storage C is calculated in dependency of litter fall rate (Cinput) " "and rate constant for litter loss (Closs) as:\n" "C(t + 1) = C(t) + (Cinput - Closs * C(t)) * dt\n" "\nTypical values:\n" "\n- Tropical Rainforest:\n" "-- Litter fall rate: 500 [g/m2/a]\n" "-- Litter loss rate: 2.0 [1/a]\n" "\n- Temperate forest:\n" "-- Litter fall rate: 240 [g/m2/a]\n" "-- Litter loss rate: 0.4 [1/a]\n" "\n- Boreal forest:\n" "-- Litter fall rate: 50 [g/m2/a]\n" "-- Litter loss rate: 0.05 [1/a]\n" "\nReference:" "\nHugget, R.J. (1993): 'Modelling the Human Impact on Nature', Oxford University Press.\n") ); //----------------------------------------------------- Parameters.Add_Table( NULL , "TABLE" , _TL("Results"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "TIME_SPAN" , _TL("Time Span"), _TL(""), PARAMETER_TYPE_Double , 100.0, 0.0, true ); Parameters.Add_Value( NULL , "TIME_STEP" , _TL("Time Interval [a]"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( NULL , "C_INIT" , _TL("Initial Litter Storage [g/m\xb2]"), _TL(""), PARAMETER_TYPE_Double , 0.0, 0.0, true ); Parameters.Add_Value( NULL , "C_INPUT" , _TL("Litterfall Rate [g/m\xb2/a]"), _TL(""), PARAMETER_TYPE_Double , 240.0, 0.0, true ); Parameters.Add_Value( NULL , "C_OUTPUT" , _TL("Rate Constant for Litter Loss [1/a]"), _TL(""), PARAMETER_TYPE_Double , 0.4, 0.0, true ); } //--------------------------------------------------------- CHugget_01::~CHugget_01(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define WRITE_RECORD pRecord = pTable->Add_Record();\ pRecord->Set_Value(0, iStep);\ pRecord->Set_Value(1, iStep * dTime);\ pRecord->Set_Value(2, C); //--------------------------------------------------------- bool CHugget_01::On_Execute(void) { int iStep, nSteps; double sTime, dTime, C, C_Input, C_Loss; CSG_Table_Record *pRecord; CSG_Table *pTable; //----------------------------------------------------- sTime = Parameters("TIME_SPAN") ->asDouble(); dTime = Parameters("TIME_STEP") ->asDouble(); nSteps = (int)(sTime / dTime); C = Parameters("C_INIT") ->asDouble(); C_Input = Parameters("C_INPUT") ->asDouble(); C_Loss = Parameters("C_OUTPUT") ->asDouble(); pTable = Parameters("TABLE") ->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("A Simple Litter System")); pTable->Add_Field("STEP" , SG_DATATYPE_Int); pTable->Add_Field("TIME" , SG_DATATYPE_Double); pTable->Add_Field("CARBON" , SG_DATATYPE_Double); //----------------------------------------------------- if( C_Loss <= 0.0 ) { C_Loss = M_ALMOST_ZERO; } if( dTime >= 1.0 / C_Loss ) { if( !Error_Set(_TL("Time interval is to large for a stable solution.")) ) { return( false ); } } //----------------------------------------------------- for(iStep=0; iStep&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/simulation/sim_ecosystems_hugget DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_ecosystems_hugget_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la 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) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_ecosystems_hugget_la_SOURCES) DIST_SOURCES = $(libsim_ecosystems_hugget_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_ecosystems_hugget.la libsim_ecosystems_hugget_la_SOURCES = \ Hugget_01.cpp\ Hugget_02.cpp\ Hugget_03.cpp\ MLB_Interface.cpp\ Hugget_01.h\ Hugget_02.h\ Hugget_03.h\ MLB_Interface.h libsim_ecosystems_hugget_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) --foreign src/modules/simulation/sim_ecosystems_hugget/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_ecosystems_hugget/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_ecosystems_hugget.la: $(libsim_ecosystems_hugget_la_OBJECTS) $(libsim_ecosystems_hugget_la_DEPENDENCIES) $(EXTRA_libsim_ecosystems_hugget_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_ecosystems_hugget_la_OBJECTS) $(libsim_ecosystems_hugget_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Hugget_01.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Hugget_02.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Hugget_03.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/simulation/sim_ecosystems_hugget/Hugget_02.cpp0000664000175000017500000002475212565125410027066 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hugget_02.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // Hugget_02.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Hugget_02.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CHugget_02::CHugget_02(void) { CSG_Parameter *pNode; Set_Name (_TL("02: Carbon Cycle Simulation for Terrestrial Biomass")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Simulation of the Carbon Cycle in Terrestrial Biomass. " "\nReference:" "\nHugget, R.J. (1993): 'Modelling the Human Impact on Nature', Oxford University Press.\n") ); //----------------------------------------------------- Parameters.Add_Table( NULL , "TABLE" , _TL("Results"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "TIME_SPAN" , _TL("Time Span"), _TL(""), PARAMETER_TYPE_Double , 100.0, 0.0, true ); Parameters.Add_Value( NULL , "TIME_STEP" , _TL("Time Interval [a]"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); //----------------------------------------------------- Parameters.Add_Value( NULL , "PRIMPROD" , _TL("Net Primary Production [Gt Carbon / a]"), _TL(""), PARAMETER_TYPE_Double , 27.8, 0.0, true ); Parameters.Add_Value( NULL , "CHUMIFY" , _TL("Humification Factor"), _TL(""), PARAMETER_TYPE_Double , 0.4, 0.0, true ); Parameters.Add_Value( NULL , "CCARBON" , _TL("Carbonization Factor"), _TL(""), PARAMETER_TYPE_Double , 0.05, 0.0, true ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_1", _TL("Partition Coefficients"), _TL("")); Parameters.Add_Value( pNode , "P_LEAV" , _TL("Leaves"), _TL(""), PARAMETER_TYPE_Double , 0.3, 0.0, true ); Parameters.Add_Value( pNode , "P_BRAN" , _TL("Branches"), _TL(""), PARAMETER_TYPE_Double , 0.2, 0.0, true ); Parameters.Add_Value( pNode , "P_STEM" , _TL("Stems"), _TL(""), PARAMETER_TYPE_Double , 0.3, 0.0, true ); Parameters.Add_Value( pNode , "P_ROOT" , _TL("Roots"), _TL(""), PARAMETER_TYPE_Double , 0.2, 0.0, true ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_2", _TL("Transfer Coefficients"), _TL("")); Parameters.Add_Value( pNode , "K_LEAV_LITT" , _TL("Leaves to Litter"), _TL(""), PARAMETER_TYPE_Double , 1.0, 0.0, true ); Parameters.Add_Value( pNode , "K_BRAN_LITT" , _TL("Branches to Litter"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( pNode , "K_STEM_LITT" , _TL("Stems to Litter"), _TL(""), PARAMETER_TYPE_Double , 0.033, 0.0, true ); Parameters.Add_Value( pNode , "K_ROOT_HUMU" , _TL("Roots to Humus"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( pNode , "K_LITT_HUMU" , _TL("Litter to Humus"), _TL(""), PARAMETER_TYPE_Double , 1.0, 0.0, true ); Parameters.Add_Value( pNode , "K_HUMU_COAL" , _TL("Humus to Charcoal"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( pNode , "K_COAL_ENVI" , _TL("Charcoal to Environment"), _TL(""), PARAMETER_TYPE_Double , 0.002, 0.0, true ); } //--------------------------------------------------------- CHugget_02::~CHugget_02(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define WRITE_RECORD pRecord = pTable->Add_Record();\ pRecord->Set_Value(0, iStep);\ pRecord->Set_Value(1, iStep * dTime);\ pRecord->Set_Value(2, C_Leav);\ pRecord->Set_Value(3, C_Bran);\ pRecord->Set_Value(4, C_Stem);\ pRecord->Set_Value(5, C_Root);\ pRecord->Set_Value(6, C_Litt);\ pRecord->Set_Value(7, C_Humu);\ pRecord->Set_Value(8, C_Coal); //--------------------------------------------------------- bool CHugget_02::On_Execute(void) { int iStep, nSteps; double sTime, dTime, PrimProd, cHumify, cCarbon, C_Leav, C_Bran, C_Stem, C_Root, C_Litt, C_Humu, C_Coal, P_Leav, P_Bran, P_Stem, P_Root, K_Leav_Litt, K_Bran_Litt, K_Stem_Litt, K_Root_Humu, K_Litt_Humu, K_Humu_Coal, K_Coal_Envi, d_Leav_Litt, d_Bran_Litt, d_Stem_Litt, d_Root_Humu, d_Litt_Humu, d_Humu_Coal, d_Coal_Envi; CSG_Table_Record *pRecord; CSG_Table *pTable; //----------------------------------------------------- sTime = Parameters("TIME_SPAN") ->asDouble(); dTime = Parameters("TIME_STEP") ->asDouble(); nSteps = (int)(sTime / dTime); PrimProd = Parameters("PRIMPROD") ->asDouble(); cHumify = Parameters("CHUMIFY") ->asDouble(); cCarbon = Parameters("CCARBON") ->asDouble(); P_Leav = Parameters("P_LEAV") ->asDouble(); P_Bran = Parameters("P_BRAN") ->asDouble(); P_Stem = Parameters("P_STEM") ->asDouble(); P_Root = Parameters("P_ROOT") ->asDouble(); K_Leav_Litt = Parameters("K_LEAV_LITT") ->asDouble(); K_Bran_Litt = Parameters("K_BRAN_LITT") ->asDouble(); K_Stem_Litt = Parameters("K_STEM_LITT") ->asDouble(); K_Root_Humu = Parameters("K_ROOT_HUMU") ->asDouble(); K_Litt_Humu = Parameters("K_LITT_HUMU") ->asDouble(); K_Humu_Coal = Parameters("K_HUMU_COAL") ->asDouble(); K_Coal_Envi = Parameters("K_COAL_ENVI") ->asDouble(); pTable = Parameters("TABLE") ->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("Carbon Cycle Simulation")); pTable->Add_Field("STEP" , SG_DATATYPE_Int); pTable->Add_Field("TIME" , SG_DATATYPE_Double); pTable->Add_Field("LEAVES" , SG_DATATYPE_Double); pTable->Add_Field("BRANCHES", SG_DATATYPE_Double); pTable->Add_Field("STEMS" , SG_DATATYPE_Double); pTable->Add_Field("ROOTS" , SG_DATATYPE_Double); pTable->Add_Field("LITTER" , SG_DATATYPE_Double); pTable->Add_Field("HUMUS" , SG_DATATYPE_Double); pTable->Add_Field("CHARCOAL", SG_DATATYPE_Double); //----------------------------------------------------- C_Leav = 0.0; C_Bran = 0.0; C_Stem = 0.0; C_Root = 0.0; C_Litt = 0.0; C_Humu = 0.0; C_Coal = 0.0; //----------------------------------------------------- for(iStep=0; iStepasDouble(); dTime = Parameters("TIME_STEP") ->asDouble(); nSteps = (int)(sTime / dTime); bUpdate = Parameters("UPDATE") ->asBool(); N_Init = Parameters("NINIT") ->asDouble(); N_Rain = Parameters("NRAIN") ->asDouble(); pDEM = Parameters("DEM") ->asGrid(); pN = Parameters("NSTORE") ->asGrid(); pN->Assign(N_Init); DataObject_Set_Colors(pN, 100, SG_COLORS_YELLOW_GREEN); N_1.Create(pN, SG_DATATYPE_Float); Init_Slopes(pDEM, S); //----------------------------------------------------- for(iStep=0; iStep<=nSteps && Set_Progress(iStep, nSteps); iStep++) { s.Printf(SG_T("%s: %f (%f)"), _TL("Time [a]"), dTime * iStep, sTime); Process_Set_Text(s); if( bUpdate ) { DataObject_Update(pN, pN->Get_ZMin(), pN->Get_ZMax(), true); } //------------------------------------------------- Step(S, pN, &N_1, N_Rain, dTime); //------------------------------------------------- pN->Assign(&N_1); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CHugget_03::Init_Slopes(CSG_Grid *pDEM, CSG_Grid S[8]) { int x, y, i, ix, iy; double z; //----------------------------------------------------- for(i=0; i<8; i++) { S[i].Create(pDEM, SG_DATATYPE_Float); } //----------------------------------------------------- for(y=0; yis_NoData(x, y) ) { for(i=0; i<8; i++) { S[i].Set_NoData(x, y); } } else { z = pDEM->asDouble(x, y); for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( pDEM->is_InGrid(ix, iy) ) { S[i].Set_Value(x, y, (pDEM->asDouble(ix, iy) - z) / Get_Length(i)); } else { S[i].Set_Value(x, y, 0.0); } } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CHugget_03::Step(CSG_Grid S[8], CSG_Grid *pN, CSG_Grid *pN_1, double N_Rain, double dTime) { int x, y, i; double s, dN; //----------------------------------------------------- for(y=0; yasDouble(x, y); } else { dN += s * pN->asDouble(Get_xTo(i, x), Get_yTo(i, y)); } } } s = pN->asDouble(x, y) + (dN + N_Rain) * dTime; if( s < 0.0 ) { s = N_Rain * dTime; } pN_1->Set_Value(x, y, s); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_ecosystems_hugget/MLB_Interface.cpp0000664000175000017500000001175112565125410027727 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Modelling the Human Impact on Nature") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("Olaf Conrad (c) 2003") ); case MLB_INFO_Description: return( _TW( "Numerical models for ecological processes. " "Examples have been taken from:\n" "Hugget, R.J. (1993): 'Modelling the Human Impact on Nature', Oxford University Press." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Ecology|Modelling the Human Impact on Nature") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Hugget_01.h" #include "Hugget_02.h" #include "Hugget_03.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { CSG_Module *pModule; switch( i ) { case 0: pModule = new CHugget_01; break; case 1: pModule = new CHugget_02; break; case 2: pModule = new CHugget_03; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/simulation/sim_ecosystems_hugget/Makefile.am0000664000175000017500000000127212565125410026662 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_ecosystems_hugget.la libsim_ecosystems_hugget_la_SOURCES =\ Hugget_01.cpp\ Hugget_02.cpp\ Hugget_03.cpp\ MLB_Interface.cpp\ Hugget_01.h\ Hugget_02.h\ Hugget_03.h\ MLB_Interface.h libsim_ecosystems_hugget_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/simulation/sim_ecosystems_hugget/MLB_Interface.h0000664000175000017500000001000312565125410027361 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__sim_lectures_hugget_H #define HEADER_INCLUDED__sim_lectures_hugget_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef sim_ecosystems_hugget_EXPORTS #define sim_ecosystems_hugget_EXPORT _SAGA_DLL_EXPORT #else #define sim_ecosystems_hugget_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__sim_lectures_hugget_H saga-2.2.3/src/modules/simulation/sim_ecosystems_hugget/Hugget_01.h0000664000175000017500000001045012565125410026520 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hugget_01.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // Hugget_01.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Hugget_01_H #define HEADER_INCLUDED__Hugget_01_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CHugget_01 : public CSG_Module { public: CHugget_01(void); virtual ~CHugget_01(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Hugget_01_H saga-2.2.3/src/modules/simulation/sim_rivflow/0000775000175000017500000000000012634325747022567 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/simulation/sim_rivflow/LandFlow.cpp0000664000175000017500000035227612565125410025004 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // LandFlow.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "LandFlow.h" #include #include #include #include #include #include #include #include #include #include using namespace std; #define ESC 27 //--------------------------------------------------------- //######################################################### CLandFlow::CLandFlow(void) { //----------------------------------------------------- // Modul information Set_Name ("LandFlow Version 1.0 (build 3.5.1b)"); //Manuelle erhoehung der WaterUseDATEN (NUR fuer Entnahme aus HG-Rasterzelle) Set_Author ("Christian Alwardt"); Set_Description ("Landflow of RiverBasine"); cVers = 3.51; //################################################################### //----------------------------------------------------- //Parameters list... //----------------------------------------------------- //Parameter Gruppierung... CSG_Parameter *pNode0; CSG_Parameter *pNode1; CSG_Parameter *pNode2; CSG_Parameter *pNode3; CSG_Parameter *pNode4; CSG_Parameter *pNode5; CSG_Parameter *pNode11; CSG_Parameter *pNode21; CSG_Parameter *pNode41; CSG_Parameter *pNode42; CSG_Parameter *pNode51; CSG_Parameter *pNode52; CSG_Parameter *pNode53; CSG_Parameter *pNode54; CSG_Parameter *pNode55; pNode0 = Parameters.Add_Node( NULL , "SOURCE_NODE" , _TL("Eingangsdaten"), _TL("") ); pNode0 = Parameters.Add_Node( NULL , "TARGET_NODE" , _TL("Ausgabedaten"), _TL("") ); pNode1 = Parameters.Add_Node( NULL , "GENERAL_NODE", _TL("Allgemeine Parameter"), _TL("") ); pNode11 = Parameters.Add_Node( pNode1 , "LS_NODE", _TL("Vertikale Zufluesse"), _TL("") ); pNode2 = Parameters.Add_Node( NULL , "FLOW_NODE", _TL("Parameterwerte HD Modell"), _TL("") ); pNode21 = Parameters.Add_Node( pNode2 , "RIV_NODE", _TL("Hauptgerinne-Parameter (erweitertes HD-Modell)"), _TL("") ); pNode3 = Parameters.Add_Node( NULL , "WTHD_NODE", _TL("Dynamische Flaechenwassernutzung und Abflussreduktion"), _TL("") ); pNode4 = Parameters.Add_Node( NULL , "RM_NODE", _TL("Punktuelle Rasterzellenmanipulation"), _TL("") ); pNode41 = Parameters.Add_Node( pNode4 , "RM1_NODE", _TL("Rasterzelle 1"), _TL("Manipulation des Gerinne- bzw. Hauptgerinneabflusses: Rasterzelle 1") ); pNode42 = Parameters.Add_Node( pNode4 , "RM2_NODE", _TL("Rasterzelle 2"), _TL("Manipulation des Gerinne- bzw. Hauptgerinneabflusses: Rasterzelle 2") ); pNode5 = Parameters.Add_Node( NULL , "MONI_NODE", _TL("Test- und Monitoring-Routinen"), _TL("") ); pNode51 = Parameters.Add_Node( pNode5 , "EvP1_NODE", _TL("Evaluierungspunkt 1 [Default: Elbe5000]"), _TL("") ); pNode52 = Parameters.Add_Node( pNode5 , "EvP2_NODE", _TL("Evaluierungspunkt 2 [Default: Elbe5000]"), _TL("") ); pNode53 = Parameters.Add_Node( pNode5 , "EvP3_NODE", _TL("Evaluierungspunkt 3 [Default: Elbe5000]"), _TL("") ); pNode54 = Parameters.Add_Node( pNode5 , "RBM_NODE", _TL("Ausgangsrasterzelle Flusseinzugsgebiet [Default: Elbe5000]"), _TL("") ); pNode55 = Parameters.Add_Node( pNode5 , "TEST1_NODE", _TL("TestRoutine 1"), _TL("") ); //----------------------------------------------------- //Grids... Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT", "Gelaendemodell (DTM)", "Digitales Gelaendemodell des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT2" , "Hoehengradienten (Grad)", "Abflussgradienten jeder Rasterzelle des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT10" , "Flusseinzugsgebiet (BasinShare)", "Abgrenzung des Flusseinzugsgebiets mit den Teileinzugsgebieten des Flussnetzwerkes", PARAMETER_INPUT ); Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT8" , "HG-Raster (HGGrid)", "Hauptgerinnerasterzellen", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT9" , "HG-Hoehengradienten (HGGrad)", "Abflussgradienten der Hauptgerinnerasterzellen", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT11" , "Referenzverlauf Flussbilanz", "Raster des Referenzverlauf des (linearen) Hauptflussarmes, der zur Erstellung der Flusswasserbilanz herangezogen werden soll", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( NULL, "INPUT12" , "Zuflussrasterzellen (NumInFlowCells)", "Raster mit Angabe ueber die Anzahl der Rasterzellen, die in eine spezifische Rasterzelle (x,y) abflieszen", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( Parameters("WTHD_NODE"), "INPUT3" , "statische Wassserentnahme (statWUse)", "Flaechenbasierte statische Wassserentnahme pro RiverGridbox in. ACHTUNG: Funktioniert ggf. nur bei bereits initiierten Systemen bzw. Vorlauf", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT5" , "Fluss-Speicher einlesen", "Simulation mit spezifischen Gerinne- bzw. Hauptgerinne-Speicherwerten (ChannelFlow) initiieren", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT6" , "Oberflaechenabfluss-Speicher einlesen", "Simulation mit spezifischen Oberflaechenabfluss-Speicherwerten (OverlandFlow) initiieren", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT7" , "Grundwasserabfluss-Speicher einlesen", "Simulation mit spezifischen Grundwasserabfluss-Speicherwerten (BaseFlow) initiieren", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( Parameters("TARGET_NODE"), "OUTPUT" , "Fluss-Speicher ausgeben", "Fluss-Speicher 'CFCache' (ChannelFlowCache) am Ende der Simulation ausgeben - Initialisierungsdaten)", PARAMETER_OUTPUT ); Parameters.Add_Grid( Parameters("TARGET_NODE"), "OUTPUT2" , "Oberflaechenabfluss-Speicher ausgeben", "Oberflaechenabfluss-Speicher 'OFCache' (OverlandFlowCache) am Ende der Simulation ausgeben - Initialisierungsdaten", PARAMETER_OUTPUT ); Parameters.Add_Grid( Parameters("TARGET_NODE"), "OUTPUT3" , "Grundwasserabfluss-Speicher ausgeben", "Grundwasserabfluss-Speicher 'BFCache' (BaseFlowCache) am Ende der Simulation ausgeben - Initialisierungsdaten", PARAMETER_OUTPUT ); Parameters.Add_Grid( Parameters("TARGET_NODE"), "OUTPUT4" , "Wasserflussvolumen", "Wasserflussvolumen in m3/s", PARAMETER_OUTPUT ); Parameters.Add_Grid( Parameters("TARGET_NODE"), "OUTPUT5" , "SumRunoffDrainage", "Aufsummieren der vertikalen Runoff und Drainage Zufluesse fuer jede Rasterzelle ueber den gesamten Simulationsverlauf", PARAMETER_OUTPUT ); Parameters.Add_Grid( Parameters("WTHD_NODE"), "OUTPUT6" , "DynWUse", "Dynamisch eingelesene Flaechenwasssernutzung pro Rasterzelle. ACHTUNG: Funktioniert nur bei bereits initiierten Systemen bzw. Vorlauf", PARAMETER_OUTPUT //siehe Funktion WConsRiv() //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); //----------------------------------------------------- //Allgemeine Parameter... Parameters.Add_Value( Parameters("GENERAL_NODE"), "onlyRB" , "Berechnung nur im Flusseinzugsgebiet", "Der Abfluss wird nur ueber die Rasterzellen des Flusseinzugsgebietes berechnet", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "TimeStep" , "Zeitschrittdauer [s]", "Dauer eines Simulations-Zeitschritts in Sekunden", PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "CalcT", "automatisierter max. Zeitschritt", "Automatisierte Berechnung der maximal moeglichen Dauer eines Zeitschrittes in [s] - Zeitschrittdauern wird ignoriert.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "sYear" , "Startjahr", "Jahr in dem die Simulation zum 1. Januar gestartet wird", PARAMETER_TYPE_Int, 1999, 1979, true, 2009, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "DayNum" , "Anzahl der Simulationstage", "Anzahl der gesamten Simulationtage ueber die berechnete wird", PARAMETER_TYPE_Int, 365, 1, true, 7670, true ); Parameters.Add_FilePath( Parameters("GENERAL_NODE") , "Folder2", _TL("Speicherordner"), _TL("Ordern in den alle Ausgabedaten gespeichert werden sollen"), _TL("Textdatei|*.txt|All Files|*.*"), 0, false ,true ,false ); Parameters.Add_FilePath( Parameters("LS_NODE") , "Folder1", _TL("Pfad LS-Daten"), _TL("Ordnerpfad der Surface Runoff- und Drainagerasterdaten des Landoberflaechenschemas"), _TL("SAGA Grid Files (*.sgrd)|*.sgrd|All Files|*.*"),0 ,false ,true ,false ); Parameters.Add_Value( Parameters("LS_NODE"), "stRedFacR", "Reduzierungsfaktor Surface Runoff [% / 100]", "Statische Reduzierung des vertikalen Zuflusses 'Surface Runoff' in [% / 100] pro Zeitschritt.", PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); Parameters.Add_Value( Parameters("LS_NODE"), "autoFacD" , "Ausgleich der Surface Runoff Reduktion", "Erhoeht automatisch die Drainage um denjenigen Volumenbetrag, um den der Surface Runoff reduziert wurde. Wenn gesetzt, wird etwaige Reduzierung der Drainage NICHT beruecksichtigt!", PARAMETER_TYPE_Bool, 0 ); Parameters.Add_Value( Parameters("LS_NODE"), "stRedFacD", "Reduzierungsfaktor Drainage [% / 100]", "Statische Reduzierung des vertikalen Zuflusses der 'Drainage' in [% / 100] pro Zeitschritt.", PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); Parameters.Add_Value( Parameters("LS_NODE"), "OffsetR", "Offsetwert Surface Runoff [m3/s]", "Statischer Offsetwert auf den vertikalen Zufluss 'Surface Runoff' in [m3/s] je Rasterzelle. ACHTUNG wird auf jede Rasterzelle angewendet, daher limitiert auf +/-1 m3/s. Bei Wahl des Wertes Aufloesung beachten! ", PARAMETER_TYPE_Double, 0.0, -1.0, true, 1.0, true ); Parameters.Add_Value( Parameters("LS_NODE"), "OffsetD", "Offsetwert Drainage [m3/s]", "Statischer Offsetwert auf den vertikalen Zufluss 'Drainage' in [m3/s] je Rasterzelle. ACHTUNG wird auf jede Rasterzelle angewendet, daher limitiert auf +/-1 m3/s. Bei Wahl des Wertes Aufloesung beachten!", PARAMETER_TYPE_Double, 0.0, -1.0, true, 1.0, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "CacheUse", "Initiierung mit vorhandenen Speichern", "Initialisierung der Simulation mit spezifischen Speicherwerten (Raster und NCache)", PARAMETER_TYPE_Bool, false ); Parameters.Add_FilePath( Parameters("GENERAL_NODE") , "Folder4", _TL("NCache einlesen"), _TL("Einlesen der NCache Textdatei"), _TL("Textdatei (*.txt)|*.txt|All Files|*.*"),0 ,false ,false ,false ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "wNC" , "Ausgabe NCache", "Schreibt die Werte der Speicherkaskaden zum Ende Simulation in eine Textdatei (Initialisierungsdaten)", PARAMETER_TYPE_Bool, 0 ); //----------------------------------------------------- //Parameterwerte HD Modell Parameters.Add_Value( Parameters("FLOW_NODE"), "ParamC" , "Gerinne-Parameter cG", "Parameter cG zur Berechnung der Lagtime kG des Gerinneabflusses", PARAMETER_TYPE_Double, 6e-2, 0, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "ParamG" , "Oberflaechen-Parameter cO", "Parameter cO zur Berechnung der Lagtime kO des Oberflaechenabflusses", PARAMETER_TYPE_Double, 357e-3, 0, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "ParamB" , "Grundwasser-Parameter pB", "Parameter pB zur Berechnung der Lagtime kB des Grundwasserabflusses", PARAMETER_TYPE_Double, 300, 0, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "nG" , "Gerinne-Speicherkaskade nG", "Festlegen, wieviele Speicher die Gerinne-Speicherkaskade nG enthaelt", PARAMETER_TYPE_Int, 3, 1, true ); Parameters.Add_Choice( Parameters("RIV_NODE") , "RivG" , _TL("Beruecksichtigung der Hauptgerinnerasterzellen?"), _TL("Seperate Beruecksichtigung und Berechnung ueber Hauptgerinnerasterzellen - neben den normalen Gerinnerasterzellen."), CSG_String::Format(SG_T("%s|%s|")/*(SG_T("%s|%s|%s|%s|")*/, _TL("nein"), _TL("ja; bestimmen anhand eines Hauptgerinnerasters (HG Raster)")/*, _TL("ja; bestimmen ueber das Wasserflussvolumen (P:RFlow)"), _TL("ja; bestimmen ueber die jeweilige Anzahl der ZuflussRasterzellen (IR:NumInFlowCells, P:NumCells")*/ ), 1 ); Parameters.Add_Value( Parameters("RIV_NODE"), "ParamCr" , "Hauptgerinne-Parameter cHG", "Parameter cHG zur Berechnung der Lagtime kHG des ChannelFlow-River [optional siehe oben]", PARAMETER_TYPE_Double, 0.007, 0, true, 1.0, true ); Parameters.Add_Value( Parameters("RIV_NODE"), "nHG" , "Hauptgerinne-Speicherkaskade nHG", "Festlegen, wieviele Speicher die Hauptgerinne-Speicherkaskade enthaelt [optional siehe oben]", PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "EnfVmax", "Abflussgeschwindigkeit begrenzen", "Die mittlere Wasserabflussgeschwindigkeit wird auf einen Hoechstwert begrenzt - Zeitschrittvorgaben und automatisierter Zeitschritt wird ueberschrieben.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "VTresh" , "Oberer Abflussgeschwindigkeitsgrenzwert [km/h]", "Maximale mittlere Wasserabflussgeschwindigkeit in km/h", PARAMETER_TYPE_Double, 4, 0, true, 10, true //Achtung!! Obergrenze statisch eingestellt ); //----------------------------------------------------- //Dynamische Wasserentnahme und Abflussreduktion Parameters.Add_Choice( Parameters("WTHD_NODE") , "WCons" , _TL("Dynamische Flaechenwassernutzung..."), _TL("Auswahl der Art der dynamischen Flaechenwasserwassernutzung (WUse). ACHTUNG: Funktioniert ggf. nur bei bereits initiierten Systemen bzw. nach Vorlauf"), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("keine"), _TL("...anteilig aus den Hauptgerinnerasterzellen"), _TL("...anteilig aus Rasterzellen der Teileinzugegebiete"), _TL("...genau den entsprechenden Wert aus der jeweiligen Rasterzelle entnehmen") ), 0 ); Parameters.Add_FilePath( Parameters("WTHD_NODE") , "Folder3", _TL("Ordnerpfad der WUse Daten"), _TL("Speicherpfad der dynamischen Wassernutzungsdaten"), _TL("SAGA Grid Files (*.sgrd)|*.sgrd|All Files|*.*"),0 ,false ,true ,false ); Parameters.Add_Choice( Parameters("WTHD_NODE") , "WConUnit" , _TL("WUse Einheit"), _TL("Einheit in der die WUse Daten vorliegen"), CSG_String::Format(SG_T("%s|%s|"), _TL("m3/s"), _TL("m3/Monat") ), 0 ); Parameters.Add_Value( Parameters("WTHD_NODE"), "WConsD" , "Vorlauftage ohne Entnahmen", "Anzahl der Simulationestage bevor eine Wasserentnahme beruecksichtigt wird", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( Parameters("WTHD_NODE"), "WConThres", "Abflussschwellenwert [m3/s]", "Fester Abflussschwellenwert in m3/s fuer das Hauptgerinne, der durch Entnahmen nicht unterschritten werden soll.", PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Value( Parameters("WTHD_NODE"), "stConsAll", "Abflussreduzierungsfaktor Gerinnerasterzellen [% / 100]", "Statische Reduzierung des Gesamtabflusses in den Gerinnerasterzellen um [% / 100] pro Zeitschritt.", PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); Parameters.Add_Value( Parameters("WTHD_NODE"), "stConsRiv", "Abflussreduzierungsfaktor HG-Rasterzellen [% / 100]", "Statische Reduzierung des Gesamtabflusses in den Hauptgerinnegitterboxen um [% / 100] pro Zeitschritt.", PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); //----------------------------------------------------- //punktuelle Rasterzellenmanipulation //RM1 Parameters.Add_Choice( Parameters("RM1_NODE") , "vRM1" , _TL("Abflussmanipulation Rasterzelle 1... "), _TL("Der Gerinne- bzw. Hauptgerinneabfluss kann mit dieser Methode fuer Rasterzelle 1 manipuliert werden. "), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("nein"), _TL("Ja, berechneten Abfluss veraendern: res. Abfluss = berechn. Abfluss * q + a"), _TL("Ja, Abfluss manuell vorgeben: res. Abfluss = Speicherinhalt * q + a") ), 0 ); Parameters.Add_Value( Parameters("RM1_NODE"), "RM1x" , "Rasterzelle 1 [x-Koord.]", "x-Koordinate der Rasterzelle 1, fuer die der Abfluss manipulatiert werden soll", PARAMETER_TYPE_Int, -1, -1, true ); Parameters.Add_Value( Parameters("RM1_NODE"), "RM1y" , "Rasterzelle 1 [y-Koord.]", "y-Koordinate der Rasterzelle 1, fuer die der Abfluss manipulatiert werden soll", PARAMETER_TYPE_Int, -1, -1, true ); Parameters.Add_Value( Parameters("RM1_NODE"), "RM1q" , "q [%/100]", "Prozentualer Faktor q [%/100] fuer Rasterzelle 1", PARAMETER_TYPE_Double, 1, 0, true ); Parameters.Add_Value( Parameters("RM1_NODE"), "RM1a" , "a [+-m3/s]", "Addidativer Offsetwert a [+-m3/s] fuer Rasterzelle 1", PARAMETER_TYPE_Double, 0 ); //RM22 Parameters.Add_Choice( Parameters("RM2_NODE") , "vRM2" , _TL("Abflussmanipulation Rasterzelle 2... "), _TL("Der Gerinne- bzw. Hauptgerinneabfluss kann mit dieser Methode fuer Rasterzelle 2 manipuliert werden. "), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("nein"), _TL("Ja, berechneten Abfluss veraendern: res. Abfluss = berechn. Abfluss * q + a"), _TL("Ja, Abfluss manuell vorgeben: res. Abfluss = Speicherinhalt * q + a") ), 0 ); Parameters.Add_Value( Parameters("RM2_NODE"), "RM2x" , "Rasterzelle 2 [x-Koord.]", "x-Koordinate der Rasterzelle 2, fuer die der Abfluss manipulatiert werden soll", PARAMETER_TYPE_Int, -1, -1, true ); Parameters.Add_Value( Parameters("RM2_NODE"), "RM2y" , "Rasterzelle 2 [y-Koord.]", "y-Koordinate der Rasterzelle 2, fuer die der Abfluss manipulatiert werden soll", PARAMETER_TYPE_Int, -1, -1, true ); Parameters.Add_Value( Parameters("RM2_NODE"), "RM2q" , "q [%/100]", "Prozentualer Faktor q [%/100] fuer Rasterzelle 2", PARAMETER_TYPE_Double, 1, 0, true ); Parameters.Add_Value( Parameters("RM2_NODE"), "RM2a" , "a [+-m3/s]", "Addidativer Offsetwert a [+-m3/s] fuer Rasterzelle 2", PARAMETER_TYPE_Double, 0 ); //Test- und Monitoring-Routinen //EvP1 Parameters.Add_String( Parameters("EvP1_NODE") , "EvP1s" , _TL("EvP1 Name"), _TL("Name des Evaluierungspunktes 1"), SG_T("NeuDarchau.txt") ); Parameters.Add_Value( Parameters("EvP1_NODE"), "EvP1x" , "EvP1 Rasterzelle [x-Koord.]", "x-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 1", PARAMETER_TYPE_Int, 30, 0, true ); Parameters.Add_Value( Parameters("EvP1_NODE"), "EvP1y" , "EvP1 Rasterzelle [y-Koord.]", "y-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 1", PARAMETER_TYPE_Int, 115, 0, true ); //EvP2 Parameters.Add_String( Parameters("EvP2_NODE") , "EvP2s" , _TL("EvP2 Name"), _TL("Name des Evaluierungspunktes 2"), SG_T("Lutherstadt-Wittenberg.txt") ); Parameters.Add_Value( Parameters("EvP2_NODE"), "EvP2x" , "EvP2 Rasterzelle [x-Koord.]", "x-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 2", PARAMETER_TYPE_Int, 54, 0, true ); Parameters.Add_Value( Parameters("EvP2_NODE"), "EvP2y" , "EvP2 Rasterzelle [y-Koord.]", "y-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 2", PARAMETER_TYPE_Int, 85, 0, true ); //EvP3 Parameters.Add_String( Parameters("EvP3_NODE") , "EvP3s" , _TL("EvP3 Name"), _TL("Name des Evaluierungspunktes 3"), SG_T("Schoena.txt") ); Parameters.Add_Value( Parameters("EvP3_NODE"), "EvP3x" , "EvP3 Rasterzelle [x-Koord.]", "x-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 3", PARAMETER_TYPE_Int, 78, 0, true ); Parameters.Add_Value( Parameters("EvP3_NODE"), "EvP3y" , "EvP3 Rasterzelle [y-Koord.]", "y-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 3", PARAMETER_TYPE_Int, 65, 0, true ); //RBM Parameters.Add_Value( Parameters("RBM_NODE"), "RBMx" , "Ausgangsrasterzelle [x-Koord.]", "x-Koordinate der Ausgangsrasterzelle des Flusseinzugsgebietes", PARAMETER_TYPE_Int, 16, 0, true ); Parameters.Add_Value( Parameters("RBM_NODE"), "RBMy" , "Ausgangsrasterzelle [y-Koord.]", "y-Koordinate der Ausgangsrasterzelle des Flusseinzugsgebietes", PARAMETER_TYPE_Int, 121, 0, true ); Parameters.Add_Value( Parameters("MONI_NODE"), "wP" , "SimParameters", "Schreibt wichtige, der Simulation zugrundeliegenden Parameter in eine Textdatei", PARAMETER_TYPE_Bool, 1 ); Parameters.Add_Value( Parameters("MONI_NODE"), "eP" , "Fehlerprotokoll", "Schreibt Fehler in Textfile", PARAMETER_TYPE_Bool, 1 ); Parameters.Add_Value( Parameters("MONI_NODE"), "MoniLog1" , "RiverBasinDay-Monitoring", "Monitoring taegicher Werte des Flusseinzugsgebiets", PARAMETER_TYPE_Bool, 1 ); Parameters.Add_Value( Parameters("MONI_NODE"), "MoniLog3" , "RiverBasinMonth-Monitoring", "Monitoring monatlicher Werte des Flusseinzugsgebiets", PARAMETER_TYPE_Bool, 1 ); Parameters.Add_Value( Parameters("MONI_NODE"), "MoniLog2" , "WSystem-Monitoring", "Monitoring von Zu- und Abflusswerten des WasserGesamtsystems", PARAMETER_TYPE_Bool, 1 ); //Test1 Parameters.Add_Choice( Parameters("TEST1_NODE") , "Test1" , _TL("Testroutine1 durchfuehren... "), _TL("Waehlen ob TestRoutine 1 durchgefuehrt werden soll... 1) nur fuer Teileinzugsgebiet der HG-Rasterzelle oder 2) fuer das Flusseinzugsgebiet bis zum Erreichen der HG-Rasterzelle."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("nein"), _TL("Ja, TestRoutine1 nur fuer Teileinzugsgbiet der HG-Rasterzelle"), _TL("Ja, TestRoutine1 fuer Flusseinzugsgebiet bis zu der HG-Rasterzelle") ), 0 ); Parameters.Add_Value( Parameters("TEST1_NODE"), "xt1" , "Hauptgerinnerasterzelle [x-Koord.]", "x-Koordinate der spezifischen Hauptgerinnerasterzelle fuer TestRoutine 1", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( Parameters("TEST1_NODE"), "yt1" , "Hauptgerinnerasterzelle [y-Koord.]", "y-Koordinate der spezifischen Hauptgerinnerasterzelle fuer TestRoutine 1", PARAMETER_TYPE_Int, 0, 0, true ); //----------------------------------------------------- /* Parameters.Add_Value( Parameters("RIV_NODE"), "RFlow" , "Wasserflussvolumen [untere Grenze]", "Unterer Grenzwert des Wasserflussvolumens, ab dem eine Flussrasterzelle vorliegen soll [siehe Auswahl 'Flussrasterzellen beruecksichtigen'].", PARAMETER_TYPE_Double, 0, 0, true ); Parameters.Add_Value( Parameters("RIV_NODE"), "NumCells" , "ZuflussRasterzellen [untere Grenze]", "Unterer Grenzwert der Anzahl an ZuflussRasterzellen, ab der eine Flussrasterzelle vorliegen soll [siehe Auswahl 'Flussrasterzellen beruecksichtigen'].", PARAMETER_TYPE_Int, 0, 0, true );*/ //################################################################### } /////////////////////////////////////////////////////////// // // // Hauptfunktion // // // /////////////////////////////////////////////////////////// bool CLandFlow::On_Execute(void) { //----------------------------------------------------- //SAGA-Input m_pDTM = Parameters("INPUT")->asGrid(); m_pGrad = Parameters("INPUT2")->asGrid(); m_pWConsIn = Parameters("INPUT3")->asGrid(); //statisches WaterConsumption Grid in m3/s -> [kg m-2 s-1] m_pCCacheIn = Parameters("INPUT5")->asGrid(); m_pRCacheIn = Parameters("INPUT6")->asGrid(); m_pDCacheIn = Parameters("INPUT7")->asGrid(); m_pRivGrids = Parameters("INPUT8")->asGrid(); m_pRivGrad = Parameters("INPUT9")->asGrid(); m_pBasinShare = Parameters("INPUT10")->asGrid(); m_pRivBalanceGrid = Parameters("INPUT11")->asGrid(); m_pNumInFlow = Parameters("INPUT12")->asGrid(); m_pCCacheOut = Parameters("OUTPUT")->asGrid(); m_pRCacheOut = Parameters("OUTPUT2")->asGrid(); m_pDCacheOut = Parameters("OUTPUT3")->asGrid(); m_pChannelFlow = Parameters("OUTPUT4")->asGrid(); m_pSumRunoffDrainage = Parameters("OUTPUT5")->asGrid(); m_pWConsOut = Parameters("OUTPUT6")->asGrid(); //dynamisch imm Programmablauf generiertes WaterConsumption Grid in [kg m-2 s-1] m_pTStep = Parameters("TimeStep")->asInt(); // [s] m_sYear0 = Parameters("sYear")->asInt(); // [y] m_pDays = Parameters("DayNum")->asInt(); m_pLSDataFolder = Parameters("Folder1")->asString(); m_pDataSaveFolder = Parameters("Folder2")->asString(); m_pWConDataFolder = Parameters("Folder3")->asString(); m_pNCacheFolder = Parameters("Folder4")->asString(); m_pVTresh = Parameters("VTresh")->asDouble(); // [km/h] m_pWConsDIn = Parameters("WConsD")->asInt(); m_pWConThres = Parameters("WConThres")->asDouble(); //Schwellenwert fuer HG-Abfluss der auch bei Entnahmen nicht unterschritten werden soll m_pOffsetR = Parameters("OffsetR")->asDouble(); //Offsetwert auf den vertikalen Zufluss 'RunOff' pro Rasterzelle in m3/s m_pOffsetD = Parameters("OffsetD")->asDouble(); //Offsetwert auf den vertikalen Zufluss 'Drainage' pro Rasterzelle in m3/s m_pConsFacAll = (Parameters("stConsAll")->asDouble()); // Entnahmefaktor aus Gitterboxen [%]/[dt] m_pConsFacRiv = (Parameters("stConsRiv")->asDouble()); // Entnahmefaktor aus Fluss-Gitterboxen [%]/[dt] m_pRedFacR = (Parameters("stRedFacR")->asDouble()); // Reduzierungsfaktor des RunOff [%]/[dt] m_pRedFacD = (Parameters("stRedFacD")->asDouble()); // Reduzierungsfaktor der Drainage [%]/[dt] nC = Parameters("nG")->asInt(); //Anzahl der Speicherkaskaden des ChannelFlow Speichers nCr = Parameters("nHG")->asInt(); //Anzahl der Speicherkaskaden des ChannelFlow River-Speichers C0 = Parameters("ParamC")->asDouble(); C0r = Parameters("ParamCr")->asDouble(); // Parameter fuer ChannelFlow im River [optional] G0 = Parameters("ParamG")->asDouble(); pB = Parameters("ParamB")->asDouble(); var2 = Parameters("MoniLog1")->asBool(); var3 = Parameters("MoniLog2")->asBool(); var4 = Parameters("MoniLog3")->asBool(); m_pEvP1s = Parameters("EvP1s")->asString(); m_pEvP2s = Parameters("EvP2s")->asString(); m_pEvP3s = Parameters("EvP3s")->asString(); //----------------------------------------------------- //Setzen von statischen Programmvariablen [0]=off [1]=on var1 = 1; //Prozentuale Wasserentnahme zulassen //----------------------------------------------------- //----------------------------------------------------- //Simulationsstart: Startzeit und -datum erfassen time_t rawtime; struct tm * timeinfo; time (&rawtime); timeinfo = localtime (&rawtime); //----------------------------------------------------- //----------------------------------------------------- //SpeicherDateipfad (sfile) fuer diese Simulation wird generiert und entsprechender Ordner erstellt - Ordnerformat : ddmmyy_HHMM std::stringstream sPath0; sPath0.str(""); char buffer [20]; strftime(buffer,20,"%d%m%y_%H%M",timeinfo); sPath0 << m_pDataSaveFolder.b_str() << "\\" << buffer; //^Speicherdateipfad m_pSPath = sPath0.str(); //^ sPath0.str(""); sPath0 << m_pSPath << "\\Grids"; //^Unter-Speicherdateipfad1 m_pSPath2 = sPath0.str(); //^ sPath0.str(""); sPath0 << m_pSPath << "\\RivBalance"; //^Unter-Speicherdateipfad2 m_pSPath3 = sPath0.str(); //^ SG_Dir_Create(CSG_String(m_pSPath .c_str())); //SaveOrdner zum speichern der Simulationsdaten wird erstellt SG_Dir_Create(CSG_String(m_pSPath2.c_str())); //Unter-SaveOrdner1 zum speichern der Grid-Dateien wird erstellt SG_Dir_Create(CSG_String(m_pSPath3.c_str())); //Unter-SaveOrdner2 zum speichern der Grid-Dateien wird erstellt //----------------------------------------------------- //LoadPfad //----------------------------------------------------- //FileName-String std::stringstream file0; std::string file; //----------------------------------------------------- //Parameter m_sYear = m_sYear0; //Jahresvariable initiieren nG = 1; //Anzahl der Speicherkaskaden des GroundFlow Speichers - STATISCH NX = m_pDTM->Get_NX(); //Anzahl der Reihen x NY = m_pDTM->Get_NY(); //Anzahl der Zeilen y NumRBGrids = 0; //Anzahl der Rasterzellen im Flusseinzugsgebiet NumGrids = 0; //Anzahl der Rasterzellen im DTM (ohne NoDataZellen) errC = 0; //Fehlercode Variable errC2 = 0; //Fehlercode Variable2 errC3 = 0; //Fehlercode Variable3 errC4 = 0; //Fehlercode Variable4 m_pWConsD = m_pWConsDIn; // Operator fuer "verbleibende Tage bis Entnahme" wird auf Input-Wert gesetzt //###################################################### //Pruefroutinen //----------------------------------------------------- //STATISCHE SICHERHEITSANGABEN!! ueBERARBEITEN!!! if(m_sYear == 1989 && m_pDays > 7670) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1990 && m_pDays > 7305) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1991 && m_pDays > 6940) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1992 && m_pDays > 6575) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1993 && m_pDays > 6209) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1994 && m_pDays > 5844) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1995 && m_pDays > 5479) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1996 && m_pDays > 5114) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1997 && m_pDays > 4748) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1998 && m_pDays > 4383) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1999 && m_pDays > 4018) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2000 && m_pDays > 3653) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2001 && m_pDays > 3287) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2002 && m_pDays > 2922) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2003 && m_pDays > 2557) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2004 && m_pDays > 2192) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2005 && m_pDays > 1826) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2006 && m_pDays > 1461) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2007 && m_pDays > 1096) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2008 && m_pDays > 731) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2009 && m_pDays > 365) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); //###################################################### //Analyse------------------------------------------- for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if(!m_pDTM->is_NoData(x,y)) { NumGrids++; //Anzahl der Rasterzellen im DTM (ohne NoDatazellen) if(m_pBasinShare->asDouble(x,y) >= 0) NumRBGrids++; //Anzahl der Rasterzellen im Flusseinzugsgebiet } } } //-------------------------------------------------- //################################################################### //###################################################### //Ermittlung kMin, vMax // double zMax, zMax2; double k_Min0; //temporaerer Operator zur bestimmung von KMin und vMax int n0; //temporaerer Operator zur bestimmung von KMin und vMax //----------------------------------------------------- //nMax Wird benoetigt um Eintraege in NCArray-Array und -File zu setzten / zu lesen | Eigentlich sollte gelten nC >= nCr if(nC >= nCr) nMax = nC; else nMax = nCr; //----------------------------------------------------- zMax = m_pGrad->Get_ZMax(); //liefert maximale Steigung des DEM Grids ueber GradGrid //minimalsten Retetionskoeffizienten der jeweiligen Abflussarten bestimmen kMinG = G0/(nG*2) * (m_pDTM->Get_Cellsize() / 1000 ) / pow(zMax, 0.1 ); //anhand zMax Berechnung der kleinsten GroundFlow-Lagtime kMinC = C0/(nC*2) * (m_pDTM->Get_Cellsize() / 1000 ) / pow(zMax, 0.1 ); //anhand zMax Berechnung der kleinsten ChannelFlow-Lagtime kMinB = pB * (m_pDTM->Get_Cellsize() / 1000 ) / 50; //anhand zMax Berechnung der kleinsten BaseFlow-Lagtime //mittlere vMax der jeweiligen Abflussarten bestimmen (in einer Speicher Kaskade entspricht die Mittlere MAximalgeschwindigkeit der Summe der einzelnen Speicher-Maximalgeschwindigkeiten) vMaxC = m_pDTM->Get_Cellsize() / 1000 / kMinC / nC / 24; vMaxG = m_pDTM->Get_Cellsize() / 1000 / kMinG / nG / 24; // falls Flusssgrids beruecksichtigt werden... if( Parameters("RivG")->asInt() > 0 ) { if( m_pRivGrids && m_pRivGrad) { zMax2 = m_pRivGrad->Get_ZMax(); //liefert maximale Steigung der RiverGrids ueber RiverGradIn kMinCr = C0r/(nCr*2) * (m_pDTM->Get_Cellsize() / 1000 ) / pow(zMax2, 0.1 ); //anhand zMax2 Berechnung der kleinsten ChannelFlow River-Lagtime vMaxCr = m_pDTM->Get_Cellsize() / 1000 / kMinCr / nCr / 24; //----------------------------------------------------- //nMax Wird benoetigt um Eintraege in NCArray-Array und -File zu setzten / zu lesen | Eigentlich sollte gelten nC >= nCr if(nC >= nCr) nMax = nC; else nMax = nCr; //----------------------------------------------------- } else { Message_Dlg("Flussgrids koennen nicht beruecksichtigt werden, da kein RiverGrids und/oder RiverGrad-Input gesetzt wurde"); return (false); } } else //Wenn Flussgrids nicht extra veruecksichtigt werden { kMinCr = -1; vMaxCr = -1; } //vMax aller Abflussarten bestimmen if(vMaxCr >= vMaxC) vMax = vMaxCr; else vMax = vMaxC; if(vMaxG > vMax) vMax = vMaxG; //Wenn mittlere Geschwindigkeitsobergrenze gesetzt und diese kleiner als errechnete mittlere Maximalgeschwindigkeit vMax... if( Parameters("EnfVmax")->asBool()) //Retentionskoeffizienten nach "oben" anpassen um mittlere Geschwindigkeitsobergrenze einzuhalten { if( m_pVTresh < vMax) { //mittlere Geschwindigkeitsobergrenze wird (bisher) allgemein fuer alle Abflussarten gesetzt!! vMax = m_pVTresh; if( (m_pDTM->Get_Cellsize() / 1000 / vMax / nC / 24) > kMinC) kMinC = m_pDTM->Get_Cellsize() / 1000 / vMax / nC / 24; if( Parameters("RivG")->asInt() > 0 && (m_pDTM->Get_Cellsize() / 1000 / vMax / nCr / 24) > kMinCr ) kMinCr = m_pDTM->Get_Cellsize() / 1000 / vMax / nCr / 24; if( (m_pDTM->Get_Cellsize() / 1000 / vMax / nG / 24) > kMinG) kMinG = m_pDTM->Get_Cellsize() / 1000 / vMax / nG / 24; } else Message_Dlg("Eingabe der Geschwindigkeitsobergrenze ist groeszer als maximal berechnete Geschwindigkeit - Eingabe wird ignoriert"); } //Bestimmen des minimalsten Retentionskoeffizienten... if(kMinC < kMinG) k_Min0 = kMinC; else k_Min0 = kMinG; if(kMinCr >= 0 && kMinCr < k_Min0) k_Min0 = kMinCr; if(kMinB < k_Min0) //Sicherheitsabfrage { Message_Dlg("BaseFlow-Lagtime ist am geringsten - SEHR wahrscheinlicher Fehler!"); } //### entspricht kleinst moeglicher Zeitschrittlaenge! k_Min = k_Min0; //### if((k_Min*86400) <= 1) { Message_Dlg("FEHLER!! k_Min ist kleiner als eine Sekunde!!"); WriteLog("FEHLER!! k_Min war kleiner als eine Sekunde!!"); errC = 1; return (false); } //Setzen des Zeitschrittoperators m_pTStep : entspricht der Zeitschrittlaenge dt //WENN GESETZT - Automatisierte max. Zeitschrittlaengen-Festlegung: if( Parameters("CalcT")->asBool() ) m_pTStep = (int)(k_Min * 86400); //Problem: k_Min nicht zwanglaeufig ein vielfaches von 60, daher m_pTStep ggf. nicht glatt durch 86400 teilbar // WENN NICHT GESETZT : 1) Verwendung der m_pTStep Eingabe - falls nicht zu grosz: -> sonst m_pVTresh = k_Min else { if( m_pTStep >= k_Min * 86400) m_pTStep = (int)(k_Min * 86400); } // //###################################################### //###################################################### //Speicher, Arrays und Membervariablen initiieren // CreateKArray( NX, NY, 3); CreateNcArray( NX, NY, nMax+1); // Array mit nMax+1 Speicherwerten (n Speichereintraege + Eintrag ueber Summe der Speicher) //CreatePArray( NX, NY, 1); //zur Zeit: nicht gesetzt //----------------------------------------------------- //SpeicherArrays initieren // InitKArray(); InitNcArray(NX, NY, nMax+1); //Array mit nMax+1 Speicherwerten (n Speichereintraege + Eintrag ueber Summe der Speicher) //InitPArray(NX, NY, 1); //zur Zeit: nicht gesetzt /**///%%%% Monitoring %%%%%%%%%% /**///Initiierung /**/WSystem = 0; // Im System befindliches Wasser /**/WSystemInit = 0; // Anfaenglicher Speicherinhalt WSystem nach Speicherinitilisierung /**/WSystemIn = 0; // Summe des Wassers was ins System gelangt (Drainage, RunOff) /**/WSystemOut = 0; // Summe des Wassers welches das System verlaeszt (Systemabfluss) /**/WSystemDayIn = 0; // Summe des Wassers was am jeweiligen Tag ins System gelangt (Drainage, RunOff) /**/WSystemDayOut = 0; // Summe des Wassers welches am jeweiligenTag das System verlaeszt (Systemabfluss) /**/WSystemDayWithd = 0; // Summe allen Wassers, dass dem WSystem pro Tag entnommen wird oder ueber Entnahmefaktor verloren geht /**/RivBas = 0; // Im RivBasin befindliches Wasser /**/RivBasInit = 0; // Anfaenglicher Speicherinhalt RivBasin nach Speicherinitilisierung /**/RivBasIn = 0; // Summe des Wassers was ins RiverBasin gelangt (Drainage, RunOff) /**/RivOut = 0; // Summe des Wassers welches das RiverBasin ueber den Fluss verlaeszt (Flussabfluss) /**/RivBasDayIn = 0; // Summe des Wassers was am jeweiligen Tag ins RiverBasin gelangt (Drainage, RunOff) /**/RivDayOut = 0; // Summe des Wassers welches am je weiligenTag das RiverBasin ueber den Fluss verlaeszt (Flussabfluss) /**/RivMonthOut = 0; // Summe des Wassers welches im jeweiligen Monat das RiverBasin ueber den Fluss verlaeszt (Flussabfluss) /**/RivBasSink = 0; // Summe allen Wasser das ueber dem Rechenzeitraum im RivBas in Senken verschwindet (geloescht wird) /**/manWithd = 0; // Wasser das durch Rasterzellen Manipulation aus dem RivBasinSystem entfernt oder hinzugefuegt wurde /**/WCCache = 0; // Speicherabbild des Wassers in den Kaskaden Speichern /**/RivBasConMonth = 0; // Summe der auftretenden Flaechenentnahmen innerhalb des gesamten Flusseinzugsgebietes pro Monat /**/resRivBasConMonth = 0; // Summe der tatsaechlichen durchgefuehrten Flaechenentnahmen innerhalb des gesamten Flusseinzugsgebietes pro Monat /**/remRivBasConMonth = 0; // Summe der Entnahmen die dem RivBas nicht entnommen werden konnten (weil resFlow kleiner als m_pCon) pro Monat /**/RivBasDayWithd = 0; // Summe allen Wassers, dass dem RivBasin pro Tag entnommen wird oder ueber Entnahmefaktor verloren geht /**/SumRDMonth = 0; //Summe der Runoff und Drainage Werte des Einzugsgebietes eines Monats /**/SumRMonth = 0; //NUR Summe der Runoff-Werte des Einzugsgebietes eines Monats /**/SumDMonth = 0; //NUR Summe der Drainage-Werte des Einzugsgebietes eines Monats /**/m_pTestR1m = 0; //TestRoutine1 /**/m_pTestR1RDm = 0; //TestRoutine1 /**/m_pTestR1Cm = 0; //TestRoutine1 /**/m_pTestR1resCm = 0; //TestRoutine1 /**/m_pTestR1remCm = 0; //TestRoutine1 /**/SumRD_SubBasin = 0; //Summe der Runoff und Drainage Werte eines SubBasin [TestRoutine 1] /**/SumCon_SubBasin = 0; //Summe der beabsichtigten Entnahmen eines SubBasin [TestRoutine 1] /**/SumResCon_SubBasin = 0; //Summe der tatsaechlichen Entnahmen eines SubBasin [TestRoutine 1] /**/SumRemCon_SubBasin = 0; //Summe der nicht beruecksichtigten Entnahmen eines SubBasin [TestRoutine 1] /**///%%%%%%%%%%%%%% /**///MonitoringLogs initiieren (Legende) /**///Monitoringlog 1 - RivBasine /**/if(var2) /**/{ /**/ file0.str(""); /**/ file0 << "Tag RivBasDayIn RivDayOut RivBasIn RivOut RivBas DiffInOut RivBasSink RivBasDayWithd "; /**/ file = file0.str(); /**/ TestLog1( file ); /**/} /**///Monitoringlog 2 - WSystem /**/if(var3) /**/{ /**/ file0.str(""); /**/ file0 << "Tag WSystemDayIn WSystemDayOut WSystemIn WSystemOut WSystem DiffInOut WCCache WSystemDayWithd"; /**/ file = file0.str(); /**/ TestLog2( file ); /**/} /**///Monitoringlog 3 - RivBasWUse /**/if(var4) /**/{ /**/ file0.str(""); /**/ file0 << "Jahr Monat RivBasRDMonth RivMonthOut RivBasWUseMonth RivBasResWUseMonth RivBasRemWUseMonth RivBasRMonth RivBasDMonth"; /**/ file = file0.str(); /**/ TestLog3( file ); /**/} /**/ /**/if(Parameters("Test1")->asInt() > 0 && m_pRivGrids->asDouble(Parameters("xt1")->asInt(),Parameters("yt1")->asInt()) != 0 ) /**/{ /**/ file0.str(""); /**/ file0 << "Jahr Monat SubRivBasRDMonth SubRivBasOutMonth SubRivBasWUseMonth SubRivBasResWUseMonth SubRivBasRemWUseMonth"; /**/ file = file0.str(); /**/ TestLog4( file ); /**/} /**///%%%%%%%%%%%%%%%%%%%%%%%%%% //----------------------------------------------------- //Temporaere Speicher anlegen m_pTempR = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); m_pTempC = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); m_pTempD = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); m_pTempK = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); // Temporaerer Speicher um je Zeitschritt dt_n den Channelzufluss je Gitterbox zu speichern und zu Anfang von dt_n+1 in den Kaskadenpeicher nCArray[x][y][0] zu schreiben m_pTemp = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); // Temporaerer Zwischenspeicher m_pSumCon = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); m_pSumRemCon = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); m_pSumResCon = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); //TestRoutine1 if(Parameters("Test1")->asInt() == 2) m_pTestR1Share = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); //gesammtes Einzugsgebiet zu HG-Rasterzelle (x,y) der TestR1 Routine //----------------------------------------------------- m_pChannelFlow->Assign(0.0); //erste Initiierung des ChannelFlow Grids m_pSumRunoffDrainage->Assign(0.0); //erste Initiierung des m_pSumRunoffDrainage Grids m_pWConsOut->Assign(0.0); //erste Initiierung des dynamischen m_pWConsOut Grids m_pTempK->Assign(0.0); //erste Initiierung m_pSumCon->Assign(0.0); //erste Initiierung m_pSumRemCon->Assign(0.0); //erste Initiierung m_pSumResCon->Assign(0.0); //erste Initiierung //TestRoutine1 if(Parameters("Test1")->asInt() == 2) { m_pTestR1Share->Assign(-1.0); //erste Initiierung TestR1Share( Parameters("xt1")->asInt(), Parameters("yt1")->asInt() ); //EinzugsgebietsRasterzellen BIS Errreichen der HG-Rasterzelle aus TestRoutine1 bestimmen } //------------ m_pHFlowFac = 1.0; //Initiierung: Weiterleitungsfaktor des Wasserflusses aus einer Gitzterbox m_pRFlowFac = 1.0; //Initiierung: Weiterleitungsfaktor des Wasserflusses aus einer Fluss-Gitterbox m_pVRFlowFac = 1.0; //Initiierung: Zuflussfaktor des vertikalen Zuflusses RunOff m_pVDFlowFac = 1.0; //Initiierung: Zuflussfaktor der vertikalen Zuflsses Drainage m_pTestR1 = 0; //Initiierung: SpeicherVariable TestRoutine 1 //----------------------------------------------------- //Ggf. Input-Grid-Speicherwerte einlesen // if( Parameters("CacheUse")->asBool() && m_pRCacheIn && m_pDCacheIn && m_pCCacheIn && !m_pNCacheFolder.is_Empty()) { //----------------------------------------------------- //Initialisierung der temporaeren Speicher mit voherigen Soeicherwerten m_pTempR->Assign(m_pRCacheIn); //Initiierung des temporaeren RunOff-Speichers mit vorhandenen Werten m_pTempD->Assign(m_pDCacheIn); //Initiierung des temporaeren Drainage-Speichers mit vorhandenen Werten m_pCCacheOut->Assign(m_pCCacheIn); //Initiierung des ChannelFlow-Grids mit vorhandenen Werten //RivBas / WSystem Monitoring: Inhalt des RivBas und Wsystem aus Speichern einlesen /**///%%%% Monitoring %%%%%%%%%% /**/ /**/for(int x=0; x < NX; x++) /**/{ /**/ for(int y=0; y < NY; y++) /**/ { /**/ WSystem = WSystem + m_pTempR->asDouble(x,x) + m_pTempD->asDouble(x,y) + m_pCCacheOut->asDouble(x,y); /**/ /**/ if(m_pBasinShare->asDouble(x,y) >= 0 ) //wenn im RivBasin... /**/ RivBas = RivBas + m_pTempR->asDouble(x,x) + m_pTempD->asDouble(x,y) + m_pCCacheOut->asDouble(x,y); /**/ } /**/} /**/RivBasInit = RivBas; /**/WSystemInit = WSystem; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ReadNCacheFile(false, "NcCacheIn.txt", NX, NY, 0, 0, nMax, ' ', 0, false); //nC-Speicherdatei in Array einlesen //----------------------------------------------------- } else { m_pTempR->Assign(0.0); m_pTempD->Assign(0.0); m_pCCacheOut->Assign(0.0); //erste Initiierung des ChannelCache Grids } //----------------------------------------------------- //Zeit Membervariablen initiieren [Funktioniert bisher nur fuer 1968-2009] // //Simulationsuhr auf 1. Januar Startjahr 00:00:00 gesetzt // CTime timeS(m_sYear0, 1, 1, 0, 0, 0); CSG_DateTime timeS(1, CSG_DateTime::Jan, m_sYear0, 0, 0, 0); dT = 0; //daytimeCounter - Tageszeitzaehler [s] (0-86400) dDC = 1; //dayDataCounter - Datentag-Zaehler [d] (1-365/366) dC = 1; //dayCounter - Tageszaehler [d] mYC = 1; //MonthOfYear Monatszaehler [m] (1-12) dMC = 1; //DayOfMonth Tageszaehler [d] (1-28/29/30/31) //UhrzeitTest-Platzhalter double Td = 0; double Tm = 0; double Ty = 0; double Th = 0; double Tmi = 0; //----------------------- //Schaltjahr-Bestimmung - statisch fuer Zeitraum 1980 - 2009 m_pDDays = CSG_DateTime::Get_NumberOfDays(m_sYear); // if(m_sYear == 1968 || m_sYear == 1972 || m_sYear == 1976 || m_sYear == 1980 || m_sYear == 1984 || m_sYear == 1988 || m_sYear == 1992 || m_sYear == 1996 || m_sYear == 2000 || m_sYear == 2004 || m_sYear == 2008 ) // m_pDDays = 366; // else // m_pDDays = 365; numTS = int(86400/m_pTStep); //Anzahl der Zeitschtritte pro Tag //----------------------------------------------------- //Auslesepunkte - Tagesspeicher //STATISCH double dV1 = 0; double dV2 = 0; double dV3 = 0; // //###################################################### //###################################################### //Ggf. Prozentuale Wasserentnahme initiieren //----------------------------------------------------- //Falls der Inputparameter Wasserentnahmefaktor != Null, berechnen des effektiven Wasserdurchflussfaktors m_pFlowFac // if(var1 && m_pConsFacAll != 0) { /*double pow1 = 1.0 - m_pConsFacAll; double pow2 = 1.0 / numTS; if(m_pConsFac!=0 && m_pConsFac <= 1) m_pFlowFac = pow( pow1, pow2); //ZinsesZins-Rechnung */ m_pHFlowFac = 1.0 - m_pConsFacAll; } if(var1 && m_pConsFacRiv != 0) m_pRFlowFac = 1.0 - m_pConsFacRiv; if(var1 && m_pRedFacR != 0) m_pVRFlowFac = 1.0 - m_pRedFacR; if(var1 && m_pRedFacD != 0) m_pVDFlowFac = 1.0 - m_pRedFacD; // //###################################################### //###################################################### // Hauptfunktionsschleife //###################################################### // //LS-Data Grids initiieren und einlesen fuer Tag 1 //----------------------------------------------------- CSG_String m_pLSData26File; CSG_String m_pLSData27File; m_pLSData26File.Printf(SG_T("%s/%d/srunoff_%d_%d.sgrd"), m_pLSDataFolder.w_str(), m_sYear, m_sYear, dDC); m_pLSData27File.Printf(SG_T("%s/%d/drainage_%d_%d.sgrd"), m_pLSDataFolder.w_str(), m_sYear, m_sYear, dDC); CSG_Grid pRunOff(m_pLSData26File); CSG_Grid pDrainage(m_pLSData27File); //----------------------------------------------------- //Dynamische WCons-Data Grids initiieren und einlesen fuer Tag 1 //----------------------------------------------------- if(Parameters("WCons")->asInt() > 0) { m_pWConsFile.Printf(SG_T("%s/TotalWUse_%d_%d.sgrd"), m_pWConDataFolder.w_str(), m_sYear, mYC); pWConsData.Create(m_pWConsFile); //Entnahmen berechnen fuer Monat 1 if( !WConsRiv( Parameters("WCons")->asInt() )) Message_Dlg("Fehler beim Berechnen der dynamischen Entnahmen!"); } //----------------------------------------------------- //###################################################### // while(dC <= m_pDays ) // ...so lange Tageszahl kleiner gleich der festgelegten Simulationstage. { m_pTempC->Assign(0.0); //temporaerer Speicher zum Berechnen von m_pCCacheOut (Gueltigkeit fuer einen Zeitschritt) m_pTemp->Assign(0.0); //temporaerer Speicher zum Speichern des Zuflusses pro Gitterbox (Gueltigkeit fuer einen Zeitschritt) //###################################################### for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if(Parameters("onlyRB")->asBool() && m_pBasinShare->asDouble(x,y) < 0) //Falls nur im RiverBasin gerechnet werden soll und Koordinaten (x,y) nicht in diesem liegt -> Koordinaten ueberspringen... {} else { if(m_pDTM->is_NoData(x,y)) { m_pCCacheOut->Set_NoData(x,y); } else { /**///TEST---- /**/double test1 = pRunOff.asDouble(x,y); /**///-------- //Tageswerte fuer RunOff und Drainage aus Array einlesen und auf Flaeche und Zeitschritt umrechnen //Entsprechende Reduktionen und Offsets beruecksichtigen bzw. ausgleichen. //----------------------------------------------------- m_pRun = ( ( pRunOff.asDouble(x,y) * m_pVRFlowFac * pow(m_pDTM->Get_Cellsize(), 2) ) + m_pOffsetR ) * m_pTStep; // Vertikaler Runoff pro Zellenflaeche (x,y): [m^3] pro Zeitschrittlaenge (Input = m/s) multipliziert mit dem Zuflussfaktor m_pVFlowFac (Moeglichkeit der prozentuelle Reduzierung des Runoff-Zuflusses) + OFFSET //Reduzierungsbetrag RunOff double redSumRunOff = pRunOff.asDouble(x,y) * m_pRedFacR; if(Parameters("autoFacD")->asBool()) m_pDrain = ( ( pDrainage.asDouble(x,y) + redSumRunOff ) * pow(m_pDTM->Get_Cellsize(), 2) ) * m_pTStep; // Vertikale Drainage pro Zellenflaeche (x,y): [m^3] pro Zeitschrittlaenge (Input = m/s) + Reduzierungsbetrag des RunOffs else m_pDrain = ( ( pDrainage.asDouble(x,y) * m_pVDFlowFac * pow(m_pDTM->Get_Cellsize(), 2) ) + m_pOffsetD ) * m_pTStep; // Vertikale Drainage pro Zellenflaeche (x,y): [m^3] pro Zeitschrittlaenge (Input = m/s) multipliziert mit dem Zuflussfaktor m_pVFlowFac (Moeglichkeit der prozentuelle Reduzierung des Drainage-Zuflusses) + OFFSET //----------------------------------------------------- //HAUPTFUNKTION-> //###################### Calc_MainFlow(x,y); //###################### //HAUPTFUNKTION-> /**///%%%% Monitoring %%%%%%%%%% /**///WCCache Werte Schreiben /**/WCCache = WCCache + nCArray[x][y][nMax]; //%%%%%%%%%%%%%%%%%%%%%%%%%% } } } } m_pCCacheOut->Assign(m_pTempC); //uebernahme des Flussinhaltes (Gerinne- und Hauptgerinnnerasterzellen) nach einem Zeitschritt dt m_pTempK->Assign(m_pTemp); //Speichern des Gitterboxzuflusses (== Zufluss in Speicherkaskade N) dieses Zeitschritts zur Verwendung im nae Zeitschritt DataObject_Update(m_pCCacheOut); DataObject_Update(m_pChannelFlow); Process_Set_Text(CSG_String::Format(SG_T("dt = %d Dt = %g Vmax = %g || Tag: %d"), m_pTStep, dT+m_pTStep, vMax, dC)); //###################################################### //----------------------------------------------------- //Zeitoperation -> naechster Zeitschritt // dT = dT + m_pTStep; //Tageszeitzaehler // timeS.operator+=(m_pTStep); //SimulationsUhr timeS += CSG_TimeSpan(0, 0, m_pTStep); //SimulationsUhr //----------------------------------------------------- //Test--------------------- Td = timeS.Get_Day(); if(Th != timeS.Get_Hour()) Th = timeS.Get_Hour(); if(Tmi != timeS.Get_Minute()) Tmi = timeS.Get_Minute(); if(Tm != timeS.Get_Month()) Tm = timeS.Get_Month(); if(Ty != timeS.Get_Year()) Ty = timeS.Get_Year(); if(timeS.Get_Day() != dMC) //------------------------- //----------------------------------------------------- //TAGESWECHSEL ////if(dT > 86400) { /**///%%%% Monitoring %%%%%%%%%% /**///WSystem Werte Schreiben /**/if(var3) /**/{ /**/ file0; /**/ file0.str(""); /**/ file0 << dC << " " << WSystemDayIn << " " << WSystemDayOut << " " << WSystemIn << " " << WSystemOut << " " << WSystem << " " << (WSystemIn-WSystemOut) << " " << WCCache << " " << WSystemDayWithd; /**/ file = file0.str(); /**/ TestLog2( file ); /**/} /**/ /**///RivBasin Werte schreiben /**/if(var2) /**/{ /**/ file0.str(""); /**/ file0 << dC << " " << RivBasDayIn << " " << RivDayOut << " " << RivBasIn << " " << RivOut << " " << RivBas << " " << (RivBasIn - RivOut) << " " << RivBasSink << " " << RivBasDayWithd; /**/ file = file0.str(); /**/ /**/ TestLog1( file ); /**/} /**/ /**/WSystemDayOut = 0; //Auf Null setzen um naechsten Tageswert erfaassen zu koennen /**/WSystemDayIn = 0; //Auf Null setzen um naechsten Tageswert erfaassen zu koennen /**/WSystemDayWithd = 0;//Auf Null setzen um naechsten Tageswert erfaassen zu koennen /**/RivBasDayIn = 0; //Auf Null setzen um naechsten Tageswert erfaassen zu koennen /**/RivDayOut = 0; //Auf Null setzen um naechsten Tageswert erfaassen zu koennen /**/RivBasDayWithd = 0; //Auf Null setzen um naechsten Tageswert erfaassen zu koennen //%%%%%%%%%%%%%%%%%%%%%%%%%% //----------------------------------------------------- //AUSLESEN // //Fixe Messstationen (Auslesekoordinaten) - Tagesmittel in [m3/s] berechnen, Werte speichern //Schreiben in Textdatei // /*ELBE1 dV1 = m_pChannelFlow->asDouble(155,698) / 86400; // [m3/s]*/ /*ELBE2 dV1 = m_pChannelFlow->asDouble(145,578) / 86400; // [m3/s]*/ /*ELBE2_5 dV1 = m_pChannelFlow->asDouble(30,115) / 86400; // [m3/s]*/ dV1 = m_pChannelFlow->asDouble(Parameters("EvP1x")->asInt(),Parameters("EvP1y")->asInt()) / 86400; WriteOutput(m_pEvP1s.b_str(), dDC, dV1, -1, -1); dV1 =0; /*Nile dV1 = m_pChannelFlow->asDouble(222,563) / 86400; // [m3/s] WriteOutput("Dongola.txt",dDC, dV1, -1, -1); dV1 =0;*/ /*ELBE1 dV2 = m_pChannelFlow->asDouble(278,547) / 86400; // [m3/s]*/ /*ELBE2 dV2 = m_pChannelFlow->asDouble(269,428) / 86400; // [m3/s]*/ /*ELBE2_5 dV2 = m_pChannelFlow->asDouble(54,85) / 86400; // [m3/s]*/ dV2 = m_pChannelFlow->asDouble(Parameters("EvP2x")->asInt(),Parameters("EvP2y")->asInt()) / 86400; WriteOutput(m_pEvP2s.b_str(), dDC, dV2, -1, -1); dV2 =0; /*Nile dV2 = m_pChannelFlow->asDouble(280,487) / 86400; // [m3/s] WriteOutput("Khartoum.txt",dDC, dV2, -1, -1); dV2 =0;*/ /*ELBE1 dV3 = m_pChannelFlow->asDouble(399,434) / 86400; // [m3/s]*/ /*ELBE2 dV3 = m_pChannelFlow->asDouble(388,327) / 86400; // [m3/s]*/ /*ELBE2_5 dV3 = m_pChannelFlow->asDouble(78,65) / 86400; // [m3/s]*/ dV3 = m_pChannelFlow->asDouble(Parameters("EvP3x")->asInt(),Parameters("EvP3y")->asInt()) / 86400; WriteOutput(m_pEvP3s.b_str(), dDC, dV3, -1, -1); dV3 =0; /*Nile dV3 = m_pChannelFlow->asDouble(272,342) / 86400; // [m3/s] WriteOutput("Malakal.txt",dDC, dV3, -1, -1); dV3 =0;*/ //----------------------------------------------------- //----------------------------------------------------- //Datei der FlussWasserBilanz pro Kilometer des letzten Simulationstages schreiben if(m_pRivBalanceGrid) { WriteRivBalance(m_sYear, dC, -1, -1); int rx, ry; for(int l=0; l < m_pDTM->Get_NCells() && Set_Progress_NCells(l); l++) //ueber alle Zellen des m_pDEM-Grids { m_pDTM->Get_Sorted(l, rx, ry); //sortieren der Zellen von hoechster (l=0) nach niedrigster... if( m_pRivBalanceGrid->asDouble(rx,ry) != 0) { WriteRivBalance(rx, ry, m_pRivBalanceGrid->asDouble(rx,ry), m_pChannelFlow->asDouble(rx,ry) / 86400 ); } } } //----------------------------------------------------- dMC++; dDC++; dC++; dT = 0; WCCache = 0; //WCCACHE immer NCache-SpeicherAbbild am Ende jedes Simulationstages - daher nach jedem Tageswechsel wieder auf Null setzten if(m_pWConsD > 0) //Tageszaehler "Vorlauf vor Wasserentnahme" minus einen Tag m_pWConsD--; //----------------------------------------------------- //MONATSWECHSEL // if(timeS.Get_Month() != mYC) { /**///%%%% Monitoring %%%%%%%%%% /**///monthRivBasCon Werte schreiben /**/if(var4) /**/{ /**/ file0.str(""); /**/ file0 << m_sYear << " " << mYC << " " << SumRDMonth << " " << RivMonthOut << " " << RivBasConMonth << " " << resRivBasConMonth << " " << remRivBasConMonth << " " << SumRMonth << " " << SumDMonth; /**/ file = file0.str(); /**/ /**/ TestLog3( file ); /**/} /**/ /**/RivBasConMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/RivMonthOut = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/resRivBasConMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/remRivBasConMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/SumRDMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/SumRMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/SumDMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen //%%%%%%%%%%%%%%%%%%%%%%%%%% if(Parameters("Test1")->asInt() > 0 && m_pRivGrids->asDouble(Parameters("xt1")->asInt(),Parameters("yt1")->asInt()) != 0 ) { /**/SubBasinId(Parameters("xt1")->asInt(), Parameters("yt1")->asInt()); /**/ /**/ file0.str(""); /**/ file0 << m_sYear << " " << mYC << " " << m_pTestR1RDm << " " << m_pTestR1m << " " << m_pTestR1Cm << " " << m_pTestR1resCm << " " << m_pTestR1remCm; /**/ file = file0.str(); /**/ TestLog4( file ); /**/ /**/ m_pTestR1m = 0; /**/ m_pTestR1RDm = 0; /**/ m_pTestR1Cm = 0; /**/ m_pTestR1resCm = 0; /**/ m_pTestR1remCm = 0; } if(mYC >= 12) mYC = 1; else mYC++; dMC = 1; //auf ersten Tag des Monats setzen //Dynamische WCons-Data Grids fuer neuen Monat berechnen //----------------------------------------------------- if(Parameters("WCons")->asInt() > 0) { int Year; if(m_sYear <= 2000) //Sicherheitsabfrage fuer WaterGapDaten, die nur bis 2000 vorliegen - falls Jahr groeszer als 2000, werden weiterhin 2000er Daten verwendet Year = m_sYear; else Year = 2000; m_pWConsFile.Printf(SG_T("%s/TotalWUse_%d_%d.sgrd"), m_pWConDataFolder.w_str(), Year, mYC); pWConsData.Create(m_pWConsFile); if( !WConsRiv( Parameters("WCons")->asInt() )) Message_Dlg("Fehler beim Berechnen der dynamischen Entnahmen!"); } //----------------------------------------------------- } //----------------------------------------------------- //----------------------------------------------------- //JAHRESWECHSEL // if(timeS.Get_Year() > m_sYear) //if(dDC > m_pDDays) { dDC = 1; m_sYear = m_sYear + 1; mYC = 1; m_pDDays = timeS.Get_NumberOfDays(m_sYear); // if(m_sYear == 1980 || m_sYear == 1984 || m_sYear == 1988 || m_sYear == 1992 || m_sYear == 1996 || m_sYear == 2000 || m_sYear == 2004 || m_sYear == 2008 ) // m_pDDays = 366; // else // m_pDDays = 365; } if(m_sYear > 2009 || dDC > 366) //STATISCHE SICHERHEITSANGABEN break; if(dC <= m_pDays) { //Aktuelle LS-Data Grids einlesen //----------------------------------------------------- m_pLSData26File.Printf(SG_T("%s/%d/srunoff_%d_%d.sgrd"), m_pLSDataFolder.w_str(), m_sYear, m_sYear, dDC); m_pLSData27File.Printf(SG_T("%s/%d/drainage_%d_%d.sgrd"), m_pLSDataFolder.w_str(), m_sYear, m_sYear, dDC); pRunOff.Create(m_pLSData26File); pDrainage.Create(m_pLSData27File); //----------------------------------------------------- m_pChannelFlow->Assign(0.0); m_pTest = 0; } //----------------------------------------------------- } //----------------------------------------------------- } // //###################################################### // //###################################################### //----------------------------------------------------- // Testroutine 1 durchfuehren if(Parameters("Test1")->asInt() > 0 && m_pRivGrids->asDouble(Parameters("xt1")->asInt(),Parameters("yt1")->asInt()) != 0 ) { SubBasinId(Parameters("xt1")->asInt(), Parameters("yt1")->asInt()); } //----------------------------------------------------- //----------------------------------------------------- // Speichern in den Ausgabedateien m_pRCacheOut->Assign(m_pTempR); //uebernahme des Gitterboxflusses nach m_pDays Simulationstagen m_pDCacheOut->Assign(m_pTempD); //uebernahme des Gitterboxflusses nach m_pDays Simulationstagen if(Parameters("wNC")->asBool()) SaveNcCache(nMax); if(Parameters("wP")->asBool()) SaveParameters(); //Speichern der AusgabeGrids in Unterordner "grids" CSG_String SaveAsFile; CSG_String SPath = m_pSPath2.c_str(); SaveAsFile.Printf(SG_T("%s/CFCache.sgrd"), SPath.w_str()); m_pCCacheOut->Save(SaveAsFile); //GridSave CCCache SaveAsFile.Printf(SG_T("%s/OFCache.sgrd"), SPath.w_str()); m_pRCacheOut->Save(SaveAsFile); //GridSave RCache SaveAsFile.Printf(SG_T("%s/BFCache.sgrd"), SPath.w_str()); m_pDCacheOut->Save(SaveAsFile); //GridSave DCache SaveAsFile.Printf(SG_T("%s/SumRunoffDrainage.sgrd"), SPath.w_str()); m_pSumRunoffDrainage->Save(SaveAsFile); //GridSave SumRunoffDrainage SaveAsFile.Printf(SG_T("%s/ChannelFlow.sgrd"), SPath.w_str()); m_pChannelFlow->Save(SaveAsFile); //GridSave ChannelFlow //----------------------------------------------------- if(Parameters("Test1")->asInt() == 2) { SaveAsFile.Printf(SG_T("%s/m_pTestR1Share.sgrd"), SPath.w_str()); m_pTestR1Share->Save(SaveAsFile); //GridSave ChannelFlow delete(m_pTestR1Share); } //----------------------------------------------------- // Loeschen der temporaeren Speicher // delete(m_pTempR); delete(m_pTempC); delete(m_pTempD); delete(m_pTempK); delete(m_pTemp); delete(m_pSumCon); delete(m_pSumRemCon); delete(m_pSumResCon); CLandFlow::DeleteKArray(); //CLandFlow::DeleteLSMArray(); //ersetzt durch direktes Laden der LSSchmea-Grids CLandFlow::DeleteNcArray(); //CLandFlow::DeletePArray(); // zur Zeit : nicht verwendet //----------------------------------------------------- return( true ); } //######################################################### //--------------------------------------------------------- //######################################################### /////////////////////////////////////////////////////////// // // // Funktionen // // // /////////////////////////////////////////////////////////// //###################################################### // void CLandFlow::Calc_MainFlow(int x, int y) { int i = -1; int ix, iy; double c, r, d; stCons = 0; varCons = 0; r = m_pTempR->asDouble(x,y) + m_pRun; // Einlesen des Inhalts des Runoff-Speichers + Runoff m_pRun des Zeitschritts d = m_pTempD->asDouble(x,y) + m_pDrain; // Einlesen des Inhalts des Drainage-Speichers + Drainage m_pDrain des Zeitschritts c = m_pTempK->asDouble(x,y); // Einlesens des Inhalts des Gitterboxzuflusses des letzten Zeitschritts /**///%%%% Monitoring %%%%%%%%%% /**/WSystemIn = WSystemIn + m_pRun + m_pDrain; /**/WSystem = WSystem + m_pRun + m_pDrain; /**/ /**/WSystemDayIn = WSystemDayIn + m_pRun + m_pDrain; /**/ /**/m_pSumRunoffDrainage->Add_Value(x, y, (m_pRun + m_pDrain)); //Grid ueber die Summe aller abflussrelevanten, vertikalen Zufluesse je Gitterzelle (x,y) des gesamten Berechnugszeitraums /**/ /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Abfrage ob (x,y) Koordinate im RiverBasin liegt /**/{ /**/ RivBasIn = RivBasIn + m_pRun + m_pDrain; /**/ RivBas = RivBas + m_pRun + m_pDrain; /**/ /**/ RivBasDayIn = RivBasDayIn + m_pRun + m_pDrain; //Summe der RunOff und DrainagWerte innerhalb des Flusseinzugsgebietes ueber einen Monat /**/ SumRDMonth = SumRDMonth + m_pRun + m_pDrain; /**/ SumRMonth = SumRMonth + m_pRun; /**/ SumDMonth = SumDMonth + m_pDrain; /**/} /**///%%%%%%%%%%%%%%%%%%%%%%%%%% /**///%%%%%%%%%%%%%%%%%%%%%%%%%% //--------------------------------------------------------- //Berechnung der Abfluesse m_pGFlow = Calc_GFlow(x, y, r); // Berechnung Oberflaechenabflusses m_pBFlow = Calc_BFlow(x,y,d); // Berechnung Grundwasserabfluss if( Parameters("RivG")->asInt() > 0 && m_pRivGrids->asDouble(x,y) != 0) m_pCFlow = Calc_CFlow(x, y, c, nCr); // Berechnung Hauptgerinnerasterzellen-Abfluss-Speicherkaskade else m_pCFlow = Calc_CFlow(x, y, c, nC); // Berechnung Gerinneabfluss-Speicherkaskade //--------------------------------------------------------- /**///%%%%%%%%%%%%%%%%%%%%%%%%%% /**///TempSpeicherwert /**/double tempN = m_pCFlow; /**/ /**///TempSpeicherwerte //%%%%%%%%%%%%%%%%%%%%%%%%%% Punktuelle Abflussmanipulation - Anfang %%%%%%%%%%%%%%%%%%%%%%%%%% //Rasterzelle 1 if( x == Parameters("RM1x")->asInt() && y == Parameters("RM1y")->asInt() && Parameters("vRM1")->asInt() != 0) if(Parameters("vRM1")->asInt() == 1) m_pCFlow = ( m_pCFlow * Parameters("RM1q")->asDouble() ) + (Parameters("RM1a")->asDouble() * m_pTStep); //Abfluss des HD-Modells veraendern else m_pCFlow = ( m_pCCacheOut->asDouble(x,y) * Parameters("RM1q")->asDouble() ) + (Parameters("RM1a")->asDouble() * m_pTStep); //Abfluss aus Speicher manuell vorgeben //Rasterzelle 2 if( x == Parameters("RM2x")->asInt() && y == Parameters("RM2y")->asInt() && Parameters("vRM2")->asInt() != 0) if(Parameters("vRM2")->asInt() == 1) m_pCFlow = ( m_pCFlow * Parameters("RM2q")->asDouble() ) + (Parameters("RM2a")->asDouble() * m_pTStep); //Abfluss des HD-Modells veraendern else m_pCFlow = ( m_pCCacheOut->asDouble(x,y) * Parameters("RM2q")->asDouble() ) + (Parameters("RM2a")->asDouble() * m_pTStep); //Abfluss aus Speicher manuell vorgeben if(m_pCFlow < 0) { Message_Dlg("Negativer Abfluss errechnet -> Punktuelle Rasterzellenmanipulation in diesem Schritt auszer Kraft gesetzt"); m_pCFlow = tempN; } else //Monitoring der Manipulierten Wasserflussvolumen (pos. Wert == Wasser hinzugefuegt) manWithd = manWithd + m_pCFlow - tempN; //%%%%%%%%%%%%%%%%%%%%%%%%%% Punktuelle Abflussmanipulation - Ende %%%%%%%%%%%%%%%%%%%%%%%%%% //--------------------------------------------------------- //Abfluesse aus den Speichern der Rasterzelle (x,y) m_pTempR->Set_Value( x, y, (r - m_pGFlow) ); // Inhalt Runoff-Speicher der in Zelle (x,y) verbleibt m_pTempD->Set_Value( x, y, (d - m_pBFlow ) ); // Inhalt Drainage-Speicher der in Zelle (x,y) verbleibt m_pTempC->Add_Value( x, y, (m_pCCacheOut->asDouble(x,y) - m_pCFlow) ); //Add_ist_richtig!! Alter Inhalt des ChannelGitterbox-Speichers minus Abfluss dieses Zeitschritts, gleich: verbleibender Inhalt in der Zelle (x,y) - (Grid: m_pCCacheOut == Summe des Volumens aller n Kaskadenspeicher) (Achtung! aus anderen Zellen kann aber immer auch nocht etwas in m_pTempC zuflieszen) //--------------------------------------------------------- //%%%%%%%%%%%%%%%%%%%%%%%%%% EntnahmenCode - Anfang %%%%%%%%%%%%%%%%%%%%%%%%%% //...aus dem Gesamtabfluss (m_pGFlow + m_pBFlow + m_pCFlow) der rasterzelle (x,y) //--------------------------------------------------------- //Wasserentnahme - flaechenbasiert ueber das Flussgrid // //Wenn bei gesetzter Wasserentnahme kein WCons-Grid vorhanden -> Fehlermeldung if(Parameters("WCons")->asInt() > 0 && !pWConsData.is_Valid()) { WriteLog("Fehler! Kein WConsDaten als Input!"); errC = 1; } m_pCon = 0; //Entnahme statisch (WConsIn) und/oder dynamisch nach Auswahl 1 oder 2 (WConsData) if( m_pWConsIn && m_pWConsD == 0 ) m_pCon = (m_pWConsIn->asDouble(x,y) / 1000 ) * pow(m_pDTM->Get_Cellsize(), 2) * m_pTStep; //Statische Wasserentnahme Eingangsdaten in m3/s -> [0,001m^3 m^-2 s^-1 == 1 mm s^-1] * (Zellgroesze)^2 * Zeitschritt(s) if( Parameters("WCons")->asInt() != 0 && pWConsData.is_Valid() && m_pWConsOut->is_Valid() && m_pWConsD == 0 ) if(Parameters("WConUnit")->asInt() == 0) m_pCon = m_pCon + (m_pWConsOut->asDouble(x,y) / 1000 ) * pow(m_pDTM->Get_Cellsize(), 2) * m_pTStep; //Wasserentnahme Eingangsdaten in m3/s -> [0,001m^3 m^-2 s^-1 == 1 mm s^-1] * (Zellgroesze)^2 * Zeitschritt(s) else m_pCon = m_pCon + (m_pWConsOut->asDouble(x,y) / 1000 / 86400 / 30) * pow(m_pDTM->Get_Cellsize(), 2) * m_pTStep; //Wasserentnahme Eingangsdaten in m3/Monat, deshalb teilen durch (86400*monthDays) -> [0,001m^3 m^-2 s^-1 == 1 mm s^-1] * (Zellgroesze)^2 * Zeitschritt(s) //--------------------------------------------------------- /**///%%%% Monitoring %%%%%%%%%% /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/ RivBasConMonth = RivBasConMonth + m_pCon; /**/m_pSumCon->Add_Value(x, y, m_pCon); /**///%%%%%%%%%%%%%%%%%%%%%%%%%% //prozentualle Abflussreduktion vornehmen - abhaengig davon, ob Gitterbox oder Flussgitterbox. if( Parameters("RivG")->asInt() > 0 && m_pRivGrids->asDouble(x,y) != 0) m_pFlowFac = m_pRFlowFac; //Weiterleitungsfaktor-Fluss-Gitterbox setzten else m_pFlowFac = m_pHFlowFac; //Weiterleitungsfaktor-Gitterbox setzen //--------------------------------------------------------- i = m_pDTM->Get_Gradient_NeighborDir(x, y); // Falls kein niedrigerer Nachbar -> Wert=-1 //Falls Abfluesse stattfinden koennen, weil es eine niedrigere Nachbarzelle gibt bzw. ein Gradient groeszer Null vorliegt... if( i >= 0 || m_pGrad->asDouble(x,y) > 0) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); //--------------------------------------------------------- //Pruefen ob Zellenabfluss [(m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac] aus Gitterzelle (x,y) kleiner etwaiger Entnahme m_pCon //...wenn der Fall: dann Entnahmen auf Groesze des Zellabflusses setzen -> es resultiert Nullabfluss in diesem Zeitschritt double resFlow = (m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac; //Fall Schwellenwert... -> m_pCon Veraenderung if(m_pWConThres != 0 && Parameters("RivG")->asInt() > 0 && m_pRivGrids->asDouble(x,y) != 0) { if(resFlow >= ( m_pWConThres * m_pTStep)) { if( (resFlow - ( m_pWConThres * m_pTStep)) < m_pCon) //wenn resultierender Abfluss nach Abzug des Schwellewertes kleiner als m_pCon, dann Entnahme nur in Hoehe von resFlow - m_pWConThres { if(Parameters("eP")->asBool() && errC2 == 0) { WriteLog("Warnung! Es wurde in mindestens einem Fall bei Beruecksichtigung des Schwellenwertes und einer Entnaheme, ein negativer Abfluss ermittelt!!"); errC2 = -1; } /**///%%%% Monitoring %%%%%%%%%% /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/ remRivBasConMonth = remRivBasConMonth + (m_pCon - ( resFlow - ( m_pWConThres * m_pTStep)) ); //Summe der Entnahmen die dem RivBasin nicht entnommen werden konnten (weil resFlow kleiner als m_pCon) pro Monat /**/m_pSumRemCon->Add_Value(x, y, (m_pCon - ( resFlow - ( m_pWConThres * m_pTStep))) ); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% m_pCon = resFlow - ( m_pWConThres * m_pTStep); } //else: m_pCon bleibt unveraendert... } else //Falls Schwellenwert schon hoeher als berechneter Abfluss, keine Entnahme mehr... { if(Parameters("eP")->asBool() && errC3 == 0) { WriteLog("Warnung! In mindestens einem Fall war der resultierdene Abfluss kleiner als der eingestellte Schwellenwert!!"); errC3 = -1; } /**///%%%% Monitoring %%%%%%%%%% /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/ remRivBasConMonth = remRivBasConMonth + m_pCon; //Summe der Entnahmen die dem RivBasin nicht entnommen werden konnten (weil resFlow kleiner als m_pCon) pro Monat /**/m_pSumRemCon->Add_Value(x, y, m_pCon); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% m_pCon = 0; } } else // falls kein Schwellenwert und/oder keine Hauptgerinnerasterzelle if( resFlow < m_pCon) { if(Parameters("eP")->asBool() && errC4 == 0) { WriteLog("Warnung! Es wurde in mindestens einem Fall ein negativer Abfluss ermittelt!!"); errC4 = -1; } /**///%%%% Monitoring %%%%%%%%%% /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/ remRivBasConMonth = remRivBasConMonth + (m_pCon - resFlow); //Summe der Entnahmen die dem RivBasin nicht entnommen werden konnten (weil resFlow kleiner als m_pCon) pro Monat /**/m_pSumRemCon->Add_Value(x, y, (m_pCon - resFlow)); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% m_pCon = resFlow; } //--------------------------------------------------------- /**///%%%% Monitoring %%%%%%%%%% /**/WSystemDayWithd = WSystemDayWithd + (m_pGFlow + m_pBFlow + m_pCFlow)*(1-m_pFlowFac); //faktorielle Tageswasserverluste aus WSystem /**/WSystem = WSystem - (m_pGFlow + m_pBFlow + m_pCFlow)*(1-m_pFlowFac); //faktorielle Wasserverluste aus WSystem pro Zeitschritt /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/{ /**/ RivBasDayWithd = RivBasDayWithd + (m_pGFlow + m_pBFlow + m_pCFlow)*(1-m_pFlowFac); //faktorielle tageswasserverluste aus RivBasin /**/ RivBas = RivBas - (m_pGFlow + m_pBFlow + m_pCFlow)*(1-m_pFlowFac); //faktorielle Wasserverluste aus RivBasin pro Zeitschritt /**/} /**///%%%%%%%%%%%%%%%%%%%%%%%%%% /**///%%%% Monitoring %%%%%%%%%% /**/WSystemDayWithd = WSystemDayWithd + m_pCon; //flaechenbasierte Tagesentnhamen aus WSystem /**/WSystem = WSystem - m_pCon; //Entnommenes Wasser aus WSystem ueber die Flaeche pro Zeitschritt /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/{ /**/ RivBasDayWithd = RivBasDayWithd + m_pCon; //flaecenbasierte Tagesentnahmen aus RivBasin /**/ RivBas = RivBas - m_pCon; //Entnommenes Wasser aus RivBasin ueber die Flaeche pro Zeitschritt /**/ resRivBasConMonth = resRivBasConMonth + m_pCon; /**/} /**/m_pSumResCon->Add_Value(x, y, m_pCon); /**///%%%%%%%%%%%%%%%%%%%%%%%%%% //FehlerAbfrage! if( (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon) < 0 ) Message_Dlg("Negativer Abfluss errechnet -> FEHLER"); //%%%%%%%%%%%%%%%%%%%%%%%%%% EntnahmenCode - Ende %%%%%%%%%%%%%%%%%%%%%%%%%% //--------------------------------------------------------- //resultierende Zufluesse in die Rasterzelle (ix,iy) entspricht (Abfluss der Rasterzelle (x,y) minus der Entnahmen bzw. faktoriellen Minderungen) if( m_pDTM->is_InGrid(ix,iy) && !m_pDTM->is_NoData(ix,iy)) //wenn (ix,iy) im Grid liegen und keine noData-Gitterzellen sind... -> Zufluss in die Zelle (ix,iy) { m_pChannelFlow->Add_Value(ix, iy, ( (m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); // GitterboxZUFLUSS in Gitterbox [ix,iy] minus Entnahme (WCon). Es gilt jeweils am Tagesende (da immer bei Tageswechsel Null gesetzt wird): [m3/d] m_pTempC->Add_Value( ix, iy, ( (m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); // GitterboxZUFLUSS: Zelle (x,y) 'uebergibt' Inhalt (OverlandFlow+BaseFlow+ChannelFlow - Entnahme(WCon) ) an niedrigste Umgebungszelle (ix,iy) m_pTemp->Add_Value (ix, iy , ( (m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); // Zwischenspeicher GitterboxZUFLUSS minus Entnahme(WCon) um diesen im nae Zeitschritt in den ersten Speicher der ChannelKaskade zu schreiben } else //wenn (ix,iy) nicht im Grid und/oder eine NoData-Gitterzelle ist... -> SYSTEMabfluss (dieser Wasserabfluss wird nicht mehr beruecksichtigt) { /**///%%%% Monitoring %%%%%%%%%% //Da Senke oder Rand -> Speicherrinhalt m_pTempC seit dem letzten Zeitschritts flieszt ab (bzw. wird geloescht). //Fuer das RiverBasin sollte diese bedingung hoechstens fuer die Ausgangsbox des Basin zutreffen (siehe naechsten MonitoringSchritt) /**/WSystemOut = WSystemOut + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/WSystem = WSystem - (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/ /**/WSystemDayOut = WSystemDayOut + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**///%%%%%%%%%%%%%%%%%%%%%%%%%% } //--------------------------------------------------------- /**///%%%% Monitoring %%%%%%%%%% RiverBasin-AUSGANG (Effektiver Abfluss aus Flusseinzugsgebiet) /**/if(x==Parameters("RBMx")->asInt() && y==Parameters("RBMy")->asInt()) //(x==16 && y==121)//Elbe2_5000m | (x==78 && y==607)//Elbe2_1000m | (x==166 && y==843)//Nile_5000m // STATISCH!! Abfrage ob Ausgangsbox aus RiverBasine vorliegt -> RivOut setzen == RiverBasine-Abfluss (Flussabfluss) /**/{ /**/RivOut = RivOut + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/RivBas = RivBas - (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/ /**/RivDayOut = RivDayOut + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/RivMonthOut = RivMonthOut + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/} /**///------------------------------------------------------- /**/// TestRoutine 1 ---------------------------------------- if(Parameters("Test1")->asInt() > 0 && x == Parameters("xt1")->asInt() && y == Parameters("yt1")->asInt()) {//Effektiver Abfluss aus der Hauptgerinnerasterzelle der TestRoutine1 m_pTestR1 = m_pTestR1 + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); //Summe der errechneten Abfluesse aus Flussrasterzelle (x,y) ueber alle Zeitschritte m_pTestR1m = m_pTestR1m + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); //Summe der errechneten Abfluesse aus Flussrasterzelle (x,y) pro Monat } /**///%%%%%%%%%%%%%%%%%%%%%%%%%% } else //Falls KEINE Abfluesse stattfinden koennen, Systemabfluss des Wassers des vorherigen Zeitschritts!! { double outflow1 = r - m_pRun; //Inhalt von m_pTempR->asDouble(x,y) des letzten Zeitschritts abflieszen lassen double outflow2 = d - m_pDrain; //Inhalt von m_pTempD->asDouble(x,y) des letzten Zeitschritts abflieszen lassen double outflow0 = 0; double remWith = 0; //Wassermenge die nicht entnommen werden kann, weil zuwenig Speicherabfluss nach drauszen if( (m_pCCacheOut->asDouble(x,y) + outflow1 + outflow2) >= m_pCon) outflow0 = (m_pCCacheOut->asDouble(x,y) + outflow1 + outflow2) - m_pCon; else remWith = m_pCon - m_pCCacheOut->asDouble(x,y) + outflow1 + outflow2; //bedeutet: outflow0 == 0 /**///%%%% Monitoring %%%%%%%%%% //Da Senke oder Rand -> Speicherrinhalte seit dem letzten Zeitschritts fliessen ab (bzw. wird geloescht). /**/WSystemOut = WSystemOut + outflow0; /**/WSystem = WSystem - outflow0; /**/ /**/WSystemDayOut = WSystemDayOut + outflow0; /**/WSystemDayWithd = WSystemDayWithd + m_pCon - remWith; /**/ /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Abfrage ob (x,y) Koordinate im RiverBasin liegt /**/{ /**/ RivBas = RivBas - outflow0; /**/ RivBasSink = RivBasSink + outflow0; /**/ RivBasDayWithd = RivBasDayWithd + m_pCon - remWith; /**/ resRivBasConMonth = resRivBasConMonth + m_pCon - remWith; /**/ remRivBasConMonth = remRivBasConMonth + remWith; /**/// m_pSumRemCon->Add_Value(x,y,remWith); //aeNDERUNG: 081114 - Anscheinden doppelter Eintrag s. Zeilen drunter (verantwortlich fuer Fehler in der Bilanz?) /**/} /**/m_pSumRemCon->Add_Value(x, y, remWith); /**/m_pSumResCon->Add_Value(x, y, m_pCon - remWith); /**///%%%%%%%%%%%%%%%%%%%%%%%%%% m_pTempR->Set_Value(x, y, m_pRun); //Speicher nur auf verikalen Zufluss dieses Zeitschritts setzen m_pTempD->Set_Value(x, y, m_pDrain); //Speicher nur auf verikalen Zufluss dieses Zeitschritts setzten m_pCCacheOut->Set_Value( x, y, 0); // Wenn Senke vorliegt (haeufig am Rande des Grids der Fall), wird Inhalt des letzten Zeitschrittes dt_n-1 (m_pCCacheOut(x,y)) geloescht (forcierter Abfluss nach auszen). Zufluss in die Box waehrend des jeweiligen Zeitschrittes dt_n (aus anderen Zellen in m_pTempC(x,y)) wird aber reingeschrieben. } } // //###################################################### //###################################################### // double CLandFlow::Calc_GFlow(int x, int y, double f) //OverlandFlow ACHTUNG!! Funktioniert so nur mit nO = 1 !! { double g = 0.0; int i; if(kArray[x][y][0] > 0) { for(i=0; i < nG; i++) { //--Test double w = kArray[x][y][0]; double q = CalcRet(kArray[x][y][0], nG); //--Test g = f / CalcRet(kArray[x][y][0], nG); } } return( g ); } // //###################################################### //###################################################### // double CLandFlow::Calc_CFlow(int x, int y, double f, int n) //ChannelFlow/Gerinneabfluss { double g = 0.0; double h = 0.0; int i; /**///%%%% Monitoring %%%%%%%%%% /**/nCArray[x][y][nMax] = 0; /**///%%%%%%%%%%%%%%%%%%%%%%%%%% if(kArray[x][y][1] > 0 ) { g = f; // Gitterboxzufluss des letzten Zeitschritts in den ersten Kaskadenspeicher [0] for(i=0; i < n; i++) { h = (nCArray[x][y][i] + g); // Speicherinhalt + Zufluss //Entnahme wird bisher immer beim Gitterboxzufluss (hier Eingangswert f) des letzten Zeitschritts beruecksichtigt!! if(n == 1 && f > 0) //testStop { int ay = 1; } if(h< 0) //testStop { int ay = 1; } //--Test double w = kArray[x][y][1]; double q = CalcRet(kArray[x][y][1], n); //--Test if( h >= 0) g = h / CalcRet(kArray[x][y][1], n); //Abfluss aus Speicher else { g = 0; if(Parameters("eP")->asBool()) WriteLog("FEHLER errC! Negativer Abfluss ermittelt - Abfluss fuer diesen Zeitschritt auf Null gesetzt"); errC = 1; } if( (h-g) < 0) //testStop { int az = 1; } nCArray[x][y][i] = h - g; //verbleibender Speicherinhalt -> g == Zufluss des naechsten Speichers /**///%%%% Monitoring %%%%%%%%%% /**/nCArray[x][y][nMax] = nCArray[x][y][nMax] + nCArray[x][y][i]; /**///%%%%%%%%%%%%%%%%%%%%%%%%%% } } if(g < 0) //Falls kein positiver Abfluss aus letztem Speicher -> Abfluss gleich Null g = 0; return( g ); //Abfluss des letzten Speichers == Abfluss der Gitterbox in diesem Zeitschritt } // //###################################################### //###################################################### double CLandFlow::Calc_BFlow(int x, int y, double f) //BaseFlow/Grundwasserabfluss ACHTUNG!! Funktioniert so nur mit nB = 1 !! { double g = 0.0; if(kArray[x][y][2] > 0) { //--Test double w = kArray[x][y][2]; double q = CalcRet(kArray[x][y][2], 1); //--Test g = f / CalcRet(kArray[x][y][2], 1); } return( g ); } //###################################################### //###################################################### double CLandFlow::CalcRet(double q, int n) { return(q * 86400 / m_pTStep); // f[d] und m_pTSTep [s] - ACHTUNG n hier NICHT mehr miteinbezogen (17.02.14) [vormals: q * 86400 / m_pTStep*n ] } //###################################################### //SubBasinId //###################################################### bool CLandFlow::SubBasinId(int x, int y) //Funktion gibt aus dem m_pSumRunoffDrainage-Raster die Summe der RunOff und Drainage Werte aller Rasterzellen des Teileinzugsgebiets der Flussrasterzelle (x,y), //ODER aller Rasterzellen des Abflusspfades bis zum Erreichen der HG-Rasterzelle { //KoordinatenDouble erzeugen FORMAT: xxxxyyyy double r = 0; int u = 10000*x + y; r = u; //Koordinate der Flussrasterzelle des Teileinzugsgebietes - FORMAT: xxxxyyyy NumGridsTestR1 = 1; //entspricht zumindest einer HG-Raterzelle im Teileinzugsgebiet/Einzugsgebiet double SumRD = m_pSumRunoffDrainage->asDouble(x,y); //als erstes die Summe der RunOff und Drainage Werte der Muendungs-HG-Rasterzelle des Teileinzugsgebiets/Einzugsgebiets setzten double SumCon = m_pSumCon->asDouble(x,y); double SumResCon = m_pSumResCon->asDouble(x,y); double SumRemCon = m_pSumRemCon->asDouble(x,y); if(Parameters("Test1")->asInt() == 1) { if(m_pBasinShare) { for(int ix=0; ix < NX; ix++) { for(int iy=0; iy < NY; iy++) { if(!m_pDTM->is_NoData(ix,iy) && m_pBasinShare->asDouble(ix,iy) == r) { SumRD = SumRD + m_pSumRunoffDrainage->asDouble(ix,iy); SumCon = SumCon + m_pSumCon->asDouble(ix,iy); SumResCon = SumResCon + m_pSumResCon->asDouble(ix,iy); SumRemCon = SumRemCon + m_pSumRemCon->asDouble(ix,iy); NumGridsTestR1++; } } } } else return(false); } if(Parameters("Test1")->asInt() == 2) { if(m_pTestR1Share) { for(int ix=0; ix < NX; ix++) { for(int iy=0; iy < NY; iy++) { if(!m_pDTM->is_NoData(ix,iy) && m_pTestR1Share->asDouble(ix,iy) == r) { SumRD = SumRD + m_pSumRunoffDrainage->asDouble(ix,iy); SumCon = SumCon + m_pSumCon->asDouble(ix,iy); SumResCon = SumResCon + m_pSumResCon->asDouble(ix,iy); SumRemCon = SumRemCon + m_pSumRemCon->asDouble(ix,iy); NumGridsTestR1++; } } } } else return(false); } m_pTestR1RDm = SumRD - SumRD_SubBasin; m_pTestR1Cm = SumCon - SumCon_SubBasin; m_pTestR1resCm = SumResCon - SumResCon_SubBasin; m_pTestR1remCm = SumRemCon - SumRemCon_SubBasin; SumRD_SubBasin = SumRD; SumCon_SubBasin = SumCon; SumResCon_SubBasin = SumResCon; SumRemCon_SubBasin = SumRemCon; return(true); } //###################################################### //###################################################### //Gesamtes Einzugsgebiet der HG-Rasterzelle (HGx,HGy) von TestR1 bestimmen void CLandFlow::TestR1Share(int HGx, int HGy) { int x, y; //KoordinatenDouble der HG-Rasterzelle erzeugen FORMAT: xxxxyyyy double r = 0; int u = 10000*HGx + HGy; // r = u; //Wert der gesetzt wird : FORMAT: xxxxyyyy (Koordinate der "Ziel"HG-Rasterzelle in alle im Abflusspfad voherigen Rasterzellen muenden) if(m_pTestR1Share) { for(int l=0; l < m_pDTM->Get_NCells() && Set_Progress_NCells(l); l++) //ueber alle Zellen des m_pDEM-Grids { m_pDTM->Get_Sorted(l, x, y); //sortieren der Zellen von hoechster (l=0) nach niedrigster - 1.Durchlauf um zu gucken, ob Abflusspfad in (HGx, HGy) endet while( !m_pDTM->is_NoData(x,y) && ( x != HGx || y != HGy ) ) { int i = m_pDTM->Get_Gradient_NeighborDir(x, y); if(i >= 0) //es gibt eine niedrigere Nachbarzelle... { x = Get_xTo(i, x); y = Get_yTo(i, y); if(x == HGx && y == HGy) { m_pDTM->Get_Sorted(l, x, y); //2.Durchlauf um Abflusspfad mit den koordinaten der HG-Rasterzelle (HGx, HGy) zu markieren. while( !m_pDTM->is_NoData(x,y) && ( x != HGx || y != HGy ) ) { int j = m_pDTM->Get_Gradient_NeighborDir(x, y); if(j >= 0) //es gibt eine niedrigere Nachbarzelle... { m_pTestR1Share->Set_Value(x, y, r); //Koordinaten der Ziel-Flussgridbox werden gesetzt x = Get_xTo(j, x); y = Get_yTo(j, y); } else {break;} //Nur fuer den Fall; j = -1 sollte eigentlich nicht mehr moeglich sein, da letzte Gridbox ja HG-Rasterzelle... } } } else break; //Senke liegt vor } } } } //###################################################### // //###################################################### bool CLandFlow::WConsRiv(int i) //Berechnung der dynamschen Wasserentnahmewerte nach Funktionsauswahl 1 oder 2 (bisher auf Monatsbasis) { double SumCons = 0; double SumInFlow = 0; double valTest = 0; double BasinCon = 0; int m = 1; //Multiplikativer Faktor fuer die Wasserentnahme (NUR fuer Entnahme aus HG-Rasterzelle) - PARAMETERWAHL wird bisher NICHT gelogt! m_pWConsOut->Assign(0.0); if(i == 3) // falls Entnahme Funktion 3 (Entnahme des genauen Wertes der Eingangsdaten aus jeder Raterzelle) -> dann entspricht WasserentnahmeRaster genau den Eingangsdaten m_pWConsOut->Assign(&pWConsData); else if(m_pNumInFlow && m_pBasinShare) { //FlussGrids Identifizieren und damit jeweiliges Teileinzugsgebiet bestimmen for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if( m_pRivGrids && Parameters("RivG")->asInt() > 0 && m_pRivGrids->asDouble(x,y) != 0) //Wenn HG-Rasterzelle { double r = 0; //KoordinatenDouble erzeugen FORMAT: xxxxyyyy int u = 10000*x + y; r = u; //Wert der gesetzt wird : FORMAT: xxxxyyyy (Koordinate der Flussrasterzelle des Teileinzugsgebietes) //Falls Entnahme Funktion 1: Entnahme des Teileinzugsgebietes NUR aus der HauptgerinneRasterzelle if(i == 1) { m_pWConsOut->Add_Value(x, y, m*pWConsData.asDouble(x, y)); //Entnahmewert der HG-Rasterzelle aus HG-Rasterzelle entnehmen BasinCon = BasinCon + m*pWConsData.asDouble(x, y); //Aufsummierung der Entnahme im gesamten Einzugsgebiet for(int ix=0; ix < NX; ix++) { for(int iy=0; iy < NY; iy++) { if(!m_pDTM->is_NoData(ix,iy) && m_pBasinShare->asDouble(ix,iy) == r) m_pWConsOut->Add_Value(x, y, (m*pWConsData.asDouble(ix, iy)) ); //Entnahmewert der Teileinzugsgebiets-Rasterzelle aus HG-Rasterzelle entnehemn BasinCon = BasinCon + (m*pWConsData.asDouble(ix, iy)); //Aufsummierung der Entnahme im gesamten Einzugsgebiet } } } //Falls Entnahme Funktion 2: Entnahme des Teileinzugsgebietes ANTEILIG aus jeder Rasterzelle des Teileinzuggebietes //Berechnugsparameter bestimmen: //SumCons=Summe aller Ennahmen des Teileinzuggebietes (inkl HG-Rasterzelle) //SumInFlow=Aufsummierte InFlowCell Werte aller Rasterzellen des Teileinzuggebietes if(i == 2) { SumCons = pWConsData.asDouble(x, y); //Entnahmen im Teileinzugsgebiet: Entnahme der HG-Rasterzelle (x,y) setzten SumInFlow = m_pNumInFlow->asDouble(x, y); for(int ix=0; ix < NX; ix++) { for(int iy=0; iy < NY; iy++) { if(!m_pDTM->is_NoData(ix,iy) && m_pBasinShare->asDouble(ix,iy) == r) { //TEST double Tst = pWConsData.asDouble(ix, iy); double Tst2 = m_pNumInFlow->asDouble(ix, iy); SumCons = SumCons + pWConsData.asDouble(ix, iy); SumInFlow = SumInFlow + m_pNumInFlow->asDouble(ix, iy); } } } BasinCon = BasinCon + SumCons; //Aufsummierung der Entnahme im gesamten Einzugsgebiet //Auf Basis des Entnahmeanteils P = m_pNumInFlow(Rasterzelle) / SumInFlow , bestimmen des Entnahmewertes ueber P*SumCons und schreiben in m_pWConsOut if(m_pNumInFlow->asDouble(x, y) == 0) //Wenn SONDERFALL: HG-Rasterzelle hat keine Zufluesse, daher m_pNumInFlow und SumInFlow == 0 -> keine antielige sonder absolute Entnahme! { m_pWConsOut->Set_Value(x, y, SumCons); //...bestimmen des Entnahmewertes der HG-Zelle valTest = SumCons; //Validierungstest: Summe der anteiligen Entnahmen im Teileinzugsgebiet } else //anteilige Entnahme { m_pWConsOut->Set_Value(x, y, (m_pNumInFlow->asDouble(x, y) / SumInFlow * SumCons)); //...bestimmen des Entnahmewertes der HG-Zelle valTest = m_pNumInFlow->asDouble(x, y) / SumInFlow * SumCons; //Validierungstest: Summe der anteiligen Entnahmen im Teileinzugsgebiet } for(int ix=0; ix < NX; ix++) { for(int iy=0; iy < NY; iy++) { if(!m_pDTM->is_NoData(ix,iy) && m_pBasinShare->asDouble(ix,iy) == r && m_pNumInFlow->asDouble(x, y) > 0) { double partCon = (m_pNumInFlow->asDouble(ix, iy) / SumInFlow * SumCons); valTest = valTest + partCon; //Validierungstest: Summe der anteiligen Entnahmen im Teileinzugsgebiet m_pWConsOut->Set_Value(ix, iy, partCon); //...bestimmen des Entnahmewertes der uebrigen Rasterzelle } } } } } } } } //valTest Breakpoint: valTest ungefaehr SumCons ?? else return(false); return(true); } //###################################################### //######################################################### //--------------------------------------------------------- //######################################################### /////////////////////////////////////////////////////////// // // // Sekundaer-Funktionen // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //Initiierungsfunktionen //--------------------------------------------------------- // void CLandFlow::InitKArray() //Warnung : Funktion statisch auf Grid m_pGrad eingestellt { double Cx; int nCx; for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if(m_pGrad->is_NoData(x,y) || m_pGrad->asDouble(x,y) == 0) { kArray[x][y][0] = -1; kArray[x][y][1] = -1; kArray[x][y][2] = -1; } else { if( Parameters("RivG")->asInt() > 0 && m_pRivGrids->asDouble(x,y) != 0) // falls Flusssgrids beruecksichtigt werden und Flussgrid... { Cx = C0r; nCx = nCr; } else { Cx = C0; nCx = nC; } double kG = G0/(nG*2) * (m_pDTM->Get_Cellsize() / 1000 ) / pow(m_pGrad->asDouble(x,y), 0.1 ); // *0* DEFAULT: pG = 17.87e-2*dx/(grad)^0.1 -> dx in km double kC = Cx/(nCx*2) * (m_pDTM->Get_Cellsize() / 1000 ) / pow(m_pGrad->asDouble(x,y), 0.1 ); // *1* DEFAULT: pC = 9.92e-4*dx/(grad)^0.1 -> dx in km double kB = pB * (m_pDTM->Get_Cellsize() / 1000 ) / 50; // *2* kB [d], dx [km] / d0=50000 m ) if( kG > kMinG ) kArray[x][y][0] = kG; else kArray[x][y][0] = kMinG; if( kC > kMinC ) kArray[x][y][1] = kC; else kArray[x][y][1] = kMinC; if ( kB > kMinB ) kArray[x][y][2] = kB; else kArray[x][y][2] = kMinB; } } } } void CLandFlow::InitNcArray(int p1, int p2, int p3) { // Initiieren mit Wert Null for(int x=0; x < p1; x++) { for(int y=0; y < p2; y++) { for(int i = 0; i < p3; i++) { nCArray[x][y][i] = 0; } } } } /*void CLandFlow::InitPArray(int p1, int p2, int p3) //zur Zeit: nicht gesetzt { // Initiieren mit Wert Null for(int x=0; x < p1; x++) { for(int y=0; y < p2; y++) { for(int i = 0; i < p3; i++) { pArray[x][y][i] = 0; } } } }*/ //--------------------------------------------------------- //Speicherfunktionen bzw. Schreibefunktion //--------------------------------------------------------- // bool CLandFlow::SaveNcCache(int nMax) { int i = 0; int o = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\NcCache.txt"; path = path0.str(); int d = NX * NY; fstream myfile; myfile.open(path.c_str(), ios::out|ios::trunc); for(int x = 0; x < NX; x++) { for(int y = 0; y < NY; y++) { myfile << x << " " << y; for(o = 0; o < nMax; o++) { /**/ if(o == 0 && m_pTempK->asDouble(x,y) >= 0) // aenderung 181114: Gitterboxzufluss des letzten Zeitschritts wird im ersten Speicher gerspeichert... /**/ myfile << " " << ( nCArray[x][y][o] + m_pTempK->asDouble(x,y) ); /**/ else myfile << " " << nCArray[x][y][o]; } myfile << "\n"; i++; Process_Set_Text(CSG_String::Format(SG_T("NcCache || Schreibe Datensatz %d von %d"),i ,d)); } } myfile.close(); return true; } bool CLandFlow::SaveParameters() { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\SimParameters.txt"; path = path0.str(); int d = NX * NY; time_t rawtime; time(&rawtime); fstream myfile; myfile.open(path.c_str(), ios::out|ios::trunc); myfile << "KALIBRIERUNGSVERSION des Programms! EingangsPARAMETER C0, C0r und G0 unabhaengig von n." << "\n\n"; myfile << "Basierend auf: ProgrammBuild " << cVers << "\n"; myfile << "TimeStamp: " << ctime(&rawtime) << "\n\n"; myfile << "Parameter:\n\n"; myfile << "Startjahr = " << m_sYear0 << "\n"; myfile << "Simulation mit Speicherwerten initialisieren [0 = nein, 1 = ja]: " << Parameters("CacheUse")->asBool() << "\n"; myfile << "Wasservolumen in den Systemspeichern zu Beginn der Simulation: RivBasInit = " << RivBasInit << " und WSystemInit = " << WSystemInit << "\n"; myfile << "Rechentage [d] = " << m_pDays << "\n"; myfile << "Schrittlaenge [s] = " << m_pTStep << "\n\n"; myfile << "vMax [km/h] = " << vMax << "\n"; myfile << "Aufloesung [m] = " << m_pDTM->Get_Cellsize() << "\n"; myfile << "Anzahl der Reihen NX = " << NX << "\n"; myfile << "Anzahl der Zeilen NY = " << NY << "\n"; myfile << "Anzahl der Rasterzellen des DTM (ohne NoDataZellen): " << NumGrids << "\n"; myfile << "Anzahl der Rasterzellen im Flusseinzugsgebiet: " << NumRBGrids << "\n\n"; myfile << "LSSchemaDaten-Dateipfad [Ordner]: " << m_pLSDataFolder.b_str() << "\n"; myfile << "WaterGapDaten-Dateipfad [Ordner]: " << m_pWConDataFolder.b_str() << "\n"; myfile << "Datenpfad wo gespeicher werden soll: " << m_pDataSaveFolder.b_str() << "\n"; myfile << "Absoluter SpeicherDateipfad: " << m_pSPath << "\n\n"; myfile << "nG = " << nC << "\n"; myfile << "nHG = " << nCr << "\n"; myfile << "nO = " << nG << "\n"; myfile << "cG = " << C0 << "\n"; myfile << "cHG = " << C0r << "\n"; myfile << "cO = " << G0 << "\n"; myfile << "pB = " << pB << "\n\n"; myfile << "Fester Reduzierungsfaktor des Surface Runoff [%/100] = " << m_pRedFacR << "\n"; myfile << "Fester Reduzierungsfaktor der Drainage [%/100] = " << m_pRedFacD << "\n"; myfile << "Ausgleich der Surface Runoff Reduktion = " << Parameters("autoFacD")->asBool() << "\n2"; myfile << "Offsetwert Surface Runoff [m3/s] = " << m_pOffsetR << "\n"; myfile << "Offsetwert Drainage [m3/s] = " << m_pOffsetD << "\n";myfile << "Flussgrid-Beruecksichtigung/Bestimmung = " << Parameters("RivG")->asInt() << "\n"; myfile << "kMinG [d] = " << kMinC << "\n"; myfile << "kMinHG [d] = " << kMinCr << "\n"; myfile << "kMinO [d] = " << kMinG << "\n"; myfile << "kMinB [d] = " << kMinB << "\n"; myfile << "vMaxG [km/h] = " << vMaxC << "\n"; myfile << "vMaxHG [km/h] = " << vMaxCr << "\n"; myfile << "vMaxO [km/h] = " << vMaxG << "\n"; myfile << "Berechnung NUR im RiverBasin = " << Parameters("onlyRB")->asBool() << "\n\n"; myfile << "Flaechenwasserentnahme - Auswahl [0=keine] = " << Parameters("WCons")->asInt() << "\n"; myfile << "Fester Gitterbox-Wasserentnahmefaktor [%] = " << m_pConsFacAll << "\n"; myfile << "Fester FlussGitterbox-Wasserentnahmefaktor [%] = " << m_pConsFacRiv << "\n"; myfile << "Vorlauftage bevor Wasserentnahme beruecksichtigt wird [d] = " << m_pWConsDIn << "\n\n"; myfile << "Schwellenwert ab dem eine Entnahem erst vorgenommen wird [m3/s] = " << m_pWConThres << "\n"; myfile << "Einheit der eingelesenen WaterGapDaten ([m3/s] = 0, [m3/Monat] = 1): " << Parameters("WConUnit")->asInt() << "\n\n"; myfile << "m_pVTresh erzwingen = " << Parameters("EnfVmax")->asBool() << "\n"; myfile << "m_pVTresh [km/h] = " << m_pVTresh << "\n"; myfile << "Autom. Zeitschrittlaenge = " << Parameters("CalcT")->asBool() << "\n"; myfile << "k_Min [d] = " << k_Min << "\n\n"; myfile << "ErrorCode = " << errC << "\n\n"; myfile << "Evaluierungspunkte:" << "\n"; myfile << "Evaluierungspunkt 1 - " << m_pEvP1s.b_str() << ", x=" << Parameters("EvP1x")->asInt() << ", y=" << Parameters("EvP1y")->asInt() << "\n"; myfile << "Evaluierungspunkt 2 - " << m_pEvP2s.b_str() << ", x=" << Parameters("EvP2x")->asInt() << ", y=" << Parameters("EvP2y")->asInt() << "\n"; myfile << "Evaluierungspunkt 3 - " << m_pEvP3s.b_str() << ", x=" << Parameters("EvP3x")->asInt() << ", y=" << Parameters("EvP3y")->asInt() << "\n"; myfile << "Ausgangsrasterzelle des Flusseinzugsgebiet: " << "x=" << Parameters("RBMx")->asInt() << ", y=" << Parameters("RBMy")->asInt() << "\n\n"; if(Parameters("vRM1")->asInt() > 0 || Parameters("vRM2")->asInt() > 0) { myfile << "Abflussmanipulation Rasterzelle 1 - Manipulation des berechnteen Abflusses [1], Abfluss aus Speicher vorgeben [2]: " << Parameters("vRM1")->asInt() << "\n"; myfile << "Koordinate: x = " << Parameters("RM1x")->asInt() << ", y = " << Parameters("RM1y")->asInt() << "\n"; myfile << "Faktor q = " << Parameters("RM1q")->asDouble() << " und Offset a = " << Parameters("RM1a")->asDouble() << "\n\n"; myfile << "Abflussmanipulation Rasterzelle 2 - Manipulation des berechnteen Abflusses [1], Abfluss aus Speicher vorgeben [2]: " << Parameters("vRM2")->asInt() << "\n"; myfile << "Koordinate: x = " << Parameters("RM2x")->asInt() << ", y = " << Parameters("RM2y")->asInt() << "\n"; myfile << "Faktor q = " << Parameters("RM2q")->asDouble() << " und Offset a = " << Parameters("RM2a")->asDouble() << "\n\n"; myfile << "Gesamtmenge des Wassers, die waehrend des Simualtionszeitraumes durch die Rasterzellenmanipulation dem RivBasin hinzugefuegt (+) oder entnommen (-) wurde: " << manWithd << "\n\n"; } if(Parameters("Test1")->asInt() > 0) { myfile << "TestRoutine [1]: 1) nur fuer Teileinzugsgebiet der HG-Rasterzelle oder [2] fuer das Flusseinzugsgebiet bis zum Erreichen der HG-Rasterzelle: " << Parameters("Test1")->asInt() << "\n\n"; myfile << "TestRoutine 1: Flusseinzugsgebiet der Flussrasterzelle (" << Parameters("xt1")->asInt() << "," << Parameters("yt1")->asInt() << ")\n"; if(SumRD_SubBasin >= 0) { myfile << "Anzahl der Rasterzellen des Teileinzugsgebietes: " << NumGridsTestR1 << "\n"; myfile << "Summe der vertikalen Zufluesse im Teileinzugsgebiet ueber den gesamten Simulationszeitraum: " << SumRD_SubBasin << "\n"; myfile << "Summe der Abfluesse aus der Flussrasterzelle ueber den gesamten Simulationszeitraum: " << m_pTestR1 << "\n"; myfile << "Differenz: " << SumRD_SubBasin - m_pTestR1 << "\n\n"; } else myfile << "FEHLER beim Ausfuehren der TestRoutine 1.\n\n"; } /*myfile << "x | y | kG | kC | kB | Wcons" << "\n"; //Schreiben aller K-Werte zu den jeweiligen (x,y) Koordinaten for(int x = 0; x < NX; x++) { for(int y = 0; y < NY; y++) { myfile << x << " " << y; myfile << " " << kArray[x][y][0]; myfile << " " << kArray[x][y][1]; myfile << " " << kArray[x][y][2]; if( Parameters("WCons")->asBool() ) myfile << " " << (m_pWCons->asDouble(x,y) / 1000) * pow(m_pDEM->Get_Cellsize(), 2) * m_pTStep; myfile << "\n"; i++; Process_Set_Text(CSG_String::Format("Parameters || Schreibe Datensatz %d von %d",i ,d)); } }*/ myfile.close(); return true; } bool CLandFlow::WriteOutput(string s, double p1, double p2, int x, int y) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\" << s ; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); if(x >= 0 && y >= 0 ) myfile << x << " " << y << " " << p1 << " " << p2 << "\n"; else myfile << p1 << " " << p2 << "\n"; myfile.close(); return true; } bool CLandFlow::WriteRivBalance(int i1, int i2, double p1, double p2) { std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath3 << "\\" << "RivWaterBalance_" << m_sYear << "-" << dC << ".txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); if(p1 < 0 && p2 < 0 ) //nur schreiben des headers { myfile << "Jahr:" << i1 << " Tag:" << i2 << "\n"; myfile << "Koordinate Flusskilometer m3/s" << "\n"; } else myfile << "(" << i1 << "," << i2 << ") " << p1 << " " << p2 << "\n"; myfile.close(); return true; } //--------------------------------------------------------- // Logeintraege //--------------------------------------------------------- // bool CLandFlow::TestLog1(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\Monitoring_RivBasin.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } bool CLandFlow::TestLog2(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\Monitoring_WSystem.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } bool CLandFlow::TestLog3(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\Monitoring_monthWUseRivBasin.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } bool CLandFlow::TestLog4(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\TestRoutine1.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } bool CLandFlow::WriteLog(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\ErrorLog.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } //----------------------------------------------------- // ReadCacheFile Functions //----------------------------------------------------- // double CLandFlow::ReadNCacheFile(bool p0, string s1, int p1, int p2, int p3, int p4, int p5, char p6, int p7, bool p8) { //p0 - false : Opt1 (Datei in Array einelsen) / true : Opt2 (Spez Wert zu Koord (x,y) einlesen) //p1 - Anzahl der x-Eintraege / Anzahl der x-Eintraege //p2 - Anzahl der y-Eintraege / Anzahl der y-Eintraege //p3 - 0 / x-Koordinate (x0 = 0) //p4 - 0 / y-Koordinate (y0 = 0) //p5 - Anzahl der Speicherwerte pro x,y Koordinate / Anzahl n der Speicherwerte pro x,y Koordinate //p6 - Trennzeichen [char] / Trennzeichen [char] //p7 - 0 / spez einzulesender Speicherwert s von n //p8 - if(true) - erste Zeile enthaelt Sonderinf. / false int x = 0; int y = 0; int o = 0; int r = 0; std::string transfer; char a; double ret = -1; std::stringstream path0; std::string path; path0.str(""); path0 << m_pNCacheFolder.b_str(); path = path0.str(); ifstream myfile; myfile.open(path.c_str(), ios_base::in); if( myfile.is_open() && !myfile.eof() ) { if(p0 == false) //p0 - false : Opt1 (Datei in Array einelsen) { if(p8 == true) getline(myfile, transfer, '\n'); for(int x = 0; x < p1; x++) { for(int y = 0; y < p2; y++) { if(!myfile.eof()) { for(int m = 0; m < 2; m++) { while( (a = myfile.get()) != p6 && a != '\n') {} } for(o = 0; o < p5; o++) { if(a != 0) { if(o= 0) { for(int m = 0; m < (2+p6-1); m++) { while( (a = myfile.get()) != p6) {} if(a == '\n') { WriteLog("FEHLER!! Angabe der Anzahl der Speicherwerte pro Koordinate ist nicht korrekt - ABBRUCH"); return ret; } } if(p5 - p6 > 0) getline(myfile, transfer, p6); else getline(myfile, transfer, '\n'); ret = atof(transfer.c_str()); return ret; } else { WriteLog("FEHLER!! Einzulesend Speicherwert existiert nicht - ABBRUCH"); return ret; } } else { getline(myfile, transfer, '\n'); //ret = atof(transfer.c_str()); // testzwecke } } else { WriteLog("FEHLER!! Datei enthaelt weniger Speichereintraege als abgefragt werden - ABBRUCH"); return ret; } } } } } else { WriteLog("FEHLER!! Dateifehler - Datei NC konnte nicht geoeffnet werden - ABBRUCH."); return ret; } myfile.close(); return ret; } //----------------------------------------------------- // CreateArray Functions //----------------------------------------------------- // void CLandFlow::CreateKArray(int p1, int p2, int p3) { kArray = new double**[p1]; for (int i = 0; i < p1; i++) { kArray[i] = new double*[p2]; for (int j = 0; j < p2; j++) kArray[i][j] = new double[p3]; } } void CLandFlow::CreateLSMArray(int p1, int p2, int p3) { lsMArray = new double**[p1]; for (int i = 0; i < p1; i++) { lsMArray[i] = new double*[p2]; for (int j = 0; j < p2; j++) lsMArray[i][j] = new double[p3]; } } void CLandFlow::CreateNcArray(int p1, int p2, int p3) { nCArray = new double**[p1]; for (int i = 0; i < p1; i++) { nCArray[i] = new double*[p2]; for (int j = 0; j < p2; j++) nCArray[i][j] = new double[p3]; } } void CLandFlow::CreatePArray(int p1, int p2, int p3) { pArray = new double**[p1]; for (int i = 0; i < p1; i++) { pArray[i] = new double*[p2]; for (int j = 0; j < p2; j++) pArray[i][j] = new double[p3]; } } //----------------------------------------------------- // DeleteArray Functions //----------------------------------------------------- //ACHTUNG : statisch auf NX/NY festgelegt - Fehlerpotential, weil keine Groeszenabfrage void CLandFlow::DeleteKArray() { for(int x = 0; x < NX; x++) { for(int y = 0; y < NY; y++) { delete [] kArray[x][y]; } delete [] kArray[x]; } delete [] kArray; kArray = NULL; } void CLandFlow::DeletePArray() { for(int x = 0; x < NX; x++) { for(int y = 0; y < NY; y++) { delete [] pArray[x][y]; } delete [] pArray[x]; } delete [] pArray; pArray = NULL; } void CLandFlow::DeleteNcArray() { for(int x = 0; x < NX; x++) { for(int y = 0; y < NY; y++) { delete [] nCArray[x][y]; } delete [] nCArray[x]; } delete [] nCArray; nCArray = NULL; } //######################################################### //--------------------------------------------------------- //######################################################### //################################################################################################### // Vorlage //################################################################################################### ////////////////TEST /* if( dC >9 && dC > 12 && x == 145 && y == 578) { double pTest = m_pCCacheOut->asDouble(x,y) - m_pCFlow; std::stringstream file0; file0.str(""); file0 << "Neu Darchau-Cache: Tag = " << dC << ", Zeitschritt = " << dT << ", Entnahme m_pCFlow = " << m_pCFlow << ", Speicherwert = " << pTest; std::string file = file0.str(); TestLog1( file ); } if( dC >9 && dC > 12 && ix == 145 && iy == 578) { m_pTest = m_pTest + (m_pGFlow + m_pBFlow + m_pCFlow - m_pCon)*m_pStCons; std::stringstream file0; file0.str(""); file0 << "Neu Darchau-InFlow: Tag = " << dC << ", Zeitschritt = " << dT << ", InFlow in TStep = " << o << ", Entnahme WCons = " << varCons << ", Sum InFlow = " << m_pTest; std::string file = file0.str(); TestLog2( file ); }*/ /////////////// saga-2.2.3/src/modules/simulation/sim_rivflow/RivGridPrep.cpp0000664000175000017500000001754312565125410025466 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivGridPrep.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "RivGridPrep.h" //--------------------------------------------------------- //######################################################### CRivGridPrep::CRivGridPrep(void) { //----------------------------------------------------- // Modul information Set_Name ("RiverGridGeneration"); Set_Author ("Christian Alwardt"); Set_Description ("Generation of RiverCourse-GridCells"); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT" , "Geländemodell (DTM)", "Digitales Geländemodell des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "OUTPUT" , "HG Raster", "Schrittweise Ausgabe der gewünschten Abflusspfade des Hauprgerinnerasters", PARAMETER_OUTPUT ); // Flussgrids [!=0] , keine Flussgrid [0] Parameters.Add_Value( NULL, "SX" , "Abflusspfad-Quelle, x-Wert", "X-Wert der Quellen-Rasterzelle", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( NULL, "SY" , "Abflusspfad-Quelle, y-Wert", "Y-Wert der Quellen-Rastertzelle", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( NULL, "MX" , "Abflusspfad-Mündung, x-Wert", "X-Wert des Mündungs-Rasterzelle", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( NULL, "MY" , "Abflusspfad-Mündung, y-Wert", "Y-Wert des MündungsRasterzelle", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( NULL, "Owrite", "Overwrite RiverGridCells", "Bereits existierende RiverGridCells werden überschrieben (Wenn nicht gesetzt: Abflusspfadende, wenn eine existierende RiverGridCell erreicht wird -> zB bei Fluss mit zwei Quellen sinnvoll).", PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // Hauptfunktion // // // /////////////////////////////////////////////////////////// bool CRivGridPrep::On_Execute(void) { //----------------------------------------------------- // Get the parameter settings... m_pDTM = Parameters("INPUT")->asGrid(); m_pRivGridCells = Parameters("OUTPUT")->asGrid(); m_pSX = Parameters("SX")->asInt(); m_pSY = Parameters("SY")->asInt(); m_pMX = Parameters("MX")->asInt(); m_pMY = Parameters("MY")->asInt(); //----------------------------------------------------- // Do something... if(!Set_RivGridCells(m_pSX, m_pSY, m_pMX, m_pMY)) Message_Dlg("Achtung, Fehler beim Erzeugen des Flussgrids"); //----------------------------------------------------- // Return 'true' if everything is okay... return( true ); } //######################################################### //--------------------------------------------------------- //######################################################### /////////////////////////////////////////////////////////// // // // Funktionen // // // /////////////////////////////////////////////////////////// //###################################################### // bool CRivGridPrep::Set_RivGridCells(int sx, int sy, int mx, int my ) { //Identifizierung der Flussgrids und setzen des Flusskilometerwertes - immer von Gitterboxmittelpunkt zu Mittelpunkt // if( Parameters("Owrite")->asBool() ) // m_pRivGrids->Assign(0.0); int x = sx; int y = sy; int i = -1; double dist = m_pDTM->Get_Cellsize() / 2; // Wert Flusskilomter der ersten Flussgitterboxmitte m_pRivGridCells->Set_Value(x, y, dist); // setzen der Kilometer bis zur Mitte der ersten Flussgitterbox while( !m_pDTM->is_NoData(x,y)) { i = m_pDTM->Get_Gradient_NeighborDir(x, y); if(i >= 0) { dist = dist + Get_Length(i); //bisheriger FlusskilometerWert + Weg zur nächsten Gitterboxmitte (abhängig ob Wasser diagonal oder rechtwinklig in nächste Gitterbox fließt) am Ende der Gridbox wird in FlussGitterbox geschrieben (!=0) x = Get_xTo(i, x); y = Get_yTo(i, y); if(!Parameters("Owrite")->asBool() && m_pRivGridCells->asDouble(x,y) != 0) //falls "überschreiben" nicht gesetzt, bricht Funktion ab sobald ein Grid != 0 erreicht wird. return(true); if(x == mx && y == my) { m_pRivGridCells->Set_Value(x, y, dist); // setzen der Kilometer bis zur Mitte der letzten Flussgitterbox DataObject_Update(m_pRivGridCells); return (true); } else m_pRivGridCells->Set_Value(x, y, dist); //FlusskilometerWert der nächsten Gridbox(mitte) wird in nächste FlussGitterbox i (ix,iy) geschrieben (!=0) DataObject_Update(m_pRivGridCells); } else return(false); } return (false); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_rivflow/GridComb.h0000664000175000017500000001070512565125410024415 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // GridComb.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GridComb_H #define HEADER_INCLUDED__GridComb_H //--------------------------------------------------------- #include //--------------------------------------------------------- //######################################################### class CGridComb : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CGridComb(void); // constructor protected: /// protected members and functions: /////////// virtual bool On_Execute (void); // always overwrite this function private: ///// private members and functions: ///////////// int sY, eY; int NX, NY; int m_pFvA; //Auswahlplatzhalter ob Wasserentnahme oder Wassernutzung berücksichtigt werden soll CSG_String m_pDataFolder; CSG_String SPath; CSG_Grid *m_pRefGrid; CSG_Grid *m_pGridComb; CSG_Grid *m_pDomW; CSG_Grid *m_pElecW; CSG_Grid *m_pLiveW; CSG_Grid *m_pManW; CSG_Grid *m_pIrrW; bool SaveParameters(); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GridComb_H saga-2.2.3/src/modules/simulation/sim_rivflow/Makefile.in0000664000175000017500000005534212622651173024635 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/simulation/sim_rivflow DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_rivflow_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_rivflow_la_OBJECTS = DataTrans.lo GridComb.lo LandFlow.lo \ MLB_Interface.lo RivBasin.lo RivCourseImpr.lo RivGridPrep.lo libsim_rivflow_la_OBJECTS = $(am_libsim_rivflow_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_rivflow_la_SOURCES) DIST_SOURCES = $(libsim_rivflow_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1537 2012-11-19 20:05:19Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_rivflow.la libsim_rivflow_la_SOURCES = \ DataTrans.cpp\ GridComb.cpp\ LandFlow.cpp\ MLB_Interface.cpp\ RivBasin.cpp\ RivCourseImpr.cpp\ RivGridPrep.cpp\ DataTrans.h\ GridComb.h\ LandFlow.h\ MLB_Interface.h\ RivBasin.h\ RivCourseImpr.h\ RivGridPrep.h libsim_rivflow_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) --foreign src/modules/simulation/sim_rivflow/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_rivflow/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_rivflow.la: $(libsim_rivflow_la_OBJECTS) $(libsim_rivflow_la_DEPENDENCIES) $(EXTRA_libsim_rivflow_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_rivflow_la_OBJECTS) $(libsim_rivflow_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DataTrans.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GridComb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LandFlow.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RivBasin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RivCourseImpr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RivGridPrep.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/simulation/sim_rivflow/RivCourseImpr.cpp0000664000175000017500000001472312565125410026037 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivCourseImpr.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "RivCourseImpr.h" #include //--------------------------------------------------------- //######################################################### CRivCourseImpr::CRivCourseImpr(void) { //----------------------------------------------------- // Modul information Set_Name ("GridManipulation"); Set_Author ("Christian Alwardt"); Set_Description ("Improve RiverCourse by MouseClicks"); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "Input1" , "Geländemodell (DTM)", "Digitales Geländemodell des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_Value( NULL, "diffH" , "Höhendifferenz", "Höhe in [m] um die der Wert der Zelle erniedrigt (positiver Wert) oder erhöht (negativer Wert) wird. ", PARAMETER_TYPE_Double, 1 ); Parameters.Add_Value( NULL, "true", "Zufluss aus Nachbarzellen erzwingen", "Der Zufluss aus allen Nachbarzellen - ausgenommen die Zelle in die Wasser abfließt - wird erzwungen. Hierbei wird die gewählte Zelle um obigen Höhendifferenzwert kleiner, als alle Nachbarzellen gesetzt.", PARAMETER_TYPE_Bool, false ); } bool CRivCourseImpr::On_Execute(void){ m_pDTM = Parameters("Input1")->asGrid(); m_pDiffH = Parameters("diffH")->asDouble(); return (true); } bool CRivCourseImpr::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { int iX, iY; //----------------------------------------------------- if( Mode != MODULE_INTERACTIVE_LDOWN || !Get_Grid_Pos(iX, iY) ) { return( false ); } double dValue = m_pDTM->asDouble(iX,iY); //Wert der ausgewählten Zelle if( Parameters("true")->asBool() ) { minVal = m_pDTM->asDouble(iX, iY); //minVal zunächst auf Wert der ausgwählten Zelle gesetzt int iN = m_pDTM->Get_Gradient_NeighborDir(iX, iY);//falls iN = -1 liegt Senke vor!! nX = Get_xTo(iN, iX);//Koordinaten der niedrigsten Nachbarzelle (ist niedriger als ausgewählte Zelle) nY = Get_yTo(iN, iY); double vN = m_pDTM->asDouble(nX, nY); //Wert der niedrigsten Nachbarzelle (ist niedriger als ausgewählte Zelle) double setVal; if(iN >= 0) { for(int i = 0; i < 7; i ++) { if(i != iN) getNeighFlowGridValue(iX, iY, minVal); } if(minVal > vN) { setVal = minVal - m_pDiffH; if(setVal <= vN ) setVal = minVal + ((minVal - vN) * 0.9999); } else { Message_Dlg("Achtung, eine Senke wurde generiert!", SG_T("caption")); setVal = minVal * 1.0001; } m_pDTM->Set_Value( iX, iY, setVal ); } else m_pDTM->Set_Value( iX, iY, minVal ); DataObject_Update(m_pDTM, SG_UI_DATAOBJECT_UPDATE_ONLY); } else { m_pDTM->Set_Value( iX, iY, dValue - m_pDiffH ); DataObject_Update(m_pDTM, SG_UI_DATAOBJECT_UPDATE_ONLY); } return (true); } void CRivCourseImpr::getNeighFlowGridValue(int x, int y, double kVal) { int i = m_pDTM->Get_Gradient_NeighborDir(x, y); int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if(i >= 0) { if( ix == nX && iy == nY) {} else { if (m_pDTM->asDouble(ix, iy) <= kVal) minVal = m_pDTM->asDouble(ix, iy); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_rivflow/GridComb.cpp0000664000175000017500000003251612565125410024754 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // GridComb.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "GridComb.h" #include #include #include #include #include #include using namespace std; //ACHTUNG ////////////////////////////////////////////////////////////////////// //ACHTUNG: Bisher keine Fehlerroutine, die auf unterschiedlich große InputGrids im DateiOrdner hinweist -> moegliche Fehlerursache!!! ////////////////////////////////////////////////////////////////////// //--------------------------------------------------------- //######################################################### CGridComb::CGridComb(void) { //----------------------------------------------------- // Modul information Set_Name ("GridCombination"); Set_Author ("Christian Alwardt"); Set_Description ("Grid Combination"); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT" , "Gelaendemodell (DTM)", "Digitales Gelaendemodell des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_FilePath( Parameters("GENERAL_NODE") , "Folder1", _TL("Pfad WaterGap Raster"), _TL("Ordnerpfad in dem alle zu bearbeitenden WaterGap Raster abgelegt sind"), _TL("SAGA Grid Files (*.sgrd)|*.sgrd|All Files|*.*"),0 ,false ,true ,false ); Parameters.Add_Value( NULL, "sY" , "Start-Jahr", "Jahr in dem die Gridoperation startet", PARAMETER_TYPE_Int, 1990, 1906, true, 2000, true ); Parameters.Add_Value( NULL, "eY" , "End-Jahr", "Jahr in dem der Verarbeitungsprozess enden soll", PARAMETER_TYPE_Int, 1990, 1906, true, 2000, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "DomW", "Domestic Water", "Beruecksichtigung der Domestic Water im resultieren Raster.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "ElecW", "Electricity Water", "Beruecksichtigung der Electricity Water im resultieren Raster.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "LiveW", "Livestock Water", "Beruecksichtigung der Livestock Water im resultieren Raster.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "ManW", "Manufacturing Water", "Beruecksichtigung des Manufacturing Water im resultieren Raster.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "IrrW", "Irrigation Water", "Beruecksichtigung des Irrigation Water im resultieren Raster (moeglicher Einheitenfehler im WaterGapDatensatz!!).", PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( Parameters("GENERAL_NODE") , "FvA" , _TL("Flaechenverbrauch-Auswahl (FvA)"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Resultierendes Raster ueber WasserENTNAHME erstellen"), _TL("Resultierendes Raster ueber WasserNUTZUNG erstellen") ), 0 ); } //--------------------------------------------------------- //######################################################### bool CGridComb::On_Execute(void) { //----------------------------------------------------- // Get the parameter settings... m_pRefGrid = Parameters("INPUT")->asGrid(); m_pDataFolder = Parameters("Folder1")->asString(); sY = Parameters("sY")->asInt(); eY = Parameters("eY")->asInt(); m_pGridComb = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pDomW = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pElecW = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pLiveW = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pManW = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pIrrW = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pFvA = Parameters("FvA")->asInt(); //Auswahlplatzhalter ob Wasserentnahme oder Wassernutzung beruecksichtigt werden soll //----------------------------------------------------- //Startdatum/Zeit erfassen time_t rawtime; struct tm * timeinfo; time (&rawtime); timeinfo = localtime (&rawtime); //----------------------------------------------------- //----------------------------------------------------- // Do something... //----------------------------------------------------- //SpeicherDateipfad (sfile) fuer diese Simulation wird generiert und entsprechender Ordner erstellt - Ordnerformat : ddmmyy_HHMM std::stringstream sPath0; sPath0.str(""); char buffer [20]; strftime(buffer,20,"%d%m%y_%H%M",timeinfo); sPath0 << m_pDataFolder.b_str() << "\\Total-" << "FvA" << m_pFvA << "-D" << Parameters("DomW")->asBool() << "E" << Parameters("ElecW")->asBool() << "L" << Parameters("LiveW")->asBool() << "M" << Parameters("ManW")->asBool() << "I" << Parameters("IrrW")->asBool() << "-" << buffer; std::string m_pSPath; m_pSPath = sPath0.str(); //Speicherdateipfad SG_Dir_Create(CSG_String(m_pSPath.c_str())); //Ordner wird erstellt SPath = m_pSPath.c_str(); //----------------------------------------------------- //----------------------------------------------------- //Fehlerroutine if((eY - sY) < 0) { Message_Dlg("Fehler: Das EndJahr liegt vor dem Startjahr"); return (false); } if( (m_pFvA == 0) && Parameters("LiveW")->asBool() ) Message_Dlg("Hinweis: Fuer den Livestock liegen nur Wassernutzungsdaten vor. Diese werden deshalb auch fuer die Kalkulation der Wasserentnahme herangezogen"); //----------------------------------------------------- NX = m_pRefGrid->Get_NX(); //Anzahl der Reihen x NY = m_pRefGrid->Get_NY(); //Anzahl der Zeilen y //----------------------------------------------------- //Jahresschleife for(int n = sY; n <= eY; n++ ) { if(Parameters("DomW")->asBool()) { CSG_String sDomW; if( m_pFvA == 0 ) sDomW.Printf(SG_T("%s/domwith_%d.sgrd"), m_pDataFolder.c_str(), n); else sDomW.Printf(SG_T("%s/domcon_%d.sgrd"), m_pDataFolder.c_str(), n); if(!m_pDomW->Create(sDomW)) m_pDomW->Assign(0.0); } if(Parameters("ElecW")->asBool()) { CSG_String sElecW; if( m_pFvA == 0 ) sElecW.Printf(SG_T("%s/elecwith_%d.sgrd"), m_pDataFolder.c_str(), n); else sElecW.Printf(SG_T("%s/eleccon_%d.sgrd"), m_pDataFolder.c_str(), n); if(!m_pElecW->Create(sElecW)) m_pElecW->Assign(0.0); } if(Parameters("LiveW")->asBool()) { CSG_String sLiveW; sLiveW.Printf(SG_T("%s/livecon_%d.sgrd"), m_pDataFolder.c_str(), n); if(!m_pLiveW->Create(sLiveW)) m_pLiveW->Assign(0.0); } if(Parameters("ManW")->asBool()) { CSG_String sManW; if( m_pFvA == 0 ) sManW.Printf(SG_T("%s/manwith_%d.sgrd"), m_pDataFolder.c_str(), n); else sManW.Printf(SG_T("%s/mancon_%d.sgrd"), m_pDataFolder.c_str(), n); if(!m_pManW->Create(sManW)) m_pManW->Assign(0.0); } if(Parameters("IrrW")->asBool()) { CSG_String sIrrW; //----------------------------------------------------- //Im Fall von IrrigationData -> extra Monatsschleife //####ACHTUNG!!###### //Annahme, dass die Einheit fuer IrrigationData falsch angegebn ist und in Wirklichkeit und m3/month betraegt, //deshalb wird durch (86400*30) getielt um Einheit m3/s zu erhalten - siehe unten !! for(int i=0; i<12; i++) { if( m_pFvA == 0 ) sIrrW.Printf(SG_T("%s/PIrrWW_%d_%d.sgrd"), m_pDataFolder.c_str(), n, i+1); else sIrrW.Printf(SG_T("%s/PIrrUse_%d_%d.sgrd"), m_pDataFolder.c_str(), n, i+1); if(!m_pIrrW->Create(sIrrW)) m_pIrrW->Assign(0.0); for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if(m_pRefGrid->is_NoData(x,y)) m_pGridComb->Set_NoData(x,y); else { m_pGridComb->Set_Value(x, y, (m_pDomW->asDouble(x,y) + m_pElecW->asDouble(x,y) + m_pLiveW->asDouble(x,y) + m_pManW->asDouble(x,y) + ( m_pIrrW->asDouble(x,y) / 86400 / 30 ) )); //Monitoring: double a = m_pDomW->asDouble(x,y); double b = m_pElecW->asDouble(x,y); double c = m_pLiveW->asDouble(x,y); double d = m_pManW->asDouble(x,y); double e = ( m_pIrrW->asDouble(x,y) / 86400 / 30 ); // } } } CSG_String SaveAsFile; SaveAsFile.Printf(SG_T("%s/TotalWUse_%d_%d.sgrd"), SPath.c_str(), n, i+1); m_pGridComb->Save(SaveAsFile); } //----------------------------------------------------- } else { for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if(m_pRefGrid->is_NoData(x,y)) m_pGridComb->Set_NoData(x,y); else m_pGridComb->Set_Value(x, y, (m_pDomW->asDouble(x,y) + m_pElecW->asDouble(x,y) + m_pLiveW->asDouble(x,y) + m_pManW->asDouble(x,y)) ); } } CSG_String SaveAsFile; SaveAsFile.Printf(SG_T("%s/TotalWUse_%d.sgrd"), SPath.c_str(), n); m_pGridComb->Save(SaveAsFile); } } //----------------------------------------------------- SaveParameters(); delete(m_pDomW); delete(m_pElecW); delete(m_pLiveW); delete(m_pManW); delete(m_pIrrW); delete(m_pGridComb); //----------------------------------------------------- // Return 'true' if everything is okay... return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGridComb::SaveParameters() { int i = 0; int d = NX * NY; time_t rawtime; time(&rawtime); CSG_String sSaveFile; sSaveFile.Printf(SG_T("%s/Parameters.txt"), SPath.c_str() ); fstream myfile; myfile.open(sSaveFile.b_str(), ios::out|ios::trunc); myfile << "Einstellungen der Grid-Kombination." << "\n\n"; myfile << "Timestamp: " << ctime(&rawtime) << "\n\n"; myfile << "Einstellungen:\n\n"; myfile << "StartJahr = " << sY << "\n"; myfile << "EndJahr = " << eY << "\n\n"; myfile << "DomW: " << Parameters("DomW")->asBool() << "\n"; myfile << "ElecW: " << Parameters("ElecW")->asBool() << "\n"; myfile << "LiveW: " << Parameters("LiveW")->asBool() << "\n"; myfile << "ManW: " << Parameters("ManW")->asBool() << "\n"; myfile << "IrrW: " << Parameters("IrrW")->asBool() << "\n\n"; myfile << "FlaechennutzungsAuswahl - WaterWithdrawl [=0] oder WaterConsumption[=1]:" << m_pFvA << "\n\n"; myfile << "SpeicherDateipfad: " << sSaveFile.b_str() << "\n\n"; myfile.close(); return true; } saga-2.2.3/src/modules/simulation/sim_rivflow/DataTrans.cpp0000664000175000017500000001326712565125410025151 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // DataTrans.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "DataTrans.h" #include #include #include "stdio.h" #include #include #include "stdlib.h" #include using namespace std; #define ESC 27 //--------------------------------------------------------- //######################################################### CDataTrans::CDataTrans(void) { //----------------------------------------------------- // Modul information Set_Name ("DataTrans"); Set_Author ("Christian Alwardt"); Set_Description ("DataOperations"); //Parameters list... Parameters.Add_Grid_List( Parameters("SOURCE_NODE"), "SOURCE1" , SG_T("RunOff"), SG_T(""), PARAMETER_INPUT, false ); Parameters.Add_Grid_List( Parameters("SOURCE_NODE"), "SOURCE2" , SG_T("Drainage"), SG_T(""), PARAMETER_INPUT, false ); } //######################################################### //--------------------------------------------------------- //######################################################### bool CDataTrans::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Grid_List *pSources1 = Parameters("SOURCE1")->asGridList(); //RunOff Liste CSG_Parameter_Grid_List *pSources2 = Parameters("SOURCE2")->asGridList(); //Drainage Liste if( pSources1->Get_Count() > 0 && pSources2->Get_Count() > 0) { if( pSources1->Get_Count() == pSources2->Get_Count()) { m_pID = pSources1->Get_Count(); for(i=0; i < pSources1->Get_Count(); i++) { pSource1 = pSources1->asGrid(i); pSource2 = pSources2->asGrid(i); Set_TFile(pSource1, pSource2); } } else Message_Dlg("Achtung, Anzahl der Einträge stimmt nicht überein"); } delete(pSources1); delete(pSources1); return(true); } bool CDataTrans::Set_TFile(CSG_Grid *pSource1, CSG_Grid *pSource2) { if( pSource1->Get_NX() == pSource2->Get_NX() && pSource1->Get_NY() == pSource2->Get_NY()) { NX = pSource1->Get_NX(); NY = pSource1->Get_NY(); fstream myfile; std::stringstream file0; std::string file; //LandSurfaceModell-Daten //----------------------------------------------------- file0.str(""); file0 << "dataTemp/lsMData-Day" << i+1 << ".txt"; file = file0.str(); myfile.open(file.c_str(), ios::out|ios::trunc); for(int x = 0; x < NX; ++x) { for(int y = 0; y < NY; ++y) { myfile << x << " " << y; myfile << " " << pSource1->asDouble(x,y) << " " << pSource2->asDouble(x,y); myfile << "\n"; } } myfile.close(); Process_Set_Text(CSG_String::Format(SG_T("GridSave || Datensatz %d geschrieben"),i+1)); } return(true); } saga-2.2.3/src/modules/simulation/sim_rivflow/RivGridPrep.h0000664000175000017500000001036612565125410025127 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivGridPrep.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__RivGridPrep_H #define HEADER_INCLUDED__RivGridPrep_H //--------------------------------------------------------- #include //--------------------------------------------------------- //######################################################### class CRivGridPrep : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CRivGridPrep(void); // constructor protected: /// protected members and functions: /////////// virtual bool On_Execute (void); // always overwrite this function private: ///// private members and functions: ///////////// CSG_Grid *m_pDTM, *m_pRivGridCells; int m_pSX, m_pSY, m_pMX, m_pMY; bool Set_RivGridCells(int sx, int sy, int mx, int my ); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__RivGrids_H saga-2.2.3/src/modules/simulation/sim_rivflow/LandFlow.h0000664000175000017500000003261612565125410024442 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // LandFlow.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__LandFlow_H #define HEADER_INCLUDED__LandFlow_H //--------------------------------------------------------- #include #include using namespace std; //--------------------------------------------------------- //######################################################### class CLandFlow : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CLandFlow(void); // constructor protected: /// protected members and functions: /////////// virtual bool On_Execute (void); // always overwrite this function private: ///// private members and functions: ///////////// /// Members //Grids CSG_Grid *m_pDTM; CSG_Grid *m_pGrad; CSG_Grid *m_pDirec; CSG_Grid *m_pRFlow; CSG_Grid *m_pDFlow; CSG_Grid *m_pWConsIn; //statisches WaterConsumption Grid in [kg m-2 s-1] CSG_Grid *m_pWConsOut; //dynamisch generiertes WaterConsumption Grid in [kg m-2 s-1] CSG_Grid *m_pCCacheIn; CSG_Grid *m_pRCacheIn; CSG_Grid *m_pDCacheIn; CSG_Grid *m_pCCacheOut; CSG_Grid *m_pRCacheOut; CSG_Grid *m_pDCacheOut; CSG_Grid *m_pTempR; CSG_Grid *m_pTempC; CSG_Grid *m_pTempD; CSG_Grid *m_pChannelFlow; CSG_Grid *m_pSumRunoffDrainage; CSG_Grid *m_pTemp; CSG_Grid *m_pTempK; CSG_Grid *m_pRivGrids; CSG_Grid *m_pRivGrad; CSG_Grid *m_pBasinShare; CSG_Grid *m_pRivBalanceGrid; CSG_Grid *m_pNumInFlow; CSG_Grid *m_pSumCon; //eigentliche Entnahme CSG_Grid *m_pSumResCon; //resultierende Entnahme CSG_Grid *m_pSumRemCon; //nicht berücksichtigte Entnahmen CSG_Grid *m_pTestR1Share; //gesammtes Einzugsgebiet zu HG-Rasterzelle (x,y) der TestR1 Routine CSG_Grid pWConsData; CSG_String m_pWConsFile; CSG_String m_pLSDataFolder; CSG_String m_pDataSaveFolder; CSG_String m_pWConDataFolder; CSG_String m_pNCacheFolder; CSG_String m_pDateipfad; //CSG_String m_pLSData26File; //CSG_String m_pLSData27File; CSG_String m_pEvP1s; CSG_String m_pEvP2s; CSG_String m_pEvP3s; std::string m_pSPath; std::string m_pSPath2; std::string m_pSPath3; //std::string m_pLPath; //Int int m_pDays; //Festgelegte Anzahl an Simulationstagen (Input Parameter) int nC; //Anzahl der Speicherkaskaden des ChannelFlow Speichers int nCr; //Anzahl der Speicherkaskaden des ChannelFlow River-Speichers int nMax; int nG; int NX; int NY; int dC; //dayCounter - Tageszähler [d] int dDC; //dayDataCounter - Datentag-Zähler [d] (1-365/366) int mYC; //MonthOfYear Monatszähler (1-12) int dMC; //DayOfMonth Tageszähler [d] (1-28/29/30/31) int m_pDDays; int m_pTStep; //Zeitschrittlänge dt int errC; int errC2; int errC3; int errC4; int m_sYear0; int m_sYear; int m_pWConsD; // verbleibende Tage bevor Entnahme (Operator) es gilt: m_pWConsD <= m_pWConsDIn, m_pWConsD-- int m_pWConsDIn; // Tage bevor jedwede Entnahme beginnt (Input-Variable) int numTS; // Anzahl der Zeitschritte pro Tag int NumRBGrids; //Anzahl der Rasterzellen im Flusseinzugsgebiet int NumGrids; //Anzahl der Rasterzellen des DTM (ohne NoDataValues) int NumGridsTestR1; //Anzahl der Rasterzellen des Teileinzugsgebietes der TestRoutine1 int var1; //Programmvariable : Prozentuale Wasserentnahme initiieren int var2; //Programmvariable : Testlog 1 int var3; //Programmvariable : Testlog 2 int var4; //Programmvariable : //double double cVers; //Compelierungs-Version double m_pGFlow; double m_pCFlow; double m_pBFlow; double m_pRun; double m_pDrain; double m_pVTresh; double k_Min; double kMinG; double kMinC; double kMinCr; double kMinB; double vMaxC; double vMaxCr; double vMaxG; double vMax; double dT; //daytimeCounter - Tageszeitzähler [s] double G0; double C0; double C0r; //Parameter für ChannelFlow im River [optional] double pB; double m_pCon; //Flächenbasierte Entnahmen (absoluter Wert) double m_pConsFacAll; //Entnahmefaktor aus Gitterboxen [%]/[dt] double m_pConsFacRiv; //Entnahmefaktor aus Fluss-Gitterboxen [%]/[dt] double m_pRedFacR; //Reduzierungsfaktor RunOff [%]/[dt] double m_pRedFacD; //Reduzierungsfaktor Drainage [%]/[dt] double m_pHFlowFac; //Weiterleitungsfaktor des Abfluss aus Gitterboxen in % des tatsächlichen Abflusses double m_pRFlowFac; //Weiterleitungsfaktor des Fluss-Gitterboxen in % des tatsächlichen Abflusses double m_pVRFlowFac; //reduzierter vertikaler Zufluss (Runnoff) in % des tatsächlichen RunOff-Zuflusses double m_pVDFlowFac; //reduzierter vertikaler Zufluss (Drainage) in % des tatsächlichen Drainage-Zuflusses double m_pFlowFac; //Abfrageplatzhalter für m_pHFlowFac oder m_pRFlowFac double m_pTest; double stCons; double varCons; double SumRDMonth; //Summe der Runoff und Drainage Werte des Einzugsgebietes eines Monats double SumRMonth; //NUR Summe der Runoff-Werte des Einzugsgebietes eines Monats double SumDMonth; //NUR Summe der Drainage-Werte des Einzugsgebietes eines Monats double SumRD_SubBasin; //Summe der Runoff und Drainage Werte eines SubBasin [TestRoutine 1] double SumCon_SubBasin; //Summe der beabsichtigten Entnahmen eines SubBasin [TestRoutine 1] double SumResCon_SubBasin; //Summe der tatsächlichen Entnahmen eines SubBasin [TestRoutine 1] double SumRemCon_SubBasin; //Summe der nicht berücksichtigten Entnahmen eines SubBasin [TestRoutine 1] double m_pTestR1; //SpeicherVariable TestRoutine 1 double m_pTestR1m; //SpeicherVariable TestRoutine 1 double m_pTestR1RDm; //SpeicherVariable TestRoutine 1 double m_pTestR1Cm; //SpeicherVariable TestRoutine 1 double m_pTestR1resCm; //SpeicherVariable TestRoutine 1 double m_pTestR1remCm; //SpeicherVariable TestRoutine 1 double m_pWConThres; //Schwellenwert für HG-Abfluss der auch bei Entnahmen nicht unterschritten werden soll double m_pOffsetR; //Offsetwert auf den vertikalen Zufluss 'RunOff' pro Rasterzelle in m³/s double m_pOffsetD; //Offsetwert auf den vertikalen Zufluss 'Drainage' pro Rasterzelle in m³/s double WSystemDayWithd; //Summe allen Wassers, dass dem WSystem pro Tag entnommen wird oder über Entnahmefaktor verloren geht double WSystem; // Im System befindliches Wasser double WSystemInit; // Anfänglicher Speicherinhalt WSystem nach Speicherinitilisierung double WSystemIn; // Summe des Wassers was ins System gelangt (Drainage, RunOff) double WSystemOut; // Summe des Wassers welches das System verläßt (Systemabfluss) double WSystemDayIn; // Summe des Wassers was am jeweiligen Tag ins System gelangt (Drainage, RunOff) double WSystemDayOut; // Summe des Wassers welches am je weiligenTag das System verläßt (Systemabfluss) double RivBas; // Im RivBasin befindliches Wasser double RivBasInit; // Anfänglicher Speicherinhalt RivBasin nach Speicherinitilisierung double RivBasIn; // Summe des Wassers was ins RiverBasin gelangt (Drainage, RunOff) double RivOut; // Summe des Wassers welches das RiverBasin über den Fluss verläßt (Flussabfluss) double RivBasDayIn; // Summe des Wassers was am jeweiligen Tag ins RiverBasin gelangt (Drainage, RunOff) double RivDayOut; // Summe des Wassers welches am jeweiligen Tag das RiverBasin über den Fluss verläßt (Flussabfluss) double RivMonthOut; // Summe des Wassers welches im jeweiligen Monat das RiverBasin über den Fluss verläßt (Flussabfluss) double WCCache; // Speicherabbild des Wassers in den Kaskaden Speichern double RivBasSink; // Summe allen Wasser das über dem Rechenzeitraum im RivBas in Senken verschwindet (gelöscht wird) double RivBasDayWithd; // Summe allen Wassers, dass dem RivBasin pro Tag entnommen wird oder über Entnahmefaktor verloren geht double RivBasConMonth; // Summe der auftretenden Flächenentnahmen innerhalb des gesamten Flusseinzugsgebietes pro Monat double resRivBasConMonth; // Summe der tatsächlichen durchgeführten Flächenentnahmen innerhalb des gesamten Flusseinzugsgebietes pro Monat double remRivBasConMonth; // Summe der Entnahmen die dem RivBasin nicht entnommen werden konnten (weil resFlow kleiner als m_pCon) pro Monat double manWithd; // Wasser das durch Rasterzellen Manipulation aus dem RivBasinSystem entfernt oder hinzugefügt wurde double ***kArray; double ***nCArray; //Array von n-ChannelFlow-Speichern je (x,y) Koordinate double ***lsMArray; double ***pArray; /// Functions void Calc_MainFlow(int x, int y); double Calc_GFlow(int x, int y, double f); double Calc_CFlow(int x, int y, double f, int n); double Calc_BFlow(int x, int y, double f); double CalcRet(double f, int n); bool SubBasinId(int x, int y); //Funktion gibt aus dem m_pSumRunoffDrainage-Raster die Summe der RunOff und Drainage Werte aller Rasterzellen des Teileinzugsgebiets der Flussrasterzelle (x,y) bool WConsRiv(int i); void TestR1Share(int HGx, int HGy); void InitKArray(); void InitNcArray(int p1, int p2, int p3); //Array von n-Speichern je (x,y) Koordinate void InitPArray(int p1, int p2, int p3); void CreateKArray(int p1, int p2, int p3); void CreateLSMArray(int p1, int p2, int p3); void CreateNcArray(int p1, int p2, int p3); void CreatePArray(int p1, int p2, int p3); void DeleteKArray(); void DeleteLSMArray(); void DeleteNcArray(); void DeletePArray(); double ReadNCacheFile(bool p0, string s1, int p1, int p2, int p3, int p4, int p5, char p6, int p7, bool p8); double ReadLSMCacheFile(bool p0, string s1, int p1, int p2, int p3, int p4, int p5, char p6, int p7, bool p8); // double ReadDNCacheFile(bool p0, string s1, int p1, int p2, int p3, int p4, int p5, char p6, int p7, bool p8); bool SaveNcCache(int n); bool SaveParameters(); bool WriteLog(string s); bool TestLog1(string s); bool TestLog2(string s); bool TestLog3(string s); bool TestLog4(string s); bool WriteOutput(string s, double p1, double p2, int x, int y); bool WriteRivBalance(int i1, int i2, double p1, double p2); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__LandFlow_Hsaga-2.2.3/src/modules/simulation/sim_rivflow/RivBasin.cpp0000664000175000017500000005377512565125410025015 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivBasin.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "RivBasin.h" #include #include #include //ACHTUNG ////////////////////////////////////////////////////////////////////// //Das Schreiben von Koordinaten als Gridboxwert ist zur // //Zeit auf VIER Stellen beschraenkt -> DoubleFormat == [XXXXYYYY] // //Bei der Programmierung beruecksichtigen!!! // // // ////////////////////////////////////////////////////////////////////// //--------------------------------------------------------- //######################################################### CRivBasin::CRivBasin(void) { //----------------------------------------------------- // Modul information Set_Name ("RiverBasin"); Set_Author ("Christian Alwardt"); Set_Description ("Parameters of RiverBasin"); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT" , "DTM", "Digitales Gelaendemodell des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT2" , "HGGrid", "Eingaberaster der Hauptgerinnerasterzellen des Flussnetzwerkes", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT3" , "statisches Entnahmeraster", "Eingaberaster mit Angaben zur statischen Flaechenwasserentnahme.", PARAMETER_INPUT_OPTIONAL //Jahreswerte //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Value( NULL, "WCons", "Anteilige Flaechenwasserentnahme", "Wenn gesetzt, werden die Werte des statischen Entahmerasters anteilig entnommen und als Raster statWUse ausgegeben", PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( Parameters("WTHD_NODE") , "WCons2" , _TL("Dynamische Flaechenwassernutzung..."), _TL("Auswahl der Art der anteiligen Flaechenwasserwasserentnahme."), CSG_String::Format(SG_T("%s|%s"), _TL("...anteilig aus den Flussrasterzellen"), _TL("...anteilig aus Rasterzellen der Teileinzugegebiete") ), 0 ); Parameters.Add_Grid( NULL, "OUTPUT2" , "Grad", "Ausgabe der Abflussgradienten jeder Rasterzelle", PARAMETER_OUTPUT ); // Gradient in Abflussrichtung Parameters.Add_Grid( NULL, "OUTPUT3" , "Direc", "Ausgabe der Abflussrichtung fuer jede Rasterzelle", PARAMETER_OUTPUT ); // Flussrichtung 0-7 // 7|0 |1 // 6|-1|2 // 5|4 |3 Parameters.Add_Grid( NULL, "OUTPUT4" , "HGGrad", "Ausgabe der Abflussgradienten jeder Hauptgerinnerasterzelle", PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "OUTPUT5" , "RivSpeed", "Ausgabe Flussgeschwindigkeiten der Hauptgerinnerasterzellen (siehe Parametereinstellungen)", PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "OUTPUT6" , "Coordinates", "Ausgabe der Koordinatenwerte der Rasterzellen im Format xxxx.yyyy", PARAMETER_OUTPUT ); // Konvention des Rasterzahlenwertes: xxxx.yyyy [x,y-Koordinate] Parameters.Add_Grid( NULL, "OUTPUT7" , "BasinShare", "Ausagbe der Rasterzellen des Flusseinzugsgebiets", PARAMETER_OUTPUT ); // Grids die in Fluss mueden [>0 = Flussgridkoordinate] , Flussgrids [=0] , keine Flussgrid [-1] Parameters.Add_Grid( NULL, "OUTPUT8" , "statWUse", "Ausagbe der anteiligen Flaechenwasserentnahme je Rasterzelle", PARAMETER_OUTPUT_OPTIONAL ); // Flussgrids [>=0] , keine Flussgrid [-1] Parameters.Add_Grid( NULL, "OUTPUT9" , "NumInFlowCells", "Ausgaberaster mit Angabe ueber die Anzahl der Rasterzellen, die in eine spezifische Rasterzelle (x,y) abflieszen", PARAMETER_OUTPUT ); Parameters.Add_Value( NULL, "pCr" , "Hauptgerinne-Parameter pHG", "Parameter pHG zur Berechnung der Lagtime kHG des Hauptgerinneabflusses", PARAMETER_TYPE_Double, 0.0035, 0, true ); Parameters.Add_Value( NULL, "nCr" , "Hauptgerinne-Speicherkaskade nHG", "Festlegen, wieviele Speicher die ChannelFlow River-Speicherkaskade enthaelt", PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "EnfVmax", "Maximal Geschwindigkeit des Hauptgerinnes beruecksichtigen", "Angegebene Maximalgeschwindigkeit im Hauptgerinne bei der Berechnung der durchschnittlichen Flieszgeschwindigkeit des Hauptgerinnes beruecksichtigen.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "VTresh" , "Maximalgeschwindigkeit im Hauptgerinne in km/h", "Festlegung der maximalen Wasserflussgeschwindigkeit im Hauptgerinne in km/h (oberer Grenzwert)", PARAMETER_TYPE_Double, 4, 0, true, 10, true //Achtung!! Obergrenze statisch eingestellt ); } //--------------------------------------------------------- //######################################################### bool CRivBasin::On_Execute(void) { int x, y; BasinGrids = 0; statV = 0; statN = 0; //----------------------------------------------------- // Get the parameter settings... m_pDTM = Parameters("INPUT")->asGrid(); m_pRivGrids = Parameters("INPUT2")->asGrid(); m_pWCons = Parameters("INPUT3")->asGrid(); //statisches WaterConsumption Grid (Jahreswerte) in [kg m-2 s-1] m_pGrad = Parameters("OUTPUT2")->asGrid(); m_pDirec = Parameters("OUTPUT3")->asGrid(); m_pRivGrad = Parameters("OUTPUT4")->asGrid(); //Gibt Grid aus, welches nur die Werte des Flussgefaelles enhaelt -> damit spaeter auschlieszliche Berechnug des max Flussgefaelles moeglich m_pRSpeed = Parameters("OUTPUT5")->asGrid(); m_pRaster = Parameters("OUTPUT6")->asGrid(); m_pBasinShare = Parameters("OUTPUT7")->asGrid(); m_pSharedRivCons = Parameters("OUTPUT8")->asGrid(); m_pNumInFlowCells = Parameters("OUTPUT9")->asGrid(); pCr = Parameters("pCr")->asDouble(); nCr = Parameters("nCr")->asInt(); m_pVTresh = Parameters("VTresh")->asDouble(); // [km/h] //----------------------------------------------------- // Do something... m_pGrad->Assign(0.0); m_pDirec->Assign(-1.0); m_pRivGrad->Assign(0.0); m_pRSpeed->Assign(0.0); m_pNumInFlowCells->Assign(0.0); m_pBasinShare->Assign(-1.0); // Vorab Werte -1 (kein Flussbasin); Wenn Grid in Fluss muendet > 0 (entspricht Koordinate) oder =0 wenn Flussgrid (>=0 entspricht Flussbasin) if(m_pSharedRivCons) m_pSharedRivCons->Assign(0.0); for(x=0; x < m_pDTM->Get_NX(); x++) { for(y=0; y < m_pDTM->Get_NY(); y++) { double r = x + 0.0001*y; // Konvention des Rasterzahlenwertes: xxxx.yyyy [x,y-Koordinate] m_pRaster->Set_Value(x, y, r); if(m_pDTM->is_NoData(x,y)) { m_pGrad->Set_NoData(x,y); m_pDirec->Set_NoData(x,y); m_pRivGrad->Set_NoData(x,y); } else Set_RivParam(x,y); } } //Durchnittsgeschwindigkeit in Log-Datei schreiben double res = statV / statN; std::stringstream lStr0; std::string lStr; lStr0.str(""); lStr0 << "Durschnittsgeschwindigkeit fuer pHG = " << pCr << ": " << res; lStr = lStr0.str(); WriteLog(lStr); //------------------------------------------------ if(!CRivBasin::Set_BasinShare()) //SetBasin Aufruf Message_Dlg("Achtung, Fehler beim Erzeugen der Flussabhaengigen-Anteile wegen nicht gesezter FlussGrids"); if( !m_pRivGrids ) { m_pRivGrad->Destroy(); m_pRSpeed->Destroy(); m_pNumInFlowCells->Destroy(); m_pBasinShare->Destroy(); } if( (!m_pWCons || !m_pRivGrids) && m_pSharedRivCons) m_pSharedRivCons->Destroy(); //----------------------------------------------------- // Return 'true' if everything is okay... return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CRivBasin::Set_RivParam(int x, int y) { int i, ix, iy; double z, dzMax, l; z = m_pDTM->asDouble(x,y); dzMax = 0.0; i = m_pDTM->Get_Gradient_NeighborDir(x, y); if( i >=0) { ix = Get_xTo(i, x); //x-Wert niedrigste Nachbarzelle iy = Get_yTo(i, y); //y-Wert niedrigste Nachbarzelle l = Get_Length(i); //Weg Mittelpunkt Gitterbox (x,y) nach Gitterboxmitte (ix,iy) dzMax = (z - m_pDTM->asDouble(ix, iy)) / l; //Steigung dz/l entspricht tan(Steigungswinkel) ->Gefaelle in Abflussrichtung } else // Senke!! dzMax = 0; if( m_pRivGrids && m_pRivGrids->asDouble(x,y) != 0) // Wenn bei (x,y) Flussgrid vorliegt... { double vMax2 = pow(dzMax, 0.1 ) / pCr / nCr / 24; //--- Werte zur Berechnung der Durchschnittsgeschwindigkeit im HG erfasse if(Parameters("EnfVmax")->asInt() && vMax2 > m_pVTresh) statV = statV + m_pVTresh; //Falls vMax2 groeszer als Geschwindigkeitsgrenze m_pVTresh, auf m_pVTresh setzten else statV = statV + vMax2; statN = statN + 1; //------------------------- m_pRivGrad->Set_Value( x, y, dzMax ); //Flussbezogene Grids: Flussgefaelle; (x,y) nach (ix,iy) -> Extra RivGrad-Grid das nur die Gradienten der Fluss-Rasterzellen enthaelt, damit in LandFlow einfach der MaximalGradient bzw. kmin der Fluss-Rasterzellen bestimmt werden kann ??? m_pRSpeed->Set_Value(x, y, vMax2); //Flussbezogene Grids: Flieszgeschwindigkeit der Flussgrids (lt. vorgegebenen pCr und nCr); (x,y) nach (ix,iy) m_pGrad->Set_Value( x, y, dzMax); //Allgemeine Grids: Flussgefaellewert wird auch in der allgemeinen Gefaelledatei gesetzt; (x,y) nach (ix,iy) m_pDirec->Set_Value( x, y, i); //Allgemeine Grids: Flieszrichtung Gitterbox; (x,y) nach (ix,iy) } else { m_pGrad->Set_Value( x, y, dzMax); //Allgemeine Grids: Flussgefaellewert wird gesetzt; (x,y) nach (ix,iy) m_pDirec->Set_Value( x, y, i); //Allgemeine Grids: Flieszrichtung Gitterbox; (x,y) nach (ix,iy) } } //--------------------------------------------------------- //######################################################### bool CRivBasin::Set_BasinShare(void) //Fuer alle Werte innerhalb des RiverBasin gilt: Riverbox: Wert==0, Zuflussbox: Wert==>>Riverbox-Koordinate [xxxxyyyy] || alle Boxen Ausserhalb RiverBasin: Wert==-1 { if(m_pRivGrids) { m_pNumInFlowCells->Assign(0.0); int NX = m_pDTM->Get_NX(); //Anzahl der Reihen x int NY = m_pDTM->Get_NY(); //Anzahl der Zeilen y double CellNum0 = 0; double CellNum = 0; int x, y; int i = -1; //Gesamt-Flusseinzugsgebiet und einzelne Flussrasterzelleneinzuggebiete bestimmen und jeweilige Koordinate der Ziel-Flussrasterzelle setzten //--------------------------------------------------------- for(int l=0; l < m_pDTM->Get_NCells() && Set_Progress_NCells(l); l++) //ueber alle Zellen des m_pDEM-Grids { m_pDTM->Get_Sorted(l, x, y); //sortieren der Zellen von hoechster (l=0) nach niedrigster... CellNum = 1; //Initialisierung der Zaehlung "vorherigerNachbarzellen" fuer erste Nachbarzelle (falls folgende if-Bedingung nicht erfuellt -> "gegenstandlos") CellNum0 = 0; //Erster Durchlauf: Zu "Gipfelzelle l" wird anhand des Abflusses die Muendungszelle im Flussgrid bestimmt (entspricht dem (x,y) fuer das gilt: m_pRivGrids->asDouble(x,y) != 0 )... if(m_pNumInFlowCells->asDouble(x,y) == 0 && !m_pDTM->is_NoData(x,y)) //starten nur wenn Gipfelzelle (enstspricht: m_pNumInputCells->asDouble(x,y) == 0); falls != gab es schon eine Zelle die hoeher war u damit wurde der Zweig schon abgegangen { while( !m_pDTM->is_NoData(x,y) && m_pRivGrids->asDouble(x,y) == 0 ) { i = m_pDTM->Get_Gradient_NeighborDir(x, y); if(i >= 0) //es gibt eine niedrigere Nachbarzelle... { x = Get_xTo(i, x); y = Get_yTo(i, y); if(m_pNumInFlowCells->asDouble(x,y) <= 0) //Wenn Null -> erstes Durchlaufen dieses Astes -> immer plus 1 fuer Naechstebarchbarzelle { CellNum0 = CellNum; CellNum = CellNum + 1; } else //Ast wurde vorher schon durchlaufen -> vorherige DurchlaufWerte plus die statische Anzahl der Zellen (CellNum) des noch nicht durchlaufenden Astabschnittes CellNum0 = m_pNumInFlowCells->asDouble(x,y) + CellNum; m_pNumInFlowCells->Set_Value(x, y, CellNum0); //Anzahl voheriger Zellen im Abflusverlauf werden gesetzt... vorher bereits Durchlaufene "aeste" sind beruecksichtigt } else //Senke liegt vor { CellNum0 = m_pNumInFlowCells->asDouble(x,y) * -1; m_pNumInFlowCells->Set_Value(x, y, CellNum0); break; } } // Bei Zelle (x,y) handelt es sich nun um eine Flussrasterzelle oder eine Senke... if(m_pRivGrids->asDouble(x,y) != 0) //Wenn es eine Flussrasterzelle (also Muendungszelle) ist, Wert fuer alle alle Flaechenrasterzellen setzen, die in die Flussrasterzelle (x,y) muenden { m_pBasinShare->Set_Value(x, y, 0); //Muendungsrasterzelle wird auf Null gesetzt //KoordinatenDouble erzeugen FORMAT: xxxxyyyy double r = 0; int u = 10000*x + y; // r = u; //Wert der gesetzt wird : FORMAT: xxxxyyyy (Koordinate der "Ziel"Flussgridbox in die voherige Gitterboxen muenden) m_pDTM->Get_Sorted(l, x, y); //selber Durchlauf nochmal; von der l-ten Gridbox bis Ziel-Flussfgridbox //Zweiter Durchlauf: Wiederum bei "Gipfelzelle l" beginnend wird nun fuer alle Gitterzellen auf dem Weg zur Muendungszelle der KoordinatenWert r gesetzt while( !m_pDTM->is_NoData(x,y) && m_pRivGrids->asDouble(x,y) == 0 ) { i = m_pDTM->Get_Gradient_NeighborDir(x, y); if(i >= 0) { m_pBasinShare->Set_Value(x, y, r); //Koordinaten der Ziel-Flussgridbox werden gesetzt x = Get_xTo(i, x); y = Get_yTo(i, y); } else {break;} //Nur fuer den Fall; i = -1 sollte eigentlich nicht mehr moeglich sein, da letzte Gridbox ja Flussgridbox... } } else {} } if(m_pDTM->is_NoData(x,y)) { m_pNumInFlowCells->Set_NoData(x,y); m_pBasinShare->Set_NoData(x,y); } } //--------------------------------------------------------- //######################################################### //----------------------------------------------------- // Anzahl der Gridboxes des Einzugsgebietes zaehlen: for(x=0; x < NX; x++) { for(y=0; y < NY; y++) { if(!m_pDTM->is_NoData(x,y) && m_pBasinShare->asDouble(x,y) != -1) BasinGrids++; } } //----------------------------------------------------- //Absolute Entnahmen in den Flussrasterzellen-Einzugsgebieten (Teileinzugsgebiet) berechnen und dort anteilig entnehmen if(Parameters("WCons")->asBool() && m_pWCons && m_pSharedRivCons) { for(x=0; x < NX; x++) { for(y=0; y < NY; y++) { if(!m_pDTM->is_NoData(x,y) && m_pRivGrids->asDouble(x,y) > 0 ) { // Wenn Flussrasterzelle... int sx = 0; int sy = 0; double sum = 0; //Summe der Rasterzellen des Teileinzuggebiets (ohne Flussrasterzelle) int u; double r = 0; double conSum = 0; //Summe der Verbrauchswerte des Teileinzugsgebiets double conShare = 0; //Berechnen der anteiligen Entnahme der Flussrasterzelle / Rasterzellen double cellShare = 0; //Summe aller InFlowCell-Werte des Teileinzuggebiets double testSum = 0; conSum = m_pWCons->asDouble(x, y); //Summe der Verbrauchswerte des Teileinzugsgebiets (hier Flussrasterzelle) cellShare = m_pNumInFlowCells->asDouble(x, y); //Summe aller InFlowCell-Werte des Teileinzuggebiets (hier Flussrasterzelle) //KoordinatenDouble der derzeitigen Flussrasterzelle erzeugen - FORMAT: xxxxyyyy u = 10000*x + y; r = u; //alle Rasterzellen finden die in die Flussrasterzelle muenden for(int sx=0; sx < NX; sx++) { //#pragma omp parallel for //TEST hier nicht anwendbar for(int sy=0; sy < NY; sy++) { //Wasserverbrauchswerte alle Rasterzellen die in Flussrasterzelle (x,y) muenden addieren... if(!m_pDTM->is_NoData(sx,sy) && m_pRivGrids->asDouble(sx,sy) == 0 && m_pBasinShare->asDouble(sx,sy) == r ) { if( m_pWCons) conSum = conSum + m_pWCons->asDouble(sx,sy); //Summe der Verbrauchswerte des Teileinzugsgebiets (hier uebrige Rasterzellen) sum = sum + 1; //Summe der Rasterzellen des Teileinzuggebiets (ohne Flussrasterzelle) cellShare = cellShare + m_pNumInFlowCells->asDouble(sx, sy); //Summe aller InFlowCell-Werte des Teileinzuggebiets (hier uebrige Rasterzellen) } } } if(cellShare > 0) { if(!Parameters("WCons2")->asBool()) //1) Gesammte Verbrauchssumme aus der jeweiligen Flussrasterzelle entnehmen m_pSharedRivCons->Set_Value(x, y, conSum); else { //2) Prozemtuale, anteilige Entnahme ueber das gesamte Teileinzugsgebiet conShare = ( m_pNumInFlowCells->asDouble(x, y) / cellShare ) * conSum; //Berechnen der anteiligen Entnahme der Flussrasterzelle: //Summe aller InFlowCell-Werte des Teileinzugsgebiets geteilt durch NumInFlowCells der Flussrasterzelle (x,y) -> Anteilieg Entnahme in Prozent; //dann mit Gesamtennehame des Teileinzuggebiets conSum multiplizieren -> anteilige Entnahme m_pSharedRivCons->Set_Value(x, y, conShare); //Setzen der anteiligen Entnahme der Flussrasterzelle testSum = testSum + conShare; //PruefSumme //Anteilige Entname aller anderen Rasterzellen des Teileinzuggebiets setzen, das in Flussrasterzelle (x,y) muenden for(int sx=0; sx < NX; sx++) { //#pragma omp parallel for //TEST hier nicht anwendbar for(int sy=0; sy < NY; sy++) { if(!m_pDTM->is_NoData(sx,sy) && m_pRivGrids->asDouble(sx,sy) == 0 && m_pBasinShare->asDouble(sx,sy) == r ) { conShare = ( m_pNumInFlowCells->asDouble(sx, sy) / cellShare) * conSum; //Berechnen der anteiligen Entnahme der Rasterzellen (Methode s. Flussrasterzelle oben) m_pSharedRivCons->Set_Value(sx, sy, conShare); //Setzen der anteiligen Entnahme der Flussrasterzelle testSum = testSum + conShare; //PruefSumme } } } //if( testSum != conSum ) //durch Rundungsdifferenzen kommt es bei dieser TestAbfrage zu unberechtigten Fehlermeldungen // Message_Dlg("Fehler! Gesamtentnahme aus Teileinzugsgebiet entspricht nicht der Summe der berechneten anteiligen Entnahmen"); //m_pNumInputCells->Set_Value(x, y, sum); //NUR zu Testzwecken //m_pBasinShare->Set_Value(x, y, sum/BasinGrids ); //Anzahl der Einzugsgebietszellen (anteilig) die in diese Flussgrid (x,y) fliessen } } else m_pSharedRivCons->Set_Value(x, y, conSum); } } } } return (true); } else return (false); } bool CRivBasin::WriteLog(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << "e:" << "\\Log.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } saga-2.2.3/src/modules/simulation/sim_rivflow/RivBasin.h0000664000175000017500000001070212565125410024441 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivBasin.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__RivBasin_H #define HEADER_INCLUDED__RivBasin_H //--------------------------------------------------------- #include #include using namespace std; //--------------------------------------------------------- //######################################################### class CRivBasin : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CRivBasin(void); // constructor protected: /// protected members and functions: /////////// virtual bool On_Execute (void); // always overwrite this function private: ///// private members and functions: ///////////// CSG_Grid *m_pDTM, *m_pGrad, *m_pDirec, *m_pRivGrids, *m_pRivGrad, *m_pRaster, *m_pRSpeed, *m_pBasinShare, *m_pSharedRivCons, *m_pWCons, *m_pNumInFlowCells; double pCr, BasinGrids, statV, m_pVTresh; int nCr, statN; void Set_RivParam(int x, int y); bool Set_BasinShare(void); bool WriteLog(string s); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__RivBasin_H saga-2.2.3/src/modules/simulation/sim_rivflow/MLB_Interface.cpp0000664000175000017500000001214112565125410025650 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //######################################################### /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { default: case MLB_INFO_Name: return( _TL("RivFlow") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( "Christian Alwardt" ); case MLB_INFO_Description: return( _TL("RivFlow.") ); case MLB_INFO_Version: return( "3.1" ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Hydrology|RivFlow") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "RivBasin.h" #include "LandFlow.h" #include "RivCourseImpr.h" #include "RivGridPrep.h" #include "GridComb.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!... switch( i ) { case 0: return( new CRivBasin ); case 1: return( new CLandFlow ); case 2: return( new CRivCourseImpr ); case 3: return( new CRivGridPrep ); case 4: return( new CGridComb ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/simulation/sim_rivflow/Makefile.am0000664000175000017500000000136612565125410024615 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1537 2012-11-19 20:05:19Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_rivflow.la libsim_rivflow_la_SOURCES =\ DataTrans.cpp\ GridComb.cpp\ LandFlow.cpp\ MLB_Interface.cpp\ RivBasin.cpp\ RivCourseImpr.cpp\ RivGridPrep.cpp\ DataTrans.h\ GridComb.h\ LandFlow.h\ MLB_Interface.h\ RivBasin.h\ RivCourseImpr.h\ RivGridPrep.h libsim_rivflow_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/simulation/sim_rivflow/MLB_Interface.h0000664000175000017500000000775012565125410025327 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Template_MLB_Interface_H #define HEADER_INCLUDED__Template_MLB_Interface_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef Template_EXPORTS #define Template_EXPORT _SAGA_DLL_EXPORT #else #define Template_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Template_MLB_Interface_H saga-2.2.3/src/modules/simulation/sim_rivflow/RivCourseImpr.h0000664000175000017500000001020312565125410025471 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivCourseImpr.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__RivCourseImpr_H #define HEADER_INCLUDED__RivCourseImpr_H //--------------------------------------------------------- #include //--------------------------------------------------------- //######################################################### class CRivCourseImpr : public CSG_Module_Grid_Interactive { public: CRivCourseImpr(void); protected: virtual bool On_Execute(void); virtual bool On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CSG_Grid *m_pDTM; double m_pDiffH, minVal; int nX, nY; void getNeighFlowGridValue(int x, int y, double minVal); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__RivCourseImpr_H saga-2.2.3/src/modules/simulation/sim_rivflow/DataTrans.h0000664000175000017500000001010412565125410024601 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // DataTrans.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // 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: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__DataTrans_H #define HEADER_INCLUDED__DataTrans_H //--------------------------------------------------------- #include #include using namespace std; //--------------------------------------------------------- //######################################################### class CDataTrans : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CDataTrans(void); // constructor protected: /// protected members and functions: /////////// virtual bool On_Execute (void); // always overwrite this function private: ///// private members and functions: ///////////// CSG_Grid *pSource1, *pSource2; int NX, NY, m_pID, i; bool Set_TFile(CSG_Grid *pSource1, CSG_Grid *pSource2); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__DataTrans_Hsaga-2.2.3/src/modules/simulation/Makefile.in0000664000175000017500000004571512622651172022277 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/simulation DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 = sim_cellular_automata sim_ecosystems_hugget sim_erosion sim_fire_spreading sim_hydrology sim_ihacres sim_qm_of_esp sim_rivflow 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) --foreign src/modules/simulation/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/simulation/sim_ihacres/0000775000175000017500000000000012634325747022515 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_elev.cpp0000664000175000017500000006535212565125410025651 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev.cpp 1261 2011-12-16 15:12:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_elev.cpp // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-01-08 // /////////////////////////////////////////////////////////// #include "ihacres_elev.h" #include "convert_sl.h" #include "model_tools.h" // TEST OUTPUT ONLY #include //--------------------------------------------------------------------- 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(CSG_String(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,CSG_String(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); } saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_v1.h0000664000175000017500000001351512565125410024703 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_v1.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // IHACRES // // // //-------------------------------------------------------// // // // ihacres_v1.h // // // // Copyright (C) 2006 by // // Stefan Liersch // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stefan.liersch@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 // used for storing date string values in array using namespace std; typedef std::vector date_array; typedef vector vector_d; //--------------------------------------------------------- class Cihacres_v1 : public CSG_Module { public: // constructor Cihacres_v1(void); // destructor virtual ~Cihacres_v1(void); virtual bool needs_GUI (void) { return( true ); } 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 */saga-2.2.3/src/modules/simulation/sim_ihacres/convert_sl.h0000664000175000017500000000416612565125410025037 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: convert_sl.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ #ifndef __convert_sl_h #define __convert_sl_h #include #include #include // function StringToDouble #ifdef _SAGA_LINUX #include #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 */ saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_elev_cal.h0000664000175000017500000001204212565125410026121 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev_cal.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_elev_cal.h // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@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 // used for storing date string values in array //using namespace std; typedef std::vector date_array; class Cihacres_elev_cal : public CSG_Module { public: //-------------------------------------------------------- // CONSTRUCTORS //-------------------------------------------------------- // default Cihacres_elev_cal(); // destructor virtual ~Cihacres_elev_cal(void); virtual bool needs_GUI (void) { return( true ); } 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 */ saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_elev_bands.h0000664000175000017500000000541112565125410026453 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev_bands.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_elev_bands.h // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@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 */saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_elev_bands.cpp0000664000175000017500000000145212565125410027007 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev_bands.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ #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; }saga-2.2.3/src/modules/simulation/sim_ihacres/convert_sl.cpp0000664000175000017500000000730712565125410025372 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: convert_sl.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ #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); } //--------------------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_elev.h0000664000175000017500000001122712565125410025306 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_elev.h // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@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 // used for storing date string values in array //using namespace std; typedef std::vector date_array; class Cihacres_elev : public CSG_Module { public: //-------------------------------------------------------- // CONSTRUCTORS //-------------------------------------------------------- // default Cihacres_elev(); // destructor virtual ~Cihacres_elev(void); virtual bool needs_GUI (void) { return( true ); } 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 */ saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_cal2.h0000664000175000017500000002170112565125410025172 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_cal2.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // IHACRES // // // //-------------------------------------------------------// // // // ihacres_cal2.h // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stefan.liersch@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 // used for storing date string values in array //using namespace std; typedef std::vector date_array; //typedef std::vector vector_d; //typedef std::vector vector_i; //typedef std::vector vector_b; //--------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // CLASS Cihacres_cal2 // /////////////////////////////////////////////////////////////////////// class Cihacres_cal2 : public CSG_Module { public: // constructor Cihacres_cal2(void); // destructor virtual ~Cihacres_cal2(void); virtual bool needs_GUI (void) { return( true ); } 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 */ saga-2.2.3/src/modules/simulation/sim_ihacres/Makefile.in0000664000175000017500000005645412622651173024570 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/simulation/sim_ihacres DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_ihacres_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_ihacres_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 libsim_ihacres_la_OBJECTS = $(am_libsim_ihacres_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_ihacres_la_SOURCES) DIST_SOURCES = $(libsim_ihacres_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_ihacres.la libsim_ihacres_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 libsim_ihacres_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) --foreign src/modules/simulation/sim_ihacres/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_ihacres.la: $(libsim_ihacres_la_OBJECTS) $(libsim_ihacres_la_DEPENDENCIES) $(EXTRA_libsim_ihacres_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_ihacres_la_OBJECTS) $(libsim_ihacres_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convert_sl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_basin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_cal2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_elev.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_elev_bands.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_elev_cal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_eq.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_v1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/model_tools.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snow_module.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_elev_cal.cpp0000664000175000017500000012660312565125410026465 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev_cal.cpp 1261 2011-12-16 15:12:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_elev_cal.cpp // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-01-08 // /////////////////////////////////////////////////////////// #include "ihacres_elev_cal.h" #include "convert_sl.h" #include "model_tools.h" #include // random numbers #include // random numbers // TEST OUTPUT ONLY #include //--------------------------------------------------------------------- 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(CSG_String(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(CSG_String(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,CSG_String(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); } saga-2.2.3/src/modules/simulation/sim_ihacres/snow_module.cpp0000664000175000017500000002245212565125410025545 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snow_module.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ //////////////////////////////////////////////////////////////// // File: // snow_module.cpp // // A class to calculate a time series of // snow melt and snow storage. // // Author: // Stefan Liersch: stefan.liersch@gmail.com, stefan.liersch@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 #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; } } } saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_basin.cpp0000664000175000017500000006607312565125410026013 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_basin.cpp 1261 2011-12-16 15:12:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_basin.cpp // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@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(CSG_String(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,CSG_String(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); } saga-2.2.3/src/modules/simulation/sim_ihacres/model_tools.h0000664000175000017500000001541512565125410025200 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: model_tools.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // model_tools.h // // // // Copyright (C) 2007 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-01-24 // //-------------------------------------------------------// #ifndef HEADER_INCLUDED__model_tools_H #define HEADER_INCLUDED__model_tools_H #include typedef std::vector 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 class dynamic_array { public: dynamic_array(){}; dynamic_array(int rows, int cols) { for(int i=0; i(cols)); } } // other ctors .... inline std::vector & operator[](int i) { return data_[i]; } inline const std::vector & 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 > data_; }; //--------------------------------------------------------------------- // An example to use the template class //--------------------------------------------------------------------- //int main() //{ // dynamic_array a(3, 3); // a[1][1] = 2; // int x = a[1][1]; // return 0; //} /////////////////////////////////////////////////////////////////////// #endif /* HEADER_INCLUDED__model_tools_H */ saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_basin.h0000664000175000017500000001652112565125410025451 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_basin.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_basin.h // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@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); virtual bool needs_GUI (void) { return( true ); } 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 */ saga-2.2.3/src/modules/simulation/sim_ihacres/snow_module.h0000664000175000017500000001055312565125410025211 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snow_module.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ //////////////////////////////////////////////////////////////// // File: // snow_module.h // // A class to calculate a time series of // snow melt and snow storage. // // Author: // Stefan Liersch: stefan.liersch@gmail.com, stefan.liersch@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 // used for storing date string values in array typedef std::vector 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 */ saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_v1.cpp0000664000175000017500000006003112565125410025231 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_v1.cpp 1261 2011-12-16 15:12:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ihacres_v1 // // // //-------------------------------------------------------// // // // ihacres_v1.cpp // // // // Copyright (C) 2006 by // // Stefan Liersch // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stefan.liersch@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 // used for textfile output (test only) #include // 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(CSG_String (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,CSG_String(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,CSG_String(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); } }saga-2.2.3/src/modules/simulation/sim_ihacres/model_tools.cpp0000664000175000017500000002255712565125410025540 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: model_tools.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ #include "model_tools.h" #include #include // 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); } //--------------------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_ihacres/MLB_Interface.cpp0000664000175000017500000002207312565125410025603 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: author@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Hydrology: IHACRES") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("Stefan Liersch (c) 2008") ); case MLB_INFO_Description: return( _TW( "The metric conceptual rainfall-runoff model IHACRES " "(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" "Purpose\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 " "rainfall-runoff database " "for flood risk assessment and forecasting by Liersch, S. and M. Volk (2008) " "(pdf).\n" "\n" "References\n
    " "
  • 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.
  • \n" "
  • 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.
  • \n" "
  • 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.
  • \n" "
  • 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.
  • \n" "
  • 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.
  • \n" "
  • 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. Sanchez-Marre, J. Bejar, 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).
  • \n" "
  • 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.
  • \n" "
  • 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.
  • \n" "
  • 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.
  • \n" "
" )); 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 saga-2.2.3/src/modules/simulation/sim_ihacres/Makefile.am0000664000175000017500000000164212565125410024540 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_ihacres.la libsim_ihacres_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 libsim_ihacres_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/simulation/sim_ihacres/MLB_Interface.h0000664000175000017500000000774312565125410025257 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: author@email.de // // // // contact: Author // // Sesame Street. 7 // // 12345 Metropolis // // Nirvana // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /* $Log: not supported by cvs2svn $ /* 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 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ihacres_H saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_eq.h0000664000175000017500000004216012565125410024760 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_eq.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_eq.h // // // // Copyright (C) 2006 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@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 // CSG_Table #include // used for storing date string values in array // and double arrays (streamflow, pcp, tmp ...) #include using namespace std; #include "snow_module.h" #include "model_tools.h" typedef std::vector date_array; typedef vector 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 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 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 */ saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_eq.cpp0000664000175000017500000011505212565125410025314 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_eq.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // ihacres_eq.cpp // // // // Copyright (C) 2006 by // // Stefan Liersch // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // // // 2006-08-27 // // // //-------------------------------------------------------// #include // used for textfile output (test only) #include // used for textfile output (test only) #include "ihacres_eq.h" #include // 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 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 = (int)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((int)streamflow_obs.size()); } //--------------------------------------------------------------------- // two storages // using vector 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 = (int)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((int)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 = (int)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 = (int)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); } saga-2.2.3/src/modules/simulation/sim_ihacres/ihacres_cal2.cpp0000664000175000017500000010515612565125410025534 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_cal2.cpp 1261 2011-12-16 15:12:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ihacres_cal2 // // // //-------------------------------------------------------// // // // ihacres_cal.cpp // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stefan.liersch@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 // used for textfile output (test only) #include // used for textfile output (test only) #include // random numbers #include // 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." )); //----------------------------------------------------- // 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(CSG_String(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(CSG_String(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); } } saga-2.2.3/src/modules/simulation/Makefile.am0000664000175000017500000000021212622651133022242 0ustar00oconradoconrad00000000000000SUBDIRS = sim_cellular_automata sim_ecosystems_hugget sim_erosion sim_fire_spreading sim_hydrology sim_ihacres sim_qm_of_esp sim_rivflow saga-2.2.3/src/modules/simulation/sim_qm_of_esp/0000775000175000017500000000000012634325747023047 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/simulation/sim_qm_of_esp/hillslope_evolution_adi.h0000664000175000017500000001232012622651133030116 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: hillslope_evolution_adi.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // hillslope_evolution_adi.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__hillslope_evolution_adi_H #define HEADER_INCLUDED__hillslope_evolution_adi_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CHillslope_Evolution_ADI : public CSG_Module_Grid { public: CHillslope_Evolution_ADI(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Simulation|Hillslope Evolution" )); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pDEM_Old, *m_pChannels; void Set_Difference (void); void Set_Diffusion (double dFactor); bool is_Channel (int x, int y); double Get_Elevation (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__hillslope_evolution_adi_H saga-2.2.3/src/modules/simulation/sim_qm_of_esp/flow_routing.cpp0000664000175000017500000001727112622651133026265 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: flow_routing.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // flow_routing.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "flow_routing.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_Routing::CFlow_Routing(void) { //----------------------------------------------------- Set_Name (_TL("Flow Accumulation (QM of ESP)")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Calculation of flow accumulation, aka upslope contributing area, with the " "multiple flow direction method after Freeman (1991).\n" "\nReferences:\n" "Freeman, G.T. (1991): Calculating catchment area with divergent flow based on a rectangular grid. Computers & Geosciences, 17, pp.413-422.\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "FLOW" , _TL("Contributing Area"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "PREPROC" , _TL("Preprocessing"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("none"), _TL("fill sinks temporarily"), _TL("fill sinks permanently") ), 1 ); Parameters.Add_Value( NULL , "DZFILL" , _TL("Fill Increment"), _TL(""), PARAMETER_TYPE_Double, 0.01, 0.0000001, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CFlow_Routing::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "PREPROC") ) { pParameters->Get_Parameter("DZFILL")->Set_Enabled(pParameter->asInt() != 0); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_Routing::On_Execute(void) { m_pDEM = Parameters("DEM" )->asGrid(); m_pFlow = Parameters("FLOW")->asGrid(); return( Set_Flow(Parameters("PREPROC")->asInt(), Parameters("DZFILL")->asDouble()) ); } //--------------------------------------------------------- bool CFlow_Routing::Set_Flow(CSG_Grid *pDEM, CSG_Grid *pFlow, int Preprocess, double dzFill) { if( is_Executing() || !pDEM || !pFlow || !pDEM->is_Compatible(pFlow) || !Get_System()->Assign(pDEM->Get_System()) ) { return( false ); } m_pDEM = pDEM; m_pFlow = pFlow; return( Set_Flow(Preprocess, dzFill) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_Routing::Set_Flow(int Preprocess, double dzFill) { CSG_Grid DEM; switch( Preprocess ) { case 1: DEM.Create(*m_pDEM); m_pDEM = &DEM; case 2: { CFill_Sinks Preprocessor; Preprocessor.Fill_Sinks(m_pDEM, NULL, dzFill); } break; } //----------------------------------------------------- int i, x, y; m_pFlow->Assign(0.0); m_pDEM->Get_Sorted(0, x, y); Process_Set_Text(_TL("Calculating Contributing Area")); for(i=0; iGet_Sorted(i, x, y) ) { Set_Flow(x, y); } } //----------------------------------------------------- if( Preprocess == 2 ) { DataObject_Update(m_pDEM); } return( true ); } //--------------------------------------------------------- void CFlow_Routing::Set_Flow(int x, int y) { if( !m_pDEM->is_NoData(x, y) ) { m_pFlow->Add_Value(x, y, Get_Cellarea()); int i; double z, dz[8], dzSum; for(i=0, dzSum=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && (dz[i] = z - m_pDEM->asDouble(ix, iy)) > 0.0 ) { dzSum += (dz[i] = pow(dz[i] / Get_Length(i), 1.1)); } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { for(i=0, z=m_pFlow->asDouble(x, y)/dzSum; i<8; i++) { if( dz[i] > 0.0 ) { m_pFlow->Add_Value(Get_xTo(i, x), Get_yTo(i, y), z * dz[i]); } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_qm_of_esp/fill_sinks.h0000664000175000017500000001207612622651133025347 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: fill_sinks.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // fill_sinks.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__fill_sinks_H #define HEADER_INCLUDED__fill_sinks_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFill_Sinks : public CSG_Module_Grid { public: CFill_Sinks(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Preprocessing" )); } bool Fill_Sinks (CSG_Grid *pDEM, CSG_Grid *pFilled=NULL, double dzFill=0.01); protected: virtual bool On_Execute (void); private: double m_dzFill; CSG_Grid *m_pDEM; bool Fill_Sinks (void); bool Fill_Sink (int x, int y); bool Fill_Cell (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__fill_sinks_H saga-2.2.3/src/modules/simulation/sim_qm_of_esp/Makefile.in0000664000175000017500000005550612622651173025117 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/simulation/sim_qm_of_esp DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_qm_of_esp_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_qm_of_esp_la_OBJECTS = fill_sinks.lo flow_routing.lo \ hillslope_evolution_adi.lo hillslope_evolution_ftcs.lo \ MLB_Interface.lo successive_flow_routing.lo libsim_qm_of_esp_la_OBJECTS = $(am_libsim_qm_of_esp_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_qm_of_esp_la_SOURCES) DIST_SOURCES = $(libsim_qm_of_esp_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1537 2012-11-19 20:05:19Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_qm_of_esp.la libsim_qm_of_esp_la_SOURCES = \ fill_sinks.cpp\ flow_routing.cpp\ hillslope_evolution_adi.cpp\ hillslope_evolution_ftcs.cpp\ MLB_Interface.cpp\ successive_flow_routing.cpp\ fill_sinks.h\ flow_routing.h\ hillslope_evolution_adi.h\ hillslope_evolution_ftcs.h\ MLB_Interface.h\ successive_flow_routing.h libsim_qm_of_esp_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) --foreign src/modules/simulation/sim_qm_of_esp/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_qm_of_esp/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_qm_of_esp.la: $(libsim_qm_of_esp_la_OBJECTS) $(libsim_qm_of_esp_la_DEPENDENCIES) $(EXTRA_libsim_qm_of_esp_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_qm_of_esp_la_OBJECTS) $(libsim_qm_of_esp_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fill_sinks.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flow_routing.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hillslope_evolution_adi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hillslope_evolution_ftcs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/successive_flow_routing.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/simulation/sim_qm_of_esp/hillslope_evolution_adi.cpp0000664000175000017500000003472012622651133030461 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: hillslope_evolution_adi.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // hillslope_evolution_adi.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "hillslope_evolution_adi.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool tridag(const CSG_Vector &a, const CSG_Vector &b, const CSG_Vector &c, const CSG_Vector &r, CSG_Vector &u) { int i, n = a.Get_N(); double beta; CSG_Vector gamma(n); if( n < 2 || n != b.Get_N() || n != c.Get_N() || n != r.Get_N() || b[0] == 0.0 ) { return( false ); } u.Create(n); u[0] = r[0] / (beta = b[0]); for(i=1; i=0; i--) { u[i] -= gamma[i + 1] * u[i + 1]; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CHillslope_Evolution_ADI::CHillslope_Evolution_ADI(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Diffusive Hillslope Evolution (ADI)")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Simulation of diffusive hillslope evolution using an Alternating-Direction-Implicit (ADI) method.\n" "\nReferences:\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CHANNELS" , _TL("Channel Mask"), _TL("use a zero value for hillslopes, any other value for channel cells."), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "MODEL" , _TL("Modelled Elevation"), _TL(""), PARAMETER_OUTPUT ); pNode = Parameters.Add_Grid( NULL , "DIFF" , _TL("Elevation Difference"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( pNode , "UPDATE" , _TL("Update"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "KAPPA" , _TL("Diffusivity [m2 / kyr]"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Value( NULL , "DURATION" , _TL("Simulation Time [kyr]"), _TL(""), PARAMETER_TYPE_Double, 10000.0, 0.0, true ); pNode = Parameters.Add_Choice( NULL , "TIMESTEP" , _TL("Time Step"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("user defined"), _TL("automatically") ), 0 ); Parameters.Add_Value( pNode , "DTIME" , _TL("Time Step [kyr]"), _TL(""), PARAMETER_TYPE_Double, 1000.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CHillslope_Evolution_ADI::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TIMESTEP") ) { pParameters->Get_Parameter("DTIME")->Set_Enabled(pParameter->asInt() == 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DIFF") ) { pParameters->Get_Parameter("UPDATE")->Set_Enabled(pParameter->asGrid() != NULL); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CHillslope_Evolution_ADI::On_Execute(void) { //----------------------------------------------------- CSG_Grid DEM(*Get_System()), Channels(*Get_System(), SG_DATATYPE_Byte); m_pDEM_Old = &DEM; m_pDEM = Parameters("MODEL" )->asGrid(); m_pChannels = Parameters("CHANNELS")->asGrid(); m_pDEM->Assign(Parameters("DEM")->asGrid()); DataObject_Set_Colors(Parameters("DIFF")->asGrid(), 10, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- double k, dTime, nTime; k = Parameters("KAPPA" )->asDouble(); nTime = Parameters("DURATION")->asDouble(); if( Parameters("TIMESTEP")->asInt() == 0 ) { dTime = Parameters("DTIME")->asDouble(); } else { dTime = 0.5 * Get_Cellarea() / (2.0 * k); } if( dTime > nTime ) { Message_Add(CSG_String::Format(SG_T("\n%s: %s [%f]"), _TL("Warning"), _TL("Time step exceeds duration"), dTime), false); dTime = nTime; } Message_Add(CSG_String::Format(SG_T("\n%s: %f"), _TL("Time Step"), dTime), false); Message_Add(CSG_String::Format(SG_T("\n%s: %d"), _TL("Steps"), (int)(nTime / dTime)), false); //----------------------------------------------------- for(double iTime=dTime; iTime<=nTime && Set_Progress(iTime, nTime); iTime+=dTime) { Process_Set_Text(CSG_String::Format(SG_T("%s: %.2f [%.2f]"), _TL("Simulation Time"), iTime, nTime)); SG_UI_Progress_Lock(true); Set_Diffusion(dTime * k / Get_Cellarea()); Set_Difference(); SG_UI_Progress_Lock(false); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CHillslope_Evolution_ADI::Set_Difference(void) { CSG_Grid *pDiff = Parameters("DIFF")->asGrid(); if( pDiff ) { CSG_Grid *pDEM = Parameters("DEM")->asGrid(); #pragma omp parallel for for(int i=0; iis_NoData(i) ) { pDiff->Set_NoData(i); } else { pDiff->Set_Value(i, m_pDEM->asDouble(i) - pDEM->asDouble(i)); } } if( Parameters("UPDATE")->asBool() ) { DataObject_Update(pDiff, SG_UI_DATAOBJECT_SHOW); } } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CHillslope_Evolution_ADI::is_Channel(int x, int y) { return( m_pChannels ? m_pChannels->asDouble(x, y) != 0.0 : false ); } //--------------------------------------------------------- inline double CHillslope_Evolution_ADI::Get_Elevation(int x, int y) { if( x < 0 ) x = 0; else if( x >= Get_NX() ) x = Get_NX() - 1; if( y < 0 ) y = 0; else if( y >= Get_NY() ) y = Get_NY() - 1; return( m_pDEM->asDouble(x, y) ); } //--------------------------------------------------------- void CHillslope_Evolution_ADI::Set_Diffusion(double dFactor) { int x, y; for(int i=0; i<5 && Process_Get_Okay(); i++) { m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for private(x, y) for(x=0; xasDouble(x, y); } else if( y == Get_NY() - 1 ) { a[y] = 0; b[y] = 1; c[y] = is_Channel(x, y) ? 0 : -dFactor; r[y] = m_pDEM_Old->asDouble(x, y); } else if( is_Channel(x, y) ) { b[y] = 1; a[y] = 0; c[y] = 0; r[y] = m_pDEM_Old->asDouble(x, y); } else // if( !is_Channel(x, y) ) { a[y] = -dFactor; c[y] = -dFactor; b[y] = 4 * dFactor + 1; r[y] = m_pDEM_Old->asDouble(x, y) + dFactor * (Get_Elevation(x - 1, y) + Get_Elevation(x + 1, y)); } } tridag(a, b, c, r, u); for(y=0; ySet_Value(x, y, u[y]); } } //------------------------------------------------- m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for private(x, y) for(y=0; yasDouble(x, y); } else if( x == Get_NX() - 1 ) { a[x] = 0; b[x] = 1; c[x] = is_Channel(x, y) ? 0 : -dFactor; r[x] = m_pDEM_Old->asDouble(x, y); } else if( is_Channel(x, y) ) { a[x] = 0; b[x] = 1; c[x] = 0; r[x] = m_pDEM_Old->asDouble(x, y); } else // if( !is_Channel(x, y) ) { a[x] = -dFactor; c[x] = -dFactor; b[x] = 4 * dFactor + 1; r[x] = m_pDEM_Old->asDouble(x, y) + dFactor * (Get_Elevation(x, y - 1) + Get_Elevation(x, y + 1)); } } tridag(a, b, c, r, u); for(x=0; xSet_Value(x, y, u[x]); } } } } /*/--------------------------------------------------------- void CHillslope_Evolution_ADI::Set_Diffusion(double dFactor) { int x, y; for(int i=0; i<5 && Process_Get_Okay(); i++) { m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for private(x, y) for(x=0; xasDouble(x, y) + dFactor * (Get_Elevation(x - 1, y) + Get_Elevation(x + 1, y)); } else { b[y] = 1; a[y] = 0; c[y] = 0; r[y] = m_pDEM_Old->asDouble(x, y); } if( y == 0 ) { b[y] = 1; c[y] = 0; r[y] = m_pDEM_Old->asDouble(x, y); } else if( y == Get_NY() - 1 ) { b[y] = 1; a[y] = 0; r[y] = m_pDEM_Old->asDouble(x, y); } } tridag(a, b, c, r, u); for(y=0; ySet_Value(x, y, u[y]); } } //------------------------------------------------- m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for private(x, y) for(y=0; yasDouble(x, y) + dFactor * (Get_Elevation(x, y - 1) + Get_Elevation(x, y + 1)); } else { b[x] = 1; a[x] = 0; c[x] = 0; r[x] = m_pDEM_Old->asDouble(x, y); } if( x == 0 ) { b[x] = 1; c[x] = 0; r[x] = m_pDEM_Old->asDouble(x, y); } else if( x == Get_NX() - 1 ) { b[x] = 1; a[x] = 0; r[x] = m_pDEM_Old->asDouble(x, y); } } tridag(a, b, c, r, u); for(x=0; xSet_Value(x, y, u[x]); } } } }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_qm_of_esp/hillslope_evolution_ftcs.cpp0000664000175000017500000002342712622651133030665 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: hillslope_evolution_ftcs.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // hillslope_evolution_ftcs.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "hillslope_evolution_ftcs.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CHillslope_Evolution_FTCS::CHillslope_Evolution_FTCS(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Diffusive Hillslope Evolution (FTCS)")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Simulation of diffusive hillslope evolution using a Forward-Time-Centered-Space (FTCS) method.\n" "\nReferences:\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "MODEL" , _TL("Modelled Elevation"), _TL(""), PARAMETER_OUTPUT ); pNode = Parameters.Add_Grid( NULL , "DIFF" , _TL("Elevation Difference"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( pNode , "UPDATE" , _TL("Update"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "KAPPA" , _TL("Diffusivity [m2 / kyr]"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL , "DURATION" , _TL("Simulation Time [kyr]"), _TL(""), PARAMETER_TYPE_Double, 100.0, 0.0, true ); pNode = Parameters.Add_Choice( NULL , "TIMESTEP" , _TL("Time Step"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("user defined"), _TL("automatically") ), 1 ); Parameters.Add_Value( pNode , "DTIME" , _TL("Time Step [kyr]"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Choice( NULL , "NEIGHBOURS" , _TL("Neighbourhood"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Neumann"), _TL("Moore") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CHillslope_Evolution_FTCS::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TIMESTEP") ) { pParameters->Get_Parameter("DTIME")->Set_Enabled(pParameter->asInt() == 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DIFF") ) { pParameters->Get_Parameter("UPDATE")->Set_Enabled(pParameter->asGrid() != NULL); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CHillslope_Evolution_FTCS::On_Execute(void) { //----------------------------------------------------- CSG_Grid DEM(*Get_System()); m_pDEM_Old = &DEM; m_pDEM = Parameters("MODEL")->asGrid(); m_pDEM->Assign(Parameters("DEM")->asGrid()); DataObject_Set_Colors(Parameters("DIFF")->asGrid(), 10, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- double k, dTime, nTime; k = Parameters("KAPPA" )->asDouble(); nTime = Parameters("DURATION")->asDouble(); if( Parameters("TIMESTEP")->asInt() == 0 ) { dTime = Parameters("DTIME")->asDouble(); } else { dTime = 0.5 * Get_Cellarea() / (2.0 * k); if( Parameters("NEIGHBOURS")->asInt() == 1 ) { dTime /= sqrt(2.0); } } if( dTime > nTime ) { Message_Add(CSG_String::Format(SG_T("\n%s: %s [%f]"), _TL("Warning"), _TL("Time step exceeds duration"), dTime), false); dTime = nTime; } Message_Add(CSG_String::Format(SG_T("\n%s: %f"), _TL("Time Step"), dTime), false); Message_Add(CSG_String::Format(SG_T("\n%s: %d"), _TL("Steps"), (int)(nTime / dTime)), false); //----------------------------------------------------- for(double iTime=dTime; iTime<=nTime && Set_Progress(iTime, nTime); iTime+=dTime) { Process_Set_Text(CSG_String::Format(SG_T("%s: %.2f [%.2f]"), _TL("Simulation Time"), iTime, nTime)); SG_UI_Progress_Lock(true); Set_Diffusion(dTime * k / Get_Cellarea()); Set_Difference(); SG_UI_Progress_Lock(false); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CHillslope_Evolution_FTCS::Set_Difference(void) { CSG_Grid *pDiff = Parameters("DIFF")->asGrid(); if( pDiff ) { CSG_Grid *pDEM = Parameters("DEM")->asGrid(); #pragma omp parallel for for(int i=0; iis_NoData(i) ) { pDiff->Set_NoData(i); } else { pDiff->Set_Value(i, m_pDEM->asDouble(i) - pDEM->asDouble(i)); } } if( Parameters("UPDATE")->asBool() ) { DataObject_Update(pDiff, SG_UI_DATAOBJECT_SHOW); } } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CHillslope_Evolution_FTCS::Set_Diffusion(double dFactor) { int iStep = Parameters("NEIGHBOURS")->asInt() == 1 ? 1 : 2; m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for for(int y=0; yis_NoData(x, y) ) { double z = m_pDEM_Old->asDouble(x, y); double dz = 0.0; for(int i=0; i<8; i+=iStep) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM_Old->is_InGrid(ix, iy) ) { dz += (m_pDEM_Old->asDouble(ix, iy) - z) / Get_UnitLength(i); } } m_pDEM->Add_Value(x, y, dFactor * dz); } } } } /*/--------------------------------------------------------- void CHillslope_Evolution_FTCS::Set_Diffusion(double dFactor) { m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for for(int y=0; yis_NoData(x, y) ) { double z, dz; z = m_pDEM_Old->asDouble(x, y); dz = -4.0 * z; for(int i=0; i<8; i+=2) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); dz += m_pDEM_Old->is_InGrid(ix, iy) ? m_pDEM_Old->asDouble(ix, iy) : z; } m_pDEM->Add_Value(x, y, dFactor * dz); } } } }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_qm_of_esp/fill_sinks.cpp0000664000175000017500000002226312622651133025701 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: fill_sinks.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // fill_sinks.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "fill_sinks.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CStack : public CSG_Stack { public: CStack(void) : CSG_Stack(3 * sizeof(int)) {} //----------------------------------------------------- virtual bool Push (int x, int y, int i) { int *Data = (int *)Get_Record_Push(); if( Data ) { Data[0] = x; Data[1] = y; Data[2] = i; return( true ); } return( false ); } //----------------------------------------------------- virtual bool Pop (int &x, int &y, int &i) { int *Data = (int *)Get_Record_Pop(); if( Data ) { x = Data[0]; y = Data[1]; i = Data[2]; return( true ); } return( false ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFill_Sinks::CFill_Sinks(void) { //----------------------------------------------------- Set_Name (_TL("Fill Sinks (QM of ESP)")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Filling in pits and flats in a DEM.\n" "\nReferences:\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "FILLED" , _TL("DEM without Sinks"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "SINKS" , _TL("Sinks"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "DZFILL" , _TL("Fill Increment"), _TL(""), PARAMETER_TYPE_Double, 0.01, 0.0000001, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFill_Sinks::On_Execute(void) { CSG_Grid *pDEM, *pSinks; pDEM = Parameters("DEM" )->asGrid(); m_pDEM = Parameters("FILLED")->asGrid(); pSinks = Parameters("SINKS" )->asGrid(); m_dzFill = Parameters("DZFILL")->asDouble(); m_pDEM->Assign(pDEM); m_pDEM->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pDEM->Get_Name(), _TL("No Sinks"))); if( !Fill_Sinks() ) { return( false ); } if( pSinks ) { pSinks->Assign(m_pDEM); pSinks->Subtract(*pDEM); pSinks->Set_NoData_Value(0.0); } return( true ); } //--------------------------------------------------------- bool CFill_Sinks::Fill_Sinks(CSG_Grid *pDEM, CSG_Grid *pFilled, double dzFill) { if( is_Executing() || !pDEM || (pFilled && !pDEM->is_Compatible(pFilled)) || !Get_System()->Assign(pDEM->Get_System()) ) { return( false ); } //----------------------------------------------------- if( pFilled ) { m_pDEM = pFilled; m_pDEM->Assign(pDEM); } else { m_pDEM = pDEM; } m_dzFill = dzFill; return( Fill_Sinks() ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFill_Sinks::Fill_Sinks(void) { if( m_dzFill <= 0.0 ) { return( false ); } Process_Set_Text(_TL("Processing Sinks and Flats")); for(int y=0; y 0 ); return( true ); } //--------------------------------------------------------- bool CFill_Sinks::Fill_Cell(int x, int y) { if( x > 0 && x < Get_NX() - 1 && y > 0 && y < Get_NY() - 1 && !m_pDEM->is_NoData(x, y) ) { for(bool bFilled=false, bSingle=true; ; ) { bool bPit = true; double zMin = m_pDEM->asDouble(x, y); for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) ) { bSingle = false; if( m_pDEM->asDouble(ix, iy) < zMin ) { zMin = m_pDEM->asDouble(ix, iy); bPit = false; } } } if( !bSingle && bPit ) { m_pDEM->Set_Value(x, y, zMin + m_dzFill); bFilled = true; } else { return( bFilled ); } } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// /*/--------------------------------------------------------- void CFill_Sinks::Fill_Sinks(int x, int y) { if( Fill_Cell(x, y) ) { for(int i=0; i<8; i++) { Fill_Sinks(Get_xTo(i, x), Get_yTo(i, y)); } } }/**/ /*/--------------------------------------------------------- void CFill_Sinks::Fill_Sinks(int x, int y) { if( x > 0 && x < Get_NX() - 1 && y > 0 && y < Get_NY() - 1 && !m_pDEM->is_NoData(x, y) ) { int i; double zMin; for(i=0, zMin=m_pDEM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && m_pDEM->asDouble(ix, iy) < zMin ) { zMin = m_pDEM->asDouble(ix, iy); } } if( m_pDEM->asDouble(x, y) <= zMin ) { m_pDEM->Set_Value(x, y, zMin + m_dzFill); Fill_Sinks(x, y); for(i=0; i<8; i++) { Fill_Sinks(Get_xTo(i, x), Get_yTo(i, y)); } } } }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_qm_of_esp/successive_flow_routing.cpp0000664000175000017500000002206212622651133030513 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: successive_flow_routing.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // successive_flow_routing.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "successive_flow_routing.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSuccessive_Flow_Routing::CSuccessive_Flow_Routing(void) { //----------------------------------------------------- Set_Name (_TL("Successive Flow Routing")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Calculation of flow accumulation, aka upslope contributing area, with the " "multiple flow direction method after Freeman (1991).\n" "\nReferences:\n" "Freeman, G.T. (1991): Calculating catchment area with divergent flow based on a rectangular grid. " "Computers & Geosciences, 17, pp.413-422.\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "FLOW" , _TL("Flow"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "ITERATIONS" , _TL("Iterations"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Value( NULL , "RUNOFF" , _TL("Runoff"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Value( NULL , "MANNING" , _TL("Manning's Roughness"), _TL(""), PARAMETER_TYPE_Double, 0.2 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSuccessive_Flow_Routing::On_Execute(void) { int x, y, nIterations; double Runoff; CSG_Grid *pDEM, DEM, Slope; nIterations = Parameters("ITERATIONS")->asInt(); Runoff = Parameters("RUNOFF" )->asDouble(); m_Manning = Parameters("MANNING" )->asDouble(); pDEM = Parameters("DEM" )->asGrid(); m_pFlow = Parameters("FLOW" )->asGrid(); m_pDEM = &DEM; m_pSlope = &Slope; DEM .Create(*pDEM); Slope .Create(*Get_System()); CSG_Colors Colors(11, SG_COLORS_WHITE_BLUE); Colors[0] = SG_GET_RGB(255, 255, 200); DataObject_Set_Colors(m_pFlow, Colors); DataObject_Update(m_pFlow, SG_UI_DATAOBJECT_SHOW); Fill_Sinks(); #pragma omp parallel for private(x, y) for(y=0; ySet_Value(x, y, pow(Runoff, 1.66667) * m_pSlope->asDouble(x, y)); } } for(int i=0; iGet_Sorted(i, x, y) ) { Set_Flow(x, y); } } #pragma omp parallel for private(x, y) for(y=0; yis_NoData(x, y) ) { m_pFlow->Set_NoData(x, y); } else { double Depth = pow(m_pFlow->asDouble(x, y) / m_pSlope->asDouble(x, y), 0.6); if( m_pDEM->asDouble(x, y) < pDEM->asDouble(x, y) + Depth ) { m_pDEM->Set_Value(x, y, pDEM->asDouble(x, y) + Depth / nIterations); } m_pFlow->Set_Value(x, y, m_pDEM->asDouble(x, y) - pDEM->asDouble(x, y)); } } } DataObject_Update(m_pFlow); SG_UI_Progress_Lock(false); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define RUN_MODULE(LIBRARY, MODULE, CONDITION) {\ bool bResult;\ SG_RUN_MODULE(bResult, LIBRARY, MODULE, CONDITION)\ } #define SET_PARAMETER(IDENTIFIER, VALUE) pModule->Get_Parameters()->Set_Parameter(SG_T(IDENTIFIER), VALUE) void CSuccessive_Flow_Routing::Fill_Sinks(void) { RUN_MODULE("ta_preprocessor", 2, // CPit_Eliminator SET_PARAMETER("DEM" , m_pDEM) ) } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSuccessive_Flow_Routing::Set_Flow(int x, int y) { if( !m_pDEM->is_NoData(x, y) ) { int i; double z, dz[8], dzSum; for(i=0, dzSum=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && (dz[i] = z - m_pDEM->asDouble(ix, iy)) > 0.0 ) { dzSum += (dz[i] = pow(dz[i] / Get_Length(i), 1.1)); } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { for(i=0, z=m_pFlow->asDouble(x, y)/dzSum; i<8; i++) { if( dz[i] > 0.0 ) { m_pFlow->Add_Value(Get_xTo(i, x), Get_yTo(i, y), z * dz[i]); } } } } } //--------------------------------------------------------- void CSuccessive_Flow_Routing::Set_Channel_Slope(int x, int y) { if( m_pDEM->is_NoData(x, y) ) { m_pSlope->Set_NoData(x, y); } else { int i; double z, dz, Slope; for(i=0, Slope=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && (dz = (z - m_pDEM->asDouble(ix, iy)) / Get_Length(i)) > Slope ) { Slope = dz; } } m_pSlope->Set_Value(x, y, sqrt(Slope > 0.01 ? Slope : 0.01) * Get_Cellsize() / m_Manning); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_qm_of_esp/hillslope_evolution_ftcs.h0000664000175000017500000001216512622651133030327 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: hillslope_evolution_ftcs.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // hillslope_evolution_ftcs.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__hillslope_evolution_ftcs_H #define HEADER_INCLUDED__hillslope_evolution_ftcs_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CHillslope_Evolution_FTCS : public CSG_Module_Grid { public: CHillslope_Evolution_FTCS(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Simulation|Hillslope Evolution" )); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pDEM_Old; void Set_Difference (void); void Set_Diffusion (double dFactor); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__hillslope_evolution_ftcs_H saga-2.2.3/src/modules/simulation/sim_qm_of_esp/MLB_Interface.cpp0000664000175000017500000001206412622651133026134 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // 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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("QM of ESP") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2013") ); case MLB_INFO_Description: return( _TW( "Quantitative Modeling of Earth Surface Processes.\n" "SAGA implementations following the examples from the text book:\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Quantitative Modeling of Earth Surface Processes") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "hillslope_evolution_ftcs.h" #include "fill_sinks.h" #include "flow_routing.h" #include "successive_flow_routing.h" #include "hillslope_evolution_adi.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CHillslope_Evolution_FTCS ); case 1: return( new CFill_Sinks ); case 2: return( new CFlow_Routing ); case 3: return( new CSuccessive_Flow_Routing ); case 4: return( new CHillslope_Evolution_ADI ); case 11: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/simulation/sim_qm_of_esp/Makefile.am0000664000175000017500000000147012622651133025071 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1537 2012-11-19 20:05:19Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_qm_of_esp.la libsim_qm_of_esp_la_SOURCES =\ fill_sinks.cpp\ flow_routing.cpp\ hillslope_evolution_adi.cpp\ hillslope_evolution_ftcs.cpp\ MLB_Interface.cpp\ successive_flow_routing.cpp\ fill_sinks.h\ flow_routing.h\ hillslope_evolution_adi.h\ hillslope_evolution_ftcs.h\ MLB_Interface.h\ successive_flow_routing.h libsim_qm_of_esp_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/simulation/sim_qm_of_esp/MLB_Interface.h0000664000175000017500000000766412622651133025613 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__qm_of_esp_MLB_Interface_H #define HEADER_INCLUDED__qm_of_esp_MLB_Interface_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef qm_of_esp_EXPORTS #define qm_of_esp_EXPORT _SAGA_DLL_EXPORT #else #define qm_of_esp_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__qm_of_esp_MLB_Interface_H saga-2.2.3/src/modules/simulation/sim_qm_of_esp/successive_flow_routing.h0000664000175000017500000001210712622651133030157 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: successive_flow_routing.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // successive_flow_routing.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__successive_flow_routing_H #define HEADER_INCLUDED__successive_flow_routing_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "flow_routing.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSuccessive_Flow_Routing : public CSG_Module_Grid { public: CSuccessive_Flow_Routing(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Simulation|Hydrology" )); } protected: virtual bool On_Execute (void); private: double m_Manning; CSG_Grid *m_pDEM, *m_pFlow, *m_pSlope; void Fill_Sinks (void); void Set_Flow (int x, int y); void Set_Channel_Slope (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__successive_flow_routing_H saga-2.2.3/src/modules/simulation/sim_qm_of_esp/flow_routing.h0000664000175000017500000001224512622651133025726 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: flow_routing.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // flow_routing.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__flow_routing_H #define HEADER_INCLUDED__flow_routing_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "fill_sinks.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFlow_Routing : public CSG_Module_Grid { public: CFlow_Routing(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Hydrology|Flow Accumulation" )); } bool Set_Flow (CSG_Grid *pDEM, CSG_Grid *pFlow, int Preprocess = 0, double dzFill = 0.01); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pFlow; bool Set_Flow (int Preprocess, double dzFill); void Set_Flow (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__flow_routing_H saga-2.2.3/src/modules/simulation/sim_hydrology/0000775000175000017500000000000012634325747023117 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/simulation/sim_hydrology/diffuse_pollution_risk.cpp0000664000175000017500000003620412565125410030376 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: diffuse_pollution_risk.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // diffuse_pollution_risk.cpp // // // // Copyright (C) 2015 by // // Cosima Berger // // // //-------------------------------------------------------// // // // 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@saga-gis.de // // // // contact: Cosima Berger // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "diffuse_pollution_risk.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDiffuse_Pollution_Risk::CDiffuse_Pollution_Risk(void) { //----------------------------------------------------- Set_Name (_TL("Diffuse Pollution Risk")); Set_Author ("Cosima Berger, Olaf Conrad (c) 2014"); Set_Description (_TW( "Diffuse Pollution Risk Mapping.\n" "This tool tries to reproduce in parts the methodology of the " "SCIMAP - Diffuse Pollution Risk Mapping - Framework.\n" "\nReferences:\n" "Lane, S.N.; Brookes, C.J.; Kirkby, M.J.; Holden, J. (2004): " "A network-index-based version of TOPMODEL for use with high-resolution digital topographic data. " "In: Hydrological processes. Vol. 18, S. 191-201.\n" "\n" "Milledge, D.G.; Lane, N.S.; Heathwait, A.L.; Reaney, S.M. (2012): " "A monte carlo approach to the invers problem of diffuse pollution risk in agricultural catchments. " "In: Science of the Total Environment. Vol. 433, S. 434-449.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CHANNEL" , _TL("Channel Network"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid_or_Const( NULL , "WEIGHT" , _TL("Land Cover Weights"), _TL(""), 1.0, 0.0, true ); Parameters.Add_Grid_or_Const( NULL , "RAIN" , _TL("Rainfall"), _TL(""), 500.0, 0.0, true ); Parameters.Add_Grid( NULL , "DELIVERY" , _TL("Delivery Index"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "RISK_POINT" , _TL("Locational Risk"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "RISK_DIFFUSE" , _TL("Diffuse Pollution Risk"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- Parameters.Add_Choice( NULL , "METHOD" , _TL("Flow Direction Algorithm"), _TL(""), CSG_String::Format("%s|%s|", _TL("single"), _TL("multiple") ), 1 ); Parameters.Add_Value( NULL , "CHANNEL_START" , _TL("Channel Initiation Threshold"), _TL("minimum number of upslope contributing cells to start a channel"), PARAMETER_TYPE_Int, 150, 1, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CDiffuse_Pollution_Risk::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "CHANNEL") ) { pParameters->Set_Enabled("CHANNEL_START", pParameter->asGrid() == NULL); } return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::On_Execute(void) { //----------------------------------------------------- m_pDEM = Parameters("DEM" )->asGrid(); m_pDelivery = Parameters("DELIVERY" )->asGrid(); m_pRisk_Point = Parameters("RISK_POINT" )->asGrid(); m_pRisk_Diffuse = Parameters("RISK_DIFFUSE")->asGrid(); m_bSingle = Parameters("METHOD" )->asInt() == 0; DataObject_Set_Colors(m_pDelivery , 11, SG_COLORS_RED_GREY_GREEN, true); DataObject_Set_Colors(m_pRisk_Point , 11, SG_COLORS_RED_GREY_GREEN, true); DataObject_Set_Colors(m_pRisk_Diffuse, 11, SG_COLORS_RED_GREY_GREEN, true); //----------------------------------------------------- bool bResult = false; if( !Set_Flow() ) { Error_Set(_TL("initialization failed")); } else if( !Set_Delivery_Index() ) { Error_Set(_TL("delivery index calculation failed")); } else if( !Get_Risk_Diffuse() ) { Error_Set(_TL("diffuse pollution risk calculation failed")); } else { bResult = true; } //----------------------------------------------------- m_FlowDir.Destroy(); m_RainAcc.Destroy(); m_TWI .Destroy(); return( bResult ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::Get_Flow_Proportions(int x, int y, double Proportion[8]) { if( m_pDEM->is_InGrid(x, y) ) { double Sum = 0.0; for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && m_pDEM->asDouble(x, y) > m_pDEM->asDouble(ix, iy) ) { Sum += (Proportion[i] = ((m_pDEM->asDouble(x, y) - m_pDEM->asDouble(ix, iy)) / Get_Length(i))); } else { Proportion[i] = 0.0; } } if( Sum > 0.0 ) { for(int i=0; i<8; i++) { if( Proportion[i] > 0.0 ) { Proportion[i] /= Sum; } } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::Set_Flow(void) { Process_Set_Text(_TL("initialization")); CSG_Grid *pWeight = Parameters("WEIGHT")->asGrid (); double Weight = Parameters("WEIGHT")->asDouble(); CSG_Grid *pRain = Parameters("RAIN" )->asGrid (); double Rain = Parameters("RAIN" )->asDouble(); m_FlowDir.Create(*Get_System(), SG_DATATYPE_Char); m_RainAcc.Create(*Get_System()); m_TWI .Create(*Get_System()); for(sLong n=0; nGet_Sorted(n, x, y, true) || (pRain && pRain->is_NoData(x, y)) || !Set_Flow(x, y, pRain ? pRain->asDouble(x, y) : Rain) ) { m_FlowDir .Set_NoData(x, y); m_RainAcc .Set_NoData(x, y); m_TWI .Set_NoData(x, y); m_pRisk_Point->Set_NoData(x, y); } else { double s, a; m_pDEM->Get_Gradient(x, y, s, a); s = tan(s); // tangens of slope a = (fabs(sin(a)) + fabs(cos(a))) * Get_Cellsize(); // flow width double SCA = m_RainAcc.asDouble(x, y) / a; // rain * specific catchment area m_TWI.Set_Value(x, y, log(SCA / (s < M_ALMOST_ZERO ? M_ALMOST_ZERO : s))); if( pWeight && pWeight->is_NoData(x, y) ) { m_pRisk_Point->Set_NoData(x, y); } else { m_pRisk_Point->Set_Value(x, y, SCA * s * (pWeight ? pWeight->asDouble(x, y) : Weight)); // Point Scale Risk Calculation according to Milledge et al. 2012 } } } return( true ); } //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::Set_Flow(int x, int y, double Rain) { //----------------------------------------------------- if( m_pDEM->is_NoData(x, y) ) { return( false ); } double d[8]; m_FlowDir.Set_Value(x, y, m_pDEM->Get_Gradient_NeighborDir(x, y)); m_RainAcc.Set_Value(x, y, Rain = Rain * Get_Cellarea() + m_RainAcc.asDouble(x, y)); //----------------------------------------------------- if( m_bSingle ) { if( Get_System()->Get_Neighbor_Pos(m_FlowDir.asInt(x, y), x, y, x, y) && m_pDEM->is_InGrid(x, y) ) { m_RainAcc.Add_Value(x, y, Rain); } } else if( Get_Flow_Proportions(x, y, d) ) { for(int i=0; i<8; i++) { if( d[i] > 0.0 ) { m_RainAcc.Add_Value(Get_xTo(i, x), Get_yTo(i, y), Rain * d[i]); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // Calculation according to Lane et al. 2004, p. 198. //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::Set_Delivery_Index(void) { //----------------------------------------------------- CSG_Grid Channel, *pChannel = Parameters("CHANNEL")->asGrid(); if( !pChannel ) // no channel network is provided, so create a tempory channel network out of the box! { Process_Set_Text(_TL("Channel Network")); int Threshold = Parameters("CHANNEL_START")->asInt(); pChannel = &Channel; Channel.Create(*Get_System(), SG_DATATYPE_Word); Channel.Assign(0.0); Channel.Set_NoData_Value(0.0); for(sLong n=0; nGet_Sorted(n, x, y, true) ) { if( Get_System()->Get_Neighbor_Pos(m_FlowDir.asInt(x, y), x, y, ix, iy) && m_FlowDir.is_InGrid(ix, iy) ) { Channel.Add_Value(ix, iy, 1.0 + Channel.asDouble(x, y)); } Channel.Set_Value(x, y, Channel.asInt(x, y) > Threshold ? 1.0 : 0.0); } } } //----------------------------------------------------- Process_Set_Text(_TL("Delivery Index")); for(sLong n=0; nGet_Sorted(n, x, y, false) ) // bottom up { if( m_TWI.is_InGrid(x, y) ) { TWI_min = m_TWI.asDouble(x, y); } if( m_FlowDir.is_InGrid(x, y) && Get_System()->Get_Neighbor_Pos(m_FlowDir.asInt(x, y), x, y, ix, iy) && m_TWI.is_InGrid(ix, iy) ) { if( TWI_min < 0.0 || TWI_min > m_TWI.asDouble(ix, iy) ) { TWI_min = m_TWI.asDouble(ix, iy); } } } if( TWI_min < 0.0 ) { m_pDelivery->Set_NoData(x, y); } else { m_pDelivery->Set_Value(x, y, TWI_min); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // Calculation according to Milledge et al. 2012 //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::Get_Risk_Diffuse(void) { Process_Set_Text(_TL("Difuse Pollution Risk")); m_pRisk_Diffuse->Assign(0.0); //----------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y, true) || m_pDelivery->is_NoData(x, y) || m_pRisk_Point->is_NoData(x, y) || m_RainAcc.asDouble(x, y) <= 0.0 ) { m_pRisk_Diffuse->Set_NoData(x, y); } else { double d[8], Risk; m_pRisk_Point->Mul_Value(x, y, m_pDelivery->asDouble(x, y)); // locational risk = generation risk * connection risk Risk = m_pRisk_Diffuse->asDouble(x, y) + m_pRisk_Point->asDouble(x, y); // risk load = sum of upslope locational risk m_pRisk_Diffuse->Set_Value(x, y, Risk / m_RainAcc.asDouble(x, y)); // risk concentration = risk load / sum of upslope rain if( m_bSingle ) { int i = !m_FlowDir.is_NoData(x, y) ? m_FlowDir.asInt(x, y) : -1; if( i > 0 && m_pDEM->is_InGrid(Get_xTo(i, x), Get_yTo(i, y)) ) { m_pRisk_Diffuse->Add_Value(Get_xTo(i, x), Get_yTo(i, y), Risk); } } else if( Get_Flow_Proportions(x, y, d) ) { for(int i=0; i<8; i++) { if( d[i] > 0.0 ) { m_pRisk_Diffuse->Add_Value(Get_xTo(i, x), Get_yTo(i, y), Risk * d[i]); } } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_hydrology/topmodel_values.cpp0000664000175000017500000002405212565125410027014 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topmodel_values.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // topmodel_values.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "topmodel_values.h" //--------------------------------------------------------- #define RESET_ARRAY(a) if( a ) { free(a); a = NULL; } #define RESET_MATRIX(n, m) if( n > 0 && m ) { for(int i=0; i 0 ) { for(iClass=0; iClass 0 ) { //------------------------------------------------- // 1. Topographic Index Classification etc... nClasses = anClasses; Classes = (CTOPMODEL_Class **)calloc(nClasses, sizeof(CTOPMODEL_Class *)); for(iClass=0; iClassGet_Parameter("P_SR0")->asDouble()); } zMin = pAtanB->Get_ZMin(); zRange = pAtanB->Get_ZMax() - zMin; dz = zRange / (nClasses + 1); nCells = 0; pClass->Create(pAtanB, SG_DATATYPE_Short); pClass->Set_NoData_Value(-9999); for(n=0; nGet_NCells(); n++) { if( !pAtanB->is_NoData(n) ) { nCells++; iClass = (int)((nClasses - 1.0) * (pAtanB->asDouble(n) - zMin) / zRange); Classes[iClass]->Area_Rel++; pClass->Set_Value(n, iClass); } else { pClass->Set_NoData(n); } } Area_Total = (double)nCells * pAtanB->Get_Cellsize() * pAtanB->Get_Cellsize(); for(iClass=0; iClassAtanB = zMin + dz * (iClass + 0.5); // mid of class -> + 0.5... Classes[iClass]->Area_Rel /= (double)nCells; } //------------------------------------------------- // 2. Calculate Lambda, the catchment average topographic index... for(iClass=0, Lambda=0.0; iClassArea_Rel * Classes[iClass]->AtanB; } //------------------------------------------------- // 3. Parameter Initialisation... //------------------------------------------------- p_Srz_Max = pParameters->Get_Parameter("P_SRZMAX")->asDouble(); p_Model = pParameters->Get_Parameter("P_MODEL")->asDouble(); p_Suz_TimeDelay = pParameters->Get_Parameter("P_SUZ_TD")->asDouble(); p_K0 = pParameters->Get_Parameter("P_K0")->asDouble(); p_Psi = pParameters->Get_Parameter("P_PSI")->asDouble(); p_dTheta = pParameters->Get_Parameter("P_DTHETA")->asDouble(); //------------------------------------------------- int i, j, t; double A1, A2, qs0_, // Initial subsurface flow per unit area [m/h], "The first streamflow input is assumed to represent only the subsurface flow contribution in the watershed." vch_, // Main channel routing velocity [m/h] vr_, // Internal subcatchment routing velocity [m/h] *tch_; // params.nch's //------------------------------------------------- lnTe_ = log(dTime) + pParameters->Get_Parameter("P_LNTE")->asDouble(); vch_ = dTime * pParameters->Get_Parameter("P_VCH")->asDouble(); vr_ = dTime * pParameters->Get_Parameter("P_VR")->asDouble(); qs0_ = dTime * pParameters->Get_Parameter("P_QS0")->asDouble(); _qs_ = exp(lnTe_ - Lambda); //------------------------------------------------- tch_ = (double *)malloc(Channel_Count * sizeof(double)); tch_[0] = Channel_Distance[0] / vch_; for(i=1; i tch_[Channel_Count - 1]) { Add[i] = 1.0; } else { for(j=1; jasGrid(); m_pFlow = Parameters("FLOW") ->asGrid(); m_pGauges = Parameters("GAUGES") ->asShapes(); m_pGauges_Flow = Parameters("GAUGES_FLOW") ->asTable(); Newton_MaxIter = Parameters("NEWTON_MAXITER") ->asInt(); Newton_Epsilon = Parameters("NEWTON_EPSILON") ->asDouble(); Roughness = Parameters("ROUGHNESS") ->asDouble(); if( !m_pDEM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } //----------------------------------------------------- if( Initialize(Roughness) ) { int x, y; double Time, Time_Span; Gauges_Initialise(); Time_Span = Parameters("TIME_SPAN") ->asDouble(); m_dTime = Parameters("TIME_STEP") ->asDouble(); for(Time=0.0; Time<=Time_Span && Process_Get_Okay(false); Time+=m_dTime) { Process_Set_Text(CSG_String::Format(SG_T("%s [h]: %f (%f)"), _TL("Simulation Time"), Time, Time_Span)); Get_Precipitation(Time); m_Flow_Last.Assign(m_pFlow); m_pFlow->Assign(0.0); for(sLong n=0; nGet_NCells() && Process_Get_Okay(false); n++) { if( m_pDEM->Get_Sorted(n, x, y) ) { Get_Runoff(x, y); } else { m_pFlow->Set_NoData(x, y); } } DataObject_Update(m_pFlow, 0.0, 100.0); Gauges_Set_Flow(Time); } //------------------------------------------------- Finalize(); return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CKinWav_D8::Get_Runoff(int x, int y) { int Direction = m_Direction.asChar(x, y); if( Direction >= 0 ) { m_pFlow->Set_Value(x, y, Get_Runoff( m_pFlow ->asDouble(x, y), m_Flow_Last .asDouble(x, y), m_Alpha .asDouble(x, y), Get_UnitLength(Direction), 0.0, 0.0 ) ); m_pFlow->Add_Value(Get_xTo(Direction, x), Get_yTo(Direction, y), m_Flow_Last.asDouble(x, y)); } } //--------------------------------------------------------- double CKinWav_D8::Get_Runoff(double q_Up, double q_Last, double alpha, double dL, double r, double r_Last) { double dTdL, d, c, q, Res, dRes, dR; //----------------------------------------------------- dTdL = m_dTime / dL; dR = m_dTime / 2.0 * (r + r_Last); //----------------------------------------------------- // 1. Initial estimation of q... if( q_Last + q_Up != 0.0 ) { d = alpha * Beta_0 * pow((q_Last + q_Up) / 2.0, Beta_1); q = ( dTdL * q_Up + q_Last * d + dR ) / ( dTdL + d ); } else { q = dR; } //----------------------------------------------------- // 2. Newton-Raphson... c = dTdL * q_Up + alpha * pow(q_Last, Beta_0) + dR; for(int i=0; iAssign(0.0); DataObject_Set_Colors(m_pFlow, 100, SG_COLORS_WHITE_BLUE); DataObject_Update(m_pFlow, 0.0, 100.0, SG_UI_DATAOBJECT_SHOW); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { int i, ix, iy, iMax; double z, d, dMax; for(i=0, iMax=-1, dMax=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && (d = (z - m_pDEM->asDouble(ix, iy)) / Get_Length(i)) > dMax ) { dMax = d; iMax = i; } } if( iMax < 0 ) { m_Direction .Set_NoData(x, y); } else { m_Direction .Set_Value(x, y, iMax); m_Alpha .Set_Value(x, y, pow(Roughness / sqrt(dMax), Beta_0)); if( m_Alpha.asDouble(x, y) > 10 ) m_Alpha.Set_Value(x, y, 10); } } } } return( true ); } //--------------------------------------------------------- bool CKinWav_D8::Finalize(void) { m_Direction .Destroy(); m_Alpha .Destroy(); m_Flow_Last .Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKinWav_D8::Gauges_Initialise(void) { if( m_pGauges_Flow != NULL ) { if( m_pGauges == NULL ) { DataObject_Add(m_pGauges = SG_Create_Shapes(SHAPE_TYPE_Point, _TL("Gauges"))); Parameters("GAUGES")->Set_Value(m_pGauges); m_pGauges->Add_Field(_TL("ID"), SG_DATATYPE_Int); for(int y=0; yis_InGrid(ix, iy) ) { bBorder = true; } else if( m_pDEM->asDouble(ix, iy) < m_pDEM->asDouble(x, y) ) { bLowest = false; } } if( bLowest && bBorder ) { CSG_Shape *pGauge = m_pGauges->Add_Shape(); pGauge->Add_Point(Get_System()->Get_Grid_to_World(x, y)); pGauge->Set_Value(0, m_pGauges->Get_Count() + 1); } } } } m_pGauges_Flow->Destroy(); m_pGauges_Flow->Set_Name(_TL("Outlet Hydrographs")); m_pGauges_Flow->Add_Field("TIME", SG_DATATYPE_Double); for(int i=0; iGet_Count(); i++) { m_pGauges_Flow->Add_Field(CSG_String::Format(SG_T("GAUGE_%02d"), i + 1), SG_DATATYPE_Double); } return( true ); } return( false ); } //--------------------------------------------------------- bool CKinWav_D8::Gauges_Set_Flow(double Time) { if( m_pGauges_Flow && m_pGauges_Flow->Get_Field_Count() == m_pGauges->Get_Count() + 1 ) { CSG_Table_Record *pRecord = m_pGauges_Flow->Add_Record(); pRecord->Set_Value(0, Time); for(int i=0; iGet_Count(); i++) { double Flow; if( m_pFlow->Get_Value(m_pGauges->Get_Shape(i)->Get_Point(0), Flow) ) { pRecord->Set_Value(i + 1, Flow); } } DataObject_Update(m_pGauges_Flow); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CKinWav_D8::Get_Precipitation(double Time) { if( Time == 0.0 ) { int x, y; double t; switch( Parameters("PRECIP")->asInt() ) { case 0: (*m_pFlow) += 100.0; break; case 1: t = Parameters("THRESHOLD")->asDouble(); for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { if( !m_pDEM->is_NoData(x, y) && m_pDEM->asDouble(x, y) > t ) { m_pFlow->Add_Value(x, y, 100.0); } } } break; case 2: for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX() / 2; x++) { if( !m_pDEM->is_NoData(x, y) ) { m_pFlow->Add_Value(x, y, 100.0); } } } break; } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_hydrology/WaterRetentionCapacity.cpp0000664000175000017500000001562012565125410030243 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: WaterRetentionCapacity.cpp 966 2011-03-25 00:40:53Z johanvdw $ *********************************************************/ /******************************************************************************* WaterRetentionCapacity.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "idw.h" #include "WaterRetentionCapacity.h" CWaterRetentionCapacity::CWaterRetentionCapacity(void){ Parameters.Set_Name(_TL("Water Retention Capacity")); Parameters.Set_Description(_TW( "(c) 2004 Victor Olaya. Water Retention Capacity (Gandullo, 1994)")); Parameters.Add_Shapes(NULL, "SHAPES", _TL("Plot Holes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Shapes(NULL, "OUTPUT", _TL("Final Parameters"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "DEM", _TL("DEM"), _TL("DEM"), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "RETENTION", _TL("Water Retention Capacity"), _TL(""), PARAMETER_OUTPUT); }//constructor CWaterRetentionCapacity::~CWaterRetentionCapacity(void) {} bool CWaterRetentionCapacity::On_Execute(void){ int i,j; int x,y; int iField; int iShape; int iRows; float fValue = 0; float **pData; int iX, iY; float fC; double dSlope,dAspect; CSG_Shape* pShape; CSG_Shapes* pShapes = Parameters("SHAPES")->asShapes(); CSG_Grid* pDEM = Parameters("DEM")->asGrid(); m_pRetention = Parameters("RETENTION")->asGrid(); m_pSlope = SG_Create_Grid(pDEM); m_pOutput = Parameters("OUTPUT")->asShapes(); m_pOutput->Assign(pShapes); m_pOutput->Add_Field("CCC", SG_DATATYPE_Double); m_pOutput->Add_Field("CIL", SG_DATATYPE_Double); m_pOutput->Add_Field(_TL("Permeability"), SG_DATATYPE_Double); m_pOutput->Add_Field(_TL("Equivalent Moisture"), SG_DATATYPE_Double); m_pOutput->Add_Field(_TL("Water Retention Capacity"), SG_DATATYPE_Double); for(y=0; yGet_Gradient(x, y, dSlope, dAspect) ){ m_pSlope->Set_Value(x, y, dSlope); } else{ m_pSlope->Set_NoData(x, y); } } } iRows = pShapes->Get_Field_Count() / 5; pData = new float*[iRows]; for (iShape = 0; iShape < pShapes->Get_Count(); iShape++){ pShape = pShapes->Get_Shape(iShape); for (i = 0; i< iRows; i++){ pData[i] = new float[5]; for (j = 0; j < 5; j++){ pData[i][j] = 0; try{ pData[i][j] = pShape->asFloat(j+i*5); }//try catch(...){} }//for }//for iX = (int)((pShape->Get_Point(0).x - pDEM->Get_XMin())/pDEM->Get_Cellsize()); iY = (int)((pShape->Get_Point(0).y - pDEM->Get_YMin())/pDEM->Get_Cellsize()); fC = (float)(1. - tan(m_pSlope->asFloat(iX,iY))); pShape = m_pOutput->Get_Shape(iShape); CalculateWaterRetention(pData, iRows, fC, pShape); }//for iField = m_pOutput->Get_Field_Count()-1; CIDW IDW; IDW.setParameters(m_pRetention, m_pOutput, iField); IDW.Interpolate(); CorrectWithSlope(); return true; }//method void CWaterRetentionCapacity::CalculateWaterRetention(float **pData, int iNumHorizons, float fC, CSG_Table_Record *pRecord){ int i; int iField; float *pCCC = new float[iNumHorizons]; float *pCIL = new float[iNumHorizons]; float *pK = new float[iNumHorizons]; int *pPerm = new int[iNumHorizons]; float *pHe = new float[iNumHorizons]; float *pCRA = new float[iNumHorizons]; float fTotalDepth = 0; float fWaterRetention = 0; float fPerm = 0; float fHe = 0; float fK = 0; float fCCC = 0; float fCIL = 0; pK[0] = 0; for (i = 0; i < iNumHorizons; i++){ pCCC[i] = CalculateCCC(pData[i]); pCIL[i] = CalculateCIL(pData[i]); pPerm[i] = CalculatePermeability(pCCC[i], pCIL[i]); pHe[i] = CalculateHe(pData[i]); if (i){ pK[i] = CalculateK(pPerm[i-1], pPerm[i], fC); }//if pCRA[i] = (float)((12.5 * pHe[i] + 12.5 * (50. - pHe[i]) * pK[i] / 2.) * pData[i][1] / 100.); fTotalDepth += pData[i][0]; }//for for (i = 0; i < iNumHorizons; i++){ fWaterRetention += pData[i][0] / fTotalDepth * pCRA[i]; fCCC += pData[i][0] / fTotalDepth * pCCC[i]; fCIL += pData[i][0] / fTotalDepth * pCIL[i]; fPerm += pData[i][0] / fTotalDepth * pPerm[i]; fHe += pData[i][0] / fTotalDepth * pHe[i]; fK += pData[i][0] / fTotalDepth * pK[i]; }//for iField = pRecord->Get_Table()->Get_Field_Count() - 1; pRecord->Set_Value(iField - 4, fCCC); pRecord->Set_Value(iField - 3, fCIL); pRecord->Set_Value(iField - 2, fPerm); pRecord->Set_Value(iField - 1, fHe); pRecord->Set_Value(iField, fWaterRetention); delete[]pCRA; }//method void CWaterRetentionCapacity::CorrectWithSlope(){ int x,y; float fC; for (x = 0; x < m_pRetention->Get_NX(); x++) { for (y = 0; y < m_pRetention->Get_NY(); y++) { fC = (float)(1. - tan(m_pSlope->asFloat(x,y))); if (fC < 0.){ fC = 0.; }//if m_pRetention->Set_Value(x,y,m_pRetention->asFloat(x,y) * fC); }//for }//for }//method float CWaterRetentionCapacity::CalculateHe(float* pHorizon){ float fL = pHorizon[2]; float fTF = pHorizon[1]; float fAr = pHorizon[3]; float fMO = pHorizon[4]; float fHe = (float)(4.6 + 0.43 * fAr + 0.25 * fL + 1.22 * fMO); return fHe; }//method float CWaterRetentionCapacity::CalculateCIL(float* pHorizon){ float fL = pHorizon[2]; float fTF = pHorizon[1]; float fCIL = (float)((fL * fTF) /10000.); return fCIL; }//method float CWaterRetentionCapacity::CalculateCCC(float* pHorizon){ float fL = pHorizon[2]; float fTF = pHorizon[1]; float fAr = pHorizon[3]; float fMO = pHorizon[4]; float fCCC = (float)((fAr - 4.*fMO) / fTF); return fCCC; }//method float CWaterRetentionCapacity::CalculateK(int iPermI, int iPermS, float fC){ float fAi = (float)((iPermI - 1) * .2); float fAs = (float)((iPermS - 1) * .2); return (float)((1. - fAi - (1 + fAs) * (1. - fC))); }//method int CWaterRetentionCapacity::CalculatePermeability(float fCCC, float fCIL){ int iPerm; if (fCCC < 0.15){ iPerm = 5 - (int)((fCIL-0.1) / 0.15); }//if else if (fCIL < 0.2){ iPerm = 5 - (int)(fCCC / 0.15); }//else if else{ iPerm = (int)(5 - (fCCC + fCIL - 0.1) / 0.15); }//else if (iPerm < 1){ iPerm = 1; }//if return iPerm; }//method saga-2.2.3/src/modules/simulation/sim_hydrology/KinWav_D8.h0000664000175000017500000001144212565125410025010 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: KinWav_D8.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // KinWav_D8.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__KinWav_D8_H #define HEADER_INCLUDED__KinWav_D8_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CKinWav_D8 : public CSG_Module_Grid { public: CKinWav_D8(void); protected: virtual bool On_Execute (void); private: double m_dTime, Newton_MaxIter, Newton_Epsilon; CSG_Grid *m_pDEM, *m_pFlow, m_Direction, m_Alpha, m_Flow_Last; CSG_Table *m_pGauges_Flow; CSG_Shapes *m_pGauges; void Get_Runoff (int x, int y); double Get_Runoff (double q_Up, double q_Last, double alpha, double dL, double r, double r_Last); bool Initialize (double Roughness); bool Finalize (void); bool Gauges_Initialise (void); bool Gauges_Set_Flow (double Time); void Get_Precipitation (double Time); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__KinWav_D8_H saga-2.2.3/src/modules/simulation/sim_hydrology/topmodel_values.h0000664000175000017500000001426412565125410026465 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topmodel_values.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // topmodel_values.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__topmodel_values_H #define HEADER_INCLUDED__topmodel_values_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTOPMODEL_Class { public: CTOPMODEL_Class(double Srz_Init); virtual ~CTOPMODEL_Class(void); double qt_, qo_, qv_, Srz_, Suz_, S_, AtanB, Area_Rel; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTOPMODEL_Values { public: CTOPMODEL_Values(void); virtual ~CTOPMODEL_Values(void); int ndelay_, nreach_; double qt_Total, qo_Total, qv_Total, qs_Total, lnTe_, _qs_, *Add, // nreach_'s: *Qt_, // input.ntimestep's: Sbar_, p_Srz_Max, // Maximum root zone storage deficit [m] p_Model, // Model parameter m... p_Suz_TimeDelay, // Unsaturated zone time delay per unit storage deficit ( > 0.0) [h] // OR -alpha: Effective vertical hydraulic gradient ( <= 0.0); -10 means that alpha = 10 p_K0, // Surface hydraulic conductivity [m/h] p_Psi, // Wetting front suction [m] p_dTheta; // Water content change across the wetting front void Create(double dTime, int anTimeSteps, CSG_Parameters *pParameters, CSG_Grid *pAtanB, int anClasses, CSG_Grid *pClass); void Destroy(void); //----------------------------------------------------- int Get_Count(void) { return( nClasses ); } //----------------------------------------------------- double Get_Area_Total(void) { return( Area_Total ); } //----------------------------------------------------- CTOPMODEL_Class * Get_Class(int iClass) { if( iClass >= 0 && iClass < nClasses ) { return( Classes[iClass] ); } return( NULL ); } //----------------------------------------------------- double Get_Lambda(void) { return( Lambda ); } private: int nClasses, Channel_Count; double Lambda, *Channel_Distance, *Channel_AreaRatio, Area_Total; // Total catchment area [m^2] CTOPMODEL_Class **Classes; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__topmodel_values_H saga-2.2.3/src/modules/simulation/sim_hydrology/Makefile.in0000664000175000017500000005576412622651173025175 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/simulation/sim_hydrology DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_hydrology_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_hydrology_la_OBJECTS = DVWK_SoilMoisture.lo \ diffuse_pollution_risk.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) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_hydrology_la_SOURCES) DIST_SOURCES = $(libsim_hydrology_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_hydrology.la libsim_hydrology_la_SOURCES = \ DVWK_SoilMoisture.cpp\ diffuse_pollution_risk.cpp\ idw.cpp\ KinWav_D8.cpp\ MLB_Interface.cpp\ topmodel.cpp\ topmodel_values.cpp\ WaterRetentionCapacity.cpp\ diffuse_pollution_risk.h\ DVWK_SoilMoisture.h\ idw.h\ KinWav_D8.h\ MLB_Interface.h\ topmodel.h\ topmodel_values.h\ WaterRetentionCapacity.h libsim_hydrology_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) --foreign src/modules/simulation/sim_hydrology/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_hydrology/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_hydrology.la: $(libsim_hydrology_la_OBJECTS) $(libsim_hydrology_la_DEPENDENCIES) $(EXTRA_libsim_hydrology_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_hydrology_la_OBJECTS) $(libsim_hydrology_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DVWK_SoilMoisture.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/KinWav_D8.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WaterRetentionCapacity.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diffuse_pollution_risk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idw.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/topmodel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/topmodel_values.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/simulation/sim_hydrology/diffuse_pollution_risk.h0000664000175000017500000001120412565125410030034 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: diffuse_pollution_risk.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // diffuse_pollution_risk.h // // // // Copyright (C) 2015 by // // Cosima Berger // // // //-------------------------------------------------------// // // // 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@saga-gis.de // // // // contact: Cosima Berger // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__diffuse_pollution_risk_H #define HEADER_INCLUDED__diffuse_pollution_risk_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDiffuse_Pollution_Risk : public CSG_Module_Grid { public: CDiffuse_Pollution_Risk(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool m_bSingle; CSG_Grid *m_pDEM, m_FlowDir, m_RainAcc, m_TWI, *m_pDelivery, *m_pRisk_Point, *m_pRisk_Diffuse; bool Get_Flow_Proportions (int x, int y, double Proportion[8]); bool Set_Flow (void); bool Set_Flow (int x, int y, double Rain); bool Set_Delivery_Index (void); bool Get_Risk_Diffuse (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__diffuse_pollution_risk_H saga-2.2.3/src/modules/simulation/sim_hydrology/topmodel.cpp0000664000175000017500000004641012565125410025437 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topmodel.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // topmodel.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "topmodel.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTOPMODEL::CTOPMODEL(void) { CSG_Parameter *pNode; //----------------------------------------------------- // Place information about your module here... Set_Name (_TL("TOPMODEL")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Simple Subcatchment Version of TOPMODEL\n\n" "Based on the 'TOPMODEL demonstration program v95.02' by Keith Beven " "(Centre for Research on Environmental Systems and Statistics, " "Institute of Environmental and Biological Sciences, " "Lancaster University, Lancaster LA1 4YQ, UK) " "and the C translation of the Fortran source codes implementated in GRASS.\n\n" "This program allows single or multiple subcatchment calculations " "but with single average rainfall and potential evapotranspiration " "inputs to the whole catchment. Subcatchment discharges are routed " "to the catchment outlet using a linear routing algorithm with " "constant main channel velocity and internal subcatchment " "routing velocity. The program requires ln(a/tanB) distributions " "for each subcatchment. These may be calculated using the " "GRIDATB program which requires raster elevation data as input. " "It is recommended that those data should be 50 m resolution or " "better.\n\n" "NOTE that TOPMODEL is not intended to be a traditional model " "package but is more a collection of concepts that can be used " "**** where appropriate ****. It is up to the user to verify that " "the assumptions are appropriate (see discussion in " "Beven et al.(1994). This version of the model will be " "best suited to catchments with shallow soils and moderate " "topography which do not suffer from excessively long dry " "periods. Ideally predicted contributing areas should be " "checked against what actually happens in the catchment.\n\n" "It includes infiltration excess calculations and parameters " "based on the exponential conductivity Green-Ampt model of " "Beven (HSJ, 1984) but if infiltration excess does occur it " "does so over whole area of a subcatchment. Spatial variability " "in conductivities can however be handled by specifying " "Ko parameter values for different subcatchments, even if they " "have the same ln(a/tanB) and routing parameters, ie. to " "represent different parts of the area.\n\n" "Note that time step calculations are explicit ie. SBAR " "at start of time step is used to determine contributing area. " "Thus with long (daily) time steps contributing area depends on " "initial value together with any volume filling effect of daily " "inputs. Also baseflow at start of time step is used to update " "SBAR at end of time step." "\n\nReferences\n" "- Beven, K., Kirkby, M.J., Schofield, N., Tagg, A.F. (1984): " " Testing a physically-based flood forecasting model (TOPMODEL) for threee U.K. catchments, " " Journal of Hydrology, H.69, S.119-143.\n" "\n" "- Beven, K. (1997): " " TOPMODEL - a critique, " " Hydrological Processes, Vol.11, pp.1069-1085.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "ATANB" , _TL("Topographic Wetness Index"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "MOIST" , _TL("Soil Moisture Deficit"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); pNode = Parameters.Add_Table( NULL , "WEATHER" , _TL("Weather Records"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "RECORD_P" , _TL("Precipitation [m / dt]"), _TL("") ); Parameters.Add_Table_Field( pNode , "RECORD_ET" , _TL("Evapotranspiration [m / dt]"), _TL("") ); Parameters.Add_Table_Field( pNode , "RECORD_DATE" , _TL("Date/Time"), _TL(""), true ); Parameters.Add_Table( NULL , "TABLE" , _TL("Simulation Output"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "DTIME" , _TL("Time Step [h]"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "NCLASSES" , _TL("Number of Classes"), _TL(""), PARAMETER_TYPE_Int , 30 , 1 , true ); pNode = NULL; // = Parameters("MOIST"); Parameters.Add_Value( pNode, "P_QS0" , _TL("Initial subsurface flow per unit area [m/h]"), _TL(""), PARAMETER_TYPE_Double , 3.28e-05 ); Parameters.Add_Value( pNode, "P_LNTE" , _TL("Areal average of ln(T0) = ln(Te) [ln(m^2/h)]"), _TL(""), PARAMETER_TYPE_Double , 5.0 ); Parameters.Add_Value( pNode, "P_MODEL" , _TL("Model parameter [m]"), _TL(""), PARAMETER_TYPE_Double , 0.032 ); Parameters.Add_Value( pNode, "P_SR0" , _TL("Initial root zone storage deficit [m]"), _TL(""), PARAMETER_TYPE_Double , 0.002 ); Parameters.Add_Value( pNode, "P_SRZMAX" , _TL("Maximum root zone storage deficit [m]"), _TL(""), PARAMETER_TYPE_Double , 0.05 ); Parameters.Add_Value( pNode, "P_SUZ_TD" , _TL("Unsaturated zone time delay per unit storage deficit [h]"), _TL(""), PARAMETER_TYPE_Double , 50.0 ); Parameters.Add_Value( pNode, "P_VCH" , _TL("Main channel routing velocity [m/h]"), _TL(""), PARAMETER_TYPE_Double , 3600.0 ); Parameters.Add_Value( pNode, "P_VR" , _TL("Internal subcatchment routing velocity [m/h]"), _TL(""), PARAMETER_TYPE_Double , 3600.0 ); Parameters.Add_Value( pNode, "P_K0" , _TL("Surface hydraulic conductivity [m/h]"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( pNode, "P_PSI" , _TL("Wetting front suction [m]"), _TL(""), PARAMETER_TYPE_Double , 0.02 ); Parameters.Add_Value( pNode, "P_DTHETA" , _TL("Water content change across the wetting front"), _TL(""), PARAMETER_TYPE_Double , 0.1 ); Parameters.Add_Value( pNode, "BINF" , _TL("Green-Ampt Infiltration"), _TL(""), PARAMETER_TYPE_Bool , true ); } //--------------------------------------------------------- CTOPMODEL::~CTOPMODEL(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTOPMODEL::On_Execute(void) { bool bInfiltration; sLong n; int iClass, nClasses, iTime, nTimeSteps, k; double Precipitation, Evaporation, Infiltration, Infiltration_Excess; CSG_String Time; CSG_Grid *pAtanB, *pMoist, gClass; CSG_Table_Record *pRecord; CSG_Table *pTable; //----------------------------------------------------- // Get user inputs from the 'Parameters' object... pAtanB = Parameters("ATANB") ->asGrid(); m_pWeather = Parameters("WEATHER") ->asTable(); m_fP = Parameters("RECORD_P") ->asInt(); m_fET = Parameters("RECORD_ET") ->asInt(); m_fTime = Parameters("RECORD_DATE") ->asInt(); dTime = Parameters("DTIME") ->asDouble(); nClasses = Parameters("NCLASSES") ->asInt(); bInfiltration = Parameters("BINF") ->asBool(); nTimeSteps = m_pWeather->Get_Record_Count(); if( (pMoist = Parameters("MOIST")->asGrid()) != NULL ) { pMoist->Set_Name(_TL("Soil Moisture Deficit")); DataObject_Set_Colors(pMoist, 100, SG_COLORS_RED_GREY_BLUE, true); } //----------------------------------------------------- pTable = Parameters("TABLE")->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("TOPMODEL - Simulation Output")); pTable->Add_Field(_TL("Time") , SG_DATATYPE_String); pTable->Add_Field(_TL("Total flow (in watershed) [m^3/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Total flow [m/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Saturation overland flow [m/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Subsurface flow [m/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Vertical (drainage) flux [m/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Mean saturation deficit (in watershed) [m]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Infiltration rate [m/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Infiltration excess runoff [m/dt]") , SG_DATATYPE_Double); //----------------------------------------------------- Vals.Create(dTime, nTimeSteps, &Parameters, pAtanB, nClasses, &gClass); //----------------------------------------------------- inf_bPonding = false; inf_cumf = 0.0; for(iTime=0; iTime 0.0 ) { Infiltration = dTime * Get_Infiltration((iTime + 1) * dTime, Precipitation / dTime); Infiltration_Excess = Precipitation - Infiltration; Precipitation = Infiltration; } else { Infiltration = 0.0; Infiltration_Excess = 0.0; } Run(Evaporation, Precipitation, Infiltration_Excess); for(iClass=0; iClass nTimeSteps - 1 ) break; Vals.Qt_[k] += Vals.qt_Total * Vals.Add[iClass]; } if( pMoist ) { for(n=0; n= 0 && iClass < nClasses ) { pMoist->Set_Value(n, Vals.Get_Class(iClass)->S_); } else { pMoist->Set_NoData(n); } } // DataObject_Update(pMoist); DataObject_Update(pMoist, 0, 0.35, true); } pRecord = pTable->Add_Record(); pRecord->Set_Value(0, Time); // Time pRecord->Set_Value(1, Vals.Qt_[iTime]); // QT pRecord->Set_Value(2, Vals.qt_Total); // qt pRecord->Set_Value(3, Vals.qo_Total); // q0 pRecord->Set_Value(4, Vals.qs_Total); // qs pRecord->Set_Value(5, Vals.qv_Total); // qv pRecord->Set_Value(6, Vals.Sbar_); // SBar pRecord->Set_Value(7, Infiltration); // Infiltration pRecord->Set_Value(8, Infiltration_Excess); // Infiltration Excess DataObject_Update(pTable); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTOPMODEL::Run(double Evaporation, double Precipitation, double Infiltration_Excess) { int iClass; double d, Excess; CTOPMODEL_Class *pClass; Vals.qo_Total = 0.0; Vals.qv_Total = 0.0; Vals.qs_Total = Vals._qs_ * exp(-Vals.Sbar_ / Vals.p_Model); for(iClass=0; iClassS_ = Vals.Sbar_ + Vals.p_Model * (Vals.Get_Lambda() - pClass->AtanB); if( pClass->S_ < 0.0 ) { pClass->S_ = 0.0; } //------------------------------------------------- // ROOT ZONE CALCULATIONS pClass->Srz_ -= Precipitation; if( pClass->Srz_ < 0.0 ) { pClass->Suz_ -= pClass->Srz_; pClass->Srz_ = 0.0; } //------------------------------------------------- // UNSATURATED ZONE CALCULATIONS if( pClass->Suz_ > pClass->S_ ) { Excess = pClass->Suz_ - pClass->S_; pClass->Suz_ = pClass->S_; } else { Excess = 0.0; } //------------------------------------------------- // CALCULATE DRAINAGE FROM SUZ (Vertical Soil Water Flux (qv))... if( pClass->S_ > 0.0 ) { if( Vals.p_Suz_TimeDelay > 0.0 ) { // Methode 1... d = pClass->Suz_ / (pClass->S_ * Vals.p_Suz_TimeDelay) * dTime; // GRASS } else { // Methode 2... d = -Vals.p_Suz_TimeDelay * Vals.p_K0 * exp(-pClass->S_ / Vals.p_Model); } if( d > pClass->Suz_ ) { d = pClass->Suz_; } pClass->Suz_ -= d; if( pClass->Suz_ < 0.0000001 ) { pClass->Suz_ = 0.0; } pClass->qv_ = d * pClass->Area_Rel; Vals.qv_Total += pClass->qv_; } else { pClass->qv_ = 0.0; } //------------------------------------------------- // CALCULATE EVAPOTRANSPIRATION FROM ROOT ZONE DEFICIT if( Evaporation > 0.0 ) { d = Evaporation * (1.0 - pClass->Srz_ / Vals.p_Srz_Max); if( d > Vals.p_Srz_Max - pClass->Srz_ ) { d = Vals.p_Srz_Max - pClass->Srz_; } pClass->Srz_ += d; } //------------------------------------------------- pClass->qo_ = Excess * pClass->Area_Rel; Vals.qo_Total += pClass->qo_; pClass->qt_ = pClass->qo_ + Vals.qs_Total; } Vals.qo_Total += Infiltration_Excess; Vals.qt_Total = Vals.qo_Total + Vals.qs_Total; Vals.Sbar_ += Vals.qs_Total - Vals.qv_Total; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTOPMODEL::Get_Weather(int iTimeStep, double &Precipitation, double &Evaporation, CSG_String &Time) { CSG_Table_Record *pRecord; if( m_pWeather && (pRecord = m_pWeather->Get_Record(iTimeStep)) != NULL ) { Precipitation = pRecord->asDouble(m_fP); Evaporation = pRecord->asDouble(m_fET); if( m_fTime >= 0 ) { Time = pRecord->asString(m_fTime); } else { Time.Printf(SG_T("%d"), iTimeStep); } return( true ); } Precipitation = 0.0; Evaporation = 0.0; return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define NEWTON_EPSILON 0.001 #define NEWTON_MAXITER 100 #define NEWTON_NTERMS 10 //--------------------------------------------------------- double CTOPMODEL::Get_Infiltration(double t, double R) { int i, j, factorial; double f, f_, f1, f2, fc, R2, cnst, pt, psi_dtheta, sum; if( R <= 0.0 ) { inf_cumf = 0.0; inf_bPonding = 0; return( 0.0 ); } psi_dtheta = Vals.p_Psi * Vals.p_dTheta; if( !inf_bPonding ) { if( inf_cumf ) { f1 = inf_cumf; R2 = -Vals.p_K0 / Vals.p_Model * (psi_dtheta + f1) / (1 - exp(f1 / Vals.p_Model)); if( R2 < R ) { f_ = inf_cumf; pt = t - dTime; inf_bPonding = 1; goto cont1; } } f2 = inf_cumf + R * dTime; R2 = -Vals.p_K0 / Vals.p_Model * (psi_dtheta + f2) / (1 - exp(f2 / Vals.p_Model)); if( f2 == 0.0 || R2 > R ) { f = R; inf_cumf += f * dTime; inf_bPonding = 0; return( f ); } f_ = inf_cumf + R2 * dTime; for(i=0; i R ) { f1 = f_; f_ = (f_ + f2) / 2.0; f = f_ - f1; } else { f2 = f_; f_ = (f_ + f1) / 2.0; f = f_ - f2; } if( fabs(f) < NEWTON_EPSILON ) break; } if( i == NEWTON_MAXITER ) { // G_set_d_null_value(&f, 1); return( 0.0 ); } pt = t - dTime + (f_ - inf_cumf) / R; if( pt > t ) { f = R; inf_cumf += f * dTime; inf_bPonding = 0; return( f ); } cont1: cnst = 0.0; factorial = 1; fc = (f_ + psi_dtheta); for(j=1; j<=NEWTON_NTERMS; j++) { factorial *= j; cnst += pow(fc / Vals.p_Model, (double) j) / (double) (j * factorial); } cnst = log(fc) - (log(fc) + cnst) / exp(psi_dtheta / Vals.p_Model); f_ += R * (t - pt) / 2.0; inf_bPonding = 1; } for(i=0; i 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CWaterRetentionCapacity : public CSG_Module_Grid { public: CWaterRetentionCapacity(void); virtual ~CWaterRetentionCapacity(void); private: CSG_Grid *m_pSlope; CSG_Grid *m_pRetention; CSG_Shapes *m_pOutput; void CalculateWaterRetention(float**,int, float, CSG_Table_Record*); void CorrectWithSlope(); float CalculateCCC(float*); float CalculateCIL(float*); int CalculatePermeability(float, float); float CalculateHe(float*); float CalculateK(int,int,float); protected: virtual bool On_Execute(void); }; saga-2.2.3/src/modules/simulation/sim_hydrology/topmodel.h0000664000175000017500000001123312565125410025077 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topmodel.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // topmodel.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__topmodel_H #define HEADER_INCLUDED__topmodel_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "topmodel_values.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTOPMODEL : public CSG_Module_Grid { public: CTOPMODEL(void); virtual ~CTOPMODEL(void); protected: virtual bool On_Execute(void); private: int m_fP, m_fET, m_fTime; double dTime, inf_cumf, inf_bPonding; CSG_Table *m_pWeather; CTOPMODEL_Values Vals; void Run(double Evaporation, double Infiltration, double Infiltration_Excess); bool Get_Weather(int iTimeStep, double &Precipitation, double &Evaporation, CSG_String &Date); double Get_Infiltration(double t, double R); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__topmodel_H saga-2.2.3/src/modules/simulation/sim_hydrology/MLB_Interface.cpp0000664000175000017500000001165012565125410026204 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Hydrology") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2001") ); case MLB_INFO_Description: return( _TL("Modelling hydrological processes.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Hydrology") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "DVWK_SoilMoisture.h" #include "KinWav_D8.h" #include "topmodel.h" #include "WaterRetentionCapacity.h" #include "diffuse_pollution_risk.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CDVWK_SoilMoisture ); case 1: return( new CKinWav_D8 ); case 2: return( new CTOPMODEL ); case 3: return( new CWaterRetentionCapacity ); case 4: return( new CDiffuse_Pollution_Risk ); case 5: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/simulation/sim_hydrology/Makefile.am0000664000175000017500000000152412565125410025141 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_hydrology.la libsim_hydrology_la_SOURCES =\ DVWK_SoilMoisture.cpp\ diffuse_pollution_risk.cpp\ idw.cpp\ KinWav_D8.cpp\ MLB_Interface.cpp\ topmodel.cpp\ topmodel_values.cpp\ WaterRetentionCapacity.cpp\ diffuse_pollution_risk.h\ DVWK_SoilMoisture.h\ idw.h\ KinWav_D8.h\ MLB_Interface.h\ topmodel.h\ topmodel_values.h\ WaterRetentionCapacity.h libsim_hydrology_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/simulation/sim_hydrology/MLB_Interface.h0000664000175000017500000000773112565125410025656 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__sim_hydrology_H #define HEADER_INCLUDED__sim_hydrology_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef sim_hydrology_EXPORTS #define sim_hydrology_EXPORT _SAGA_DLL_EXPORT #else #define sim_hydrology_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__sim_hydrology_H saga-2.2.3/src/modules/simulation/sim_hydrology/idw.cpp0000664000175000017500000000454512565125410024402 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: idw.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* IDW.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "idw.h" CIDW::CIDW() { } CIDW::~CIDW() { } void CIDW::setParameters(CSG_Grid* pGrid, CSG_Shapes *pPoints, int iField){ m_pGrid = pGrid; m_pPoints = pPoints; m_iField = iField; }//method void CIDW::Interpolate(){ int x,y; for(y=0; yGet_NY(); y++){ for(x=0; xGet_NX(); x++){ Get_Grid_Value(x,y); }// for }// for }//method //--------------------------------------------------------- bool CIDW::Get_Grid_Value(int x, int y) { int iPoint, nPoints; double zSum, dSum, d, dx, xPos, yPos; TSG_Point Point; CSG_Shape *pPoint; nPoints = m_pPoints->Get_Count(); xPos = m_pGrid->Get_XMin() + x * m_pGrid->Get_Cellsize(); yPos = m_pGrid->Get_YMin() + y * m_pGrid->Get_Cellsize(); for(iPoint=0, zSum=0.0, dSum=0.0; iPointGet_Shape(iPoint); Point = pPoint->Get_Point(0); dx = Point.x - xPos; d = Point.y - yPos; d = sqrt(dx*dx + d*d); if( d <= 0.0 ){ m_pGrid->Set_Value(x, y, pPoint->asDouble(m_iField) ); return( true ); }//if d = pow(d, -2); zSum += d * pPoint->asDouble(m_iField); dSum += d; }//for if( dSum > 0.0 ){ m_pGrid->Set_Value(x, y, zSum / dSum ); return( true ); }//if m_pGrid->Set_NoData(x, y); return( false ); }//methodsaga-2.2.3/src/modules/simulation/sim_hydrology/DVWK_SoilMoisture.cpp0000664000175000017500000004241012565125410027101 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: DVWK_SoilMoisture.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // DVWK_SoilMoisture.cpp // // // // Copyright (C) 2002 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "DVWK_SoilMoisture.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDVWK_SoilMoisture::CDVWK_SoilMoisture(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Soil Moisture Content")); Set_Author (SG_T("(c) 2002 by O.Conrad")); Set_Description (_TW( "The WEELS (Wind Erosion on European Light Soils) soil moisture " "model dynamically calculates the soil moisture based on the rules " "proposed by the DVWK (1996) with input data about:\n" "- soil properties (grids: field capacity and permanent wilting point)\n" "- land use (grid: crop types)\n" "- climate (table: daily values of precipitation, temperature, air humidity)\n\n" "References:\n" "- DVWK - Deutscher Verband fuer Wasserwirtschaft und Kulturbau e.V. (1996): " "'Ermittlung der Verdunstung von Land- und Wasserflaechen', " "DVWK Merkblaetter 238/1996, Bonn, 135p.\n" "- Boehner, J., Schaefer, W., Conrad, O., Gross, J., Ringeler, A. (2001): " "'The WEELS Model: methods, results and limits of wind erosion modelling', " "In: Catena, Special Issue\n") ); //----------------------------------------------------- pNode = Parameters.Add_Grid( NULL , "STA_FC" , _TL("Field Capacity [mm]"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "STA_FC_DEF" , _TL("Default"), _TL(""), PARAMETER_TYPE_Double , 20.0 , 0.0, true ); pNode = Parameters.Add_Grid( NULL , "STA_PWP" , _TL("Permanent Wilting Point [mm]"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "STA_PWP_DEF" , _TL("Default"), _TL(""), PARAMETER_TYPE_Double , 2.0 , 0.0, true ); pNode = Parameters.Add_Grid( NULL , "LANDUSE" , _TL("Land Use"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "LANDUSE_DEF" , _TL("Default"), _TL(""), PARAMETER_TYPE_Int , -1.0 ); //----------------------------------------------------- pNode = Parameters.Add_Grid( NULL , "DYN_W" , _TL("Soil Moisture"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- pNode = Parameters.Add_FixedTable( NULL , "DYN_CLIMATE" , _TL("Climate Data"), _TL("") ); pClimate = pNode->asTable(); pClimate->Set_Name(_TL("Climate Data")); pClimate->Add_Field(_TL("Precipitation [mm]") , SG_DATATYPE_Double); pClimate->Add_Field(_TL("Temperature (2pm) [DegreeC]"), SG_DATATYPE_Double); pClimate->Add_Field(_TL("Air Humidity (2pm) [%%]"), SG_DATATYPE_Double); //----------------------------------------------------- pNode = Parameters.Add_FixedTable( NULL , "STA_KC" , _TL("Crop Coefficients"), _TL("") ); pCropCoeff = pNode->asTable(); pCropCoeff->Set_Name(_TL("Crop Coefficients")); pCropCoeff->Add_Field(_TL("Land Use ID") , SG_DATATYPE_Int); pCropCoeff->Add_Field(_TL("Name") , SG_DATATYPE_String); pCropCoeff->Add_Field(_TL("January") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("February") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("March") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("April") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("May") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("June") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("July") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("August") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("September") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("October") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("November") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("December") , SG_DATATYPE_Double); CSG_Table_Record *pRec; #define ADD_RECORD(ID, NAME, m01, m02, m03, m04, m05, m06, m07, m08, m09, m10, m11, m12) pRec = pCropCoeff->Add_Record();\ pRec->Set_Value( 0, ID); pRec->Set_Value( 1, NAME);\ pRec->Set_Value( 2, m01); pRec->Set_Value( 3, m02); pRec->Set_Value( 4, m03); pRec->Set_Value( 5, m04);\ pRec->Set_Value( 6, m05); pRec->Set_Value( 7, m06); pRec->Set_Value( 8, m07); pRec->Set_Value( 9, m08);\ pRec->Set_Value(10, m09); pRec->Set_Value(11, m10); pRec->Set_Value(12, m11); pRec->Set_Value(13, m12); // ID NAME Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dec ADD_RECORD(1.0, _TL("Maehweide") , 1 , 1 , 1 , 1 , 1.05, 1.10, 1.10, 1.05, 1.05, 1 , 1 , 1 ); ADD_RECORD(2.0, _TL("Winterweizen") , 0.65, 0.65, 0.80, 0.85, 1.15, 1.45, 1.40, 1 , 0.80, 0.70, 0.65, 0.65); ADD_RECORD(3.0, _TL("Wintergerste") , 1 , 1 , 0.85, 0.95, 1.30, 1.35, 1.25, 1 , 1 , 1 , 1 , 1 ); ADD_RECORD(4.0, _TL("Sommergerste") , 1 , 1 , 0.80, 0.90, 1.20, 1.35, 1.20, 1 , 1 , 1 , 1 , 1 ); ADD_RECORD(5.0, _TL("Winterroggen") , 0.65, 0.65, 0.85, 0.90, 1.20, 1.30, 1.25, 0.95, 0.80, 0.70, 0.65, 0.65); ADD_RECORD(6.0, _TL("Hafer" ) , 1 , 1 , 0.65, 0.70, 1.10, 1.45, 1.35, 0.95, 1 , 1 , 1 , 1 ); ADD_RECORD(7.0, _TL("Zuckerrueben") , 1 , 1 , 1 , 0.50, 0.75, 1.05, 1.40, 1.30, 1.10, 0.85, 1 , 1 ); ADD_RECORD(8.0, _TL("Kartoffeln") , 1 , 1 , 1 , 0.50, 0.90, 1.05, 1.45, 1.20, 0.90, 1 , 1 , 1 ); ADD_RECORD(9.0, _TL("Winterraps") , 0.65, 0.65, 0.85, 1 , 1.35, 1.35, 1.10, 0.85, 1 , 1 , 0.65, 0.65); ADD_RECORD(0.0, _TL("Unknown") , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ); #undef ADD_RECORD } //--------------------------------------------------------- CDVWK_SoilMoisture::~CDVWK_SoilMoisture(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDVWK_SoilMoisture::On_Execute(void) { int Day, x, y, i, LandUseID; CSG_Grid *pGrid; //----------------------------------------------------- if( pClimate->Get_Record_Count() > 0 ) { pFK_mm = Parameters("STA_FC") ->asGrid(); FK_mm_Def = Parameters("STA_FC_DEF") ->asDouble(); pPWP_mm = Parameters("STA_PWP") ->asGrid(); PWP_mm_Def = Parameters("STA_PWP_DEF") ->asDouble(); pWi_mm = Parameters("DYN_W") ->asGrid(); DataObject_Set_Colors(pWi_mm, 100, SG_COLORS_YELLOW_BLUE); //------------------------------------------------- pLandUse = SG_Create_Grid(pWi_mm, pCropCoeff->Get_Record_Count() < 127 ? SG_DATATYPE_Char : SG_DATATYPE_Int); pLandUse->Assign(Parameters("LANDUSE_DEF")->asInt()); if( (pGrid = Parameters("LANDUSE")->asGrid()) != NULL ) { for(y=0; yasInt(x, y); for(i=0; iGet_Record_Count(); i++) { if( LandUseID == pCropCoeff->Get_Record(i)->asInt(0) ) { pLandUse->Set_Value(x, y, i); break; } } } } } //------------------------------------------------- DataObject_Update(pWi_mm, 0, pFK_mm ? pFK_mm->Get_ZMax() : FK_mm_Def, true); for(Day=0; Day<365 && Set_Progress(Day, 365); Day++) { Step_Day(Day); DataObject_Update(pWi_mm, true); } //------------------------------------------------- delete(pLandUse); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CDVWK_SoilMoisture::Get_Month(int Day) { const int Days[] = // Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int iMonth, nDays; Day %= 365; if( Day < 0 ) { Day += 365; } for(iMonth=0, nDays=0; iMonth<12; iMonth++) { nDays += Days[iMonth]; if( Day < nDays ) { return( iMonth + 1 ); } } return( 12 ); } //--------------------------------------------------------- // VKR 4.10: Bestandeskoeffizient z.Ber.d.pot.Verdunstung d.Pflbest. (kc) // // Bestand : Typ (als ENUM) des Pflanzenbestandes // Month : 1=Jan, 2=Feb... 0=NA; // double CDVWK_SoilMoisture::Get_kc(int Bestand, int Day) { if( Bestand >= 0 && Bestand < pCropCoeff->Get_Record_Count() ) { return( pCropCoeff->Get_Record(Bestand)->asDouble(1 + Get_Month(Day)) ); } return( 1.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CDVWK_SoilMoisture::Get_ETP_Haude(int Day) { const double f[] = // --- Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez { 0.00, 0.22, 0.22, 0.22, 0.29, 0.29, 0.28, 0.26, 0.25, 0.23, 0.22, 0.22, 0.22 }; double T14, U14, es, e, ETP_Haude; //----------------------------------------------------- CSG_Table_Record *pRecord; if( (pRecord = pClimate->Get_Record(Day)) == NULL ) { return( 0 ); } T14 = pRecord->asDouble(1); U14 = pRecord->asDouble(2); //----------------------------------------------------- // VKR 4.6: Berechnung des Saettigungsdampfdruckes (es [hPa]) // // 17,62 * T14 // es(T14) = 6,11 * exp( -------------- ); bei T14 > 0 // 243,12 + T14 // // 22,46 * T14 // es(T14) = 6,11 * exp( -------------- ); bei T14 < 0 // 272,62 + T14 // // T14 : Temperatur 14 Uhr [DegreeC] // if( T14 < 0 ) { es = 6.11 * exp( (22.46 * T14) / (272.62 + T14) ); } else { es = 6.11 * exp( (17.62 * T14) / (243.12 + T14) ); } //----------------------------------------------------- // VKR 4.7: Berechnung des aktuellen Dampfdruckes (e [hPa]) // // e = es(T14) * U14 / 100 // // es(T14) : Saettigungsdampfdruck 14 Uhr [hPa] // U14 : relative Luftfeuchte 14 Uhr [%] (Dampfdruck in % des Saettigungsdampfdruckes) // e = es * U14 / 100.0; //----------------------------------------------------- // VKR 4.8: Berechnung der potentiellen Verdunstung nach Haude (ETPhaude [mm/d]) // // ETPhaude = f(m) * (es - e) // // f(m) : Monatsfaktor [mm/mbar/d] // e : aktueller Dampfdruck [hPa] // es : Saettigungsdampfdruck // ETP_Haude = f[Get_Month(Day)] * (es - e); return( ETP_Haude ); } //--------------------------------------------------------- double CDVWK_SoilMoisture::Get_Pi(int Day) { const double Messfehler[] = // --- Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez { 0.000, 0.228, 0.236, 0.200, 0.160, 0.120, 0.103, 0.105, 0.103, 0.115, 0.136, 0.162, 0.189 }; double P, Pi; //----------------------------------------------------- CSG_Table_Record *pRecord; if( (pRecord = pClimate->Get_Record(Day)) == NULL ) { return( 0 ); } P = pRecord->asDouble(0); //----------------------------------------------------- // VKR 4.11: Berechnung der korrigierten Niederschlaege (Pi [mm/d]) // // Pi = N * kn // // N : Niederschlag gemessen [mm/d] // kn : Korrekturfaktor ergibt sich aus den prozentualen Meßfehlern... // Month : 1=Jan, 2=Feb... 0=NA; // Pi = P + P * Messfehler[Get_Month(Day)]; return( Pi ); } //--------------------------------------------------------- double CDVWK_SoilMoisture::Get_Wi(double Wi, double Pi, double ETP, double kc, double FK, double PWP) { double Ri, d, ETPi, ETAi; //----------------------------------------------------- // VKR 4.9: Berechnung des Reduktionsfaktors f.Verdunstung (Ri) // // PWP // 1 - ----- // Wi ETP Ri = 1 bei Pi > ETPi // Ri = ------------- + 0,1 * ------; Ri = 1 bei Ri > 1,0 // PWP ETPi Ri = 0 bei Ri < 0,0 // 1 - ----- // FK // // Pi : korrigierter Niederschlag [mm/d] // Wi : Bodenwassergehalt // PWP : Permanenter Welkepunkt // FK : Feldkapazitaet // kc : Koeffizient f.d. Pflz.Bestand // ETPi = ETP * kc; if( Pi > ETPi ) { Ri = 1.0; } else if( ETPi <= 0.0 || Wi <= 0.0 || FK <= 0.0 ) { Ri = 0.0; } else { d = 1.0 - PWP / FK; if( d == 0.0 ) { Ri = 0.0; } else { Ri = (1.0 - PWP / Wi) / d + 0.1 * ETP / ETPi; if( Ri > 1.0 ) { Ri = 1.0; } else if( Ri < 0.0 ) { Ri = 0.0; } } } //----------------------------------------------------- // VKR 4.13: Berechnung der tatsaechlichen Verdunstung (ETa [mm/d]) // // ETai = Pi - (Pi - (ETPhaude * kc)) * Ri // // Pi : korrigierter Niederschlag [mm/d] // ETPhaude : potentielle Verdunstung nach Haude [mm/d] // kc : Bestandeskoeffizient // Ri : Reduktionsfaktor // ETAi = Pi - (Pi - ETPi) * Ri; //----------------------------------------------------- // VKR 4.14: Berechnung des Bodenwasservorrats (Wi [mm/d]) // // Wi+1 = Wi + Pi - ETai - SRi + KR // // Pi : korrigierter Niederschlag [mm/d] // ETai : tatsaechliche Verdunstung [mm/d] // SRi : taegliche Sickerwaserrate [mm/d] // SRi = 0 bei Wi+1 <= FK * ku // SRi = Wi+1 - FK * ku bei Wi+1 > FK * ku; // FK : Feldkapazitaet [mm] // ku : moegliche Uebersaettigung ueber FK := 1 (findet keine Beruecksichtigung) // KR : kapillare Aufstiegsrate := 0 (findet keine Beruecksichtigung) // Wi += Pi - ETAi; if( Wi > FK ) { Wi = FK; // -= SRi... } else if( Wi < PWP ) { Wi = PWP; } return( Wi ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CDVWK_SoilMoisture::Step_Day(int Day) { int x, y; double Wi, Pi, ETP, kc, FK, PWP; ETP = Get_ETP_Haude(Day); Pi = Get_Pi(Day); for(y=0; yasInt(x, y), Day); FK = pFK_mm ? pFK_mm ->asDouble(x, y) : FK_mm_Def; PWP = pPWP_mm ? pPWP_mm ->asDouble(x, y) : PWP_mm_Def; Wi = pWi_mm->asDouble(x, y); Wi = Get_Wi(Wi, Pi, ETP, kc, FK, PWP); pWi_mm->Set_Value(x, y, Wi); } } } saga-2.2.3/src/modules/simulation/sim_hydrology/idw.h0000664000175000017500000000263612565125410024046 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: idw.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Isochrones.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include class CIDW { public: CIDW(); virtual ~CIDW(); void setParameters(CSG_Grid*,CSG_Shapes*,int); void Interpolate(); private: CSG_Grid* m_pGrid; CSG_Shapes *m_pPoints; int m_iField; bool Get_Grid_Value(int,int); }; saga-2.2.3/src/modules/simulation/sim_cellular_automata/0000775000175000017500000000000012634325746024574 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/simulation/sim_cellular_automata/Wator.cpp0000664000175000017500000003363712565125410026375 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Wator.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // Wator.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Wator.h" #include //--------------------------------------------------------- #define FISH 1 #define SHARK 2 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWator::CWator(void) { CSG_Parameter *pNode_0, *pNode_1; //----------------------------------------------------- Set_Name (_TL("Wa-Tor")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Wa-Tor - an ecological simulation of predator-prey populations - " "is based upon A. K. Dewdney's 'Computer Recreations' article " "in the December 1984 issue of Scientific American." )); //----------------------------------------------------- Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); pNode_0 = Parameters.Add_Node( NULL , "NODE_GRID" , _TL("New Grid Dimensions"), _TL("If grid is not set, a new one will be created using chosen width and height.") ); Parameters.Add_Value( pNode_0 , "NX" , _TL("Width (Cells)"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Value( pNode_0 , "NY" , _TL("Height (Cells)"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); pNode_0 = Parameters.Add_Grid( NULL , "RESULT" , _TL("Wa-Tor"), _TL(""), PARAMETER_OUTPUT_OPTIONAL , true, SG_DATATYPE_Byte ); pNode_1 = Parameters.Add_Value( pNode_0 , "REFRESH" , _TL("Refresh"), _TL(""), PARAMETER_TYPE_Bool , true ); pNode_1 = Parameters.Add_Value( pNode_0 , "INIT_FISH" , _TL("Initial Number of Fishes [%]"), _TL(""), PARAMETER_TYPE_Double , 30.0, 0.0, true, 100.0, true ); pNode_1 = Parameters.Add_Value( pNode_0 , "INIT_SHARK" , _TL("Initial Number of Sharks [%]"), _TL(""), PARAMETER_TYPE_Double , 7.5, 0.0, true, 100.0, true ); pNode_0 = Parameters.Add_Table( NULL , "TABLE" , _TL("Cycles"), _TL(""), PARAMETER_OUTPUT ); pNode_0 = Parameters.Add_Value( NULL , "FISH_BIRTH" , _TL("Birth Rate of Fishes"), _TL(""), PARAMETER_TYPE_Int , 3.0, 0.0, true ); pNode_0 = Parameters.Add_Value( NULL , "SHARK_BIRTH" , _TL("Birth Rate of Sharks"), _TL(""), PARAMETER_TYPE_Int , 12.0, 0.0, true ); pNode_0 = Parameters.Add_Value( NULL , "SHARK_STARVE" , _TL("Max. Starvation Time for Sharks"), _TL(""), PARAMETER_TYPE_Int , 4.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWator::On_Execute(void) { bool bRefresh; int x, y, i; double perc, Fish_perc, Shark_perc; CSG_Colors Colors; CSG_Table *pTable; CSG_Table_Record *pRecord; //----------------------------------------------------- if( (pWator = Parameters("RESULT")->asGrid()) == NULL ) { bRefresh = true; pWator = SG_Create_Grid(SG_DATATYPE_Byte, Parameters("NX")->asInt(), Parameters("NY")->asInt()); Parameters("GRID")->Set_Value(pWator); } else { bRefresh = Parameters("REFRESH")->asBool(); } pWator->Set_Name(_TL("Wa-Tor")); Colors.Set_Count(3); Colors.Set_Color(0, SG_GET_RGB( 0, 0, 0)); Colors.Set_Color(1, SG_GET_RGB( 0, 255, 0)); Colors.Set_Color(2, SG_GET_RGB(255, 0, 0)); DataObject_Set_Colors(pWator, Colors); DataObject_Update(pWator, 0, 3, SG_UI_DATAOBJECT_SHOW); //----------------------------------------------------- Fish_Birth = Parameters("FISH_BIRTH") ->asInt(); Shark_Birth = Parameters("SHARK_BIRTH") ->asInt(); Shark_Starve = Parameters("SHARK_STARVE")->asInt(); pTable = Parameters("TABLE") ->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("Wa-Tor")); pTable->Add_Field("Cycle" , SG_DATATYPE_Int); pTable->Add_Field("Fishes" , SG_DATATYPE_Int); pTable->Add_Field("Sharks" , SG_DATATYPE_Int); pNext = SG_Create_Grid(pWator, SG_DATATYPE_Byte); pAge = SG_Create_Grid(pWator, SG_DATATYPE_Byte); pStarve = SG_Create_Grid(pWator, SG_DATATYPE_Byte); srand((unsigned)time(NULL)); //----------------------------------------------------- if( bRefresh ) { pWator->Assign(0.0); Fish_perc = Parameters("INIT_FISH" )->asDouble(); Shark_perc = Parameters("INIT_SHARK")->asDouble() + Fish_perc; for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { perc = 100.0 * (double)rand() / (double)RAND_MAX; if( perc <= Fish_perc ) { pWator ->Set_Value(x, y, FISH); } else if( perc <= Shark_perc ) { pWator ->Set_Value(x, y, SHARK); } } } } //----------------------------------------------------- pAge ->Assign(); pStarve ->Assign(); for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { switch( pWator->asByte(x, y) ) { case FISH: pAge ->Set_Value(x, y, Fish_Birth * (double)rand() / (double)RAND_MAX); break; case SHARK: pAge ->Set_Value(x, y, Shark_Birth * (double)rand() / (double)RAND_MAX); pStarve ->Set_Value(x, y, Shark_Starve * (double)rand() / (double)RAND_MAX); break; } } } //----------------------------------------------------- SG_UI_Progress_Lock(true); for(i=1; Process_Get_Okay(true) && Next_Cycle(); i++) { Process_Set_Text(CSG_String::Format(SG_T("%s: %d"), _TL("Life Cycle"), i)); pRecord = pTable->Add_Record(); pRecord->Set_Value(0, i); pRecord->Set_Value(1, nFishes); pRecord->Set_Value(2, nSharks); DataObject_Update(pWator, 0, 3); DataObject_Update(pTable); } SG_UI_Progress_Lock(false); //----------------------------------------------------- delete(pNext); delete(pAge); delete(pStarve); if( is_Progress() ) { Message_Add(CSG_String::Format(SG_T("%s %d %s"), _TL("Dead after"), i, _TL("Life Cycles"))); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_NEIGHBOR { ix = pWator->Get_System().Get_xTo(i, x); if( ix < 0 ) ix = pWator->Get_NX() - 1; else if( ix >= pWator->Get_NX() ) ix = 0;\ iy = pWator->Get_System().Get_yTo(i, y); if( iy < 0 ) iy = pWator->Get_NY() - 1; else if( iy >= pWator->Get_NY() ) iy = 0; } #define GET_NEIGHBOR_RANDOMLY { i = iNeighbor[(int)((double)rand() * nNeighbors / (double)RAND_MAX)];\ ix = pWator->Get_System().Get_xTo(i, x); if( ix < 0 ) ix = pWator->Get_NX() - 1; else if( ix >= pWator->Get_NX() ) ix = 0;\ iy = pWator->Get_System().Get_yTo(i, y); if( iy < 0 ) iy = pWator->Get_NY() - 1; else if( iy >= pWator->Get_NY() ) iy = 0; } //--------------------------------------------------------- bool CWator::Next_Cycle(void) { static int iDir = 0; int x, y, i, ix, iy, xx, yy, ax, ay, dx, dy, iNeighbor[8], nNeighbors, Age, Starve; //----------------------------------------------------- nFishes = 0; nSharks = 0; pNext->Assign(0.0); switch( iDir ) { default: case 3: ay = pWator->Get_NY() - 1; dy = -1; ax = pWator->Get_NX() - 1; dx = -1; iDir=0; break; case 2: ay = 0; dy = 1; ax = pWator->Get_NX() - 1; dx = -1; iDir++; break; case 1: ay = pWator->Get_NY() - 1; dy = -1; ax = 0; dx = 1; iDir++; break; case 0: ay = 0; dy = 1; ax = 0; dx = 1; iDir++; break; } //----------------------------------------------------- for(yy=0, y=ay; yyGet_NY(); yy++, y+=dy) { for(xx=0, x=ax; xxGet_NX(); xx++, x+=dx) { if( pWator->asByte(x, y) == FISH ) { nFishes++; Age = pAge->asInt(x, y) + 1; pAge->Set_Value(x, y, 0); for(i=0, nNeighbors=0; i<8; i++) { GET_NEIGHBOR; if( pWator->asByte(ix, iy) == 0 && pNext->asByte(ix, iy) == 0 ) { iNeighbor[nNeighbors++] = i; } } if( nNeighbors > 0 ) { GET_NEIGHBOR_RANDOMLY; pNext ->Set_Value(ix, iy, FISH); pAge ->Set_Value(ix, iy, Age >= Fish_Birth ? 0 : Age); if( Age >= Fish_Birth ) { pNext ->Set_Value( x, y, FISH); pAge ->Set_Value( x, y, Fish_Birth * (double)rand() / (double)RAND_MAX); } else { pWator ->Set_Value( x, y, 0); } } else { pNext ->Set_Value( x, y, FISH); pAge ->Set_Value( x, y, Age >= Fish_Birth ? 0 : Fish_Birth); } } } } //----------------------------------------------------- for(yy=0, y=ay; yyGet_NY(); yy++, y+=dy) { for(xx=0, x=ax; xxGet_NX(); xx++, x+=dx) { if( pWator->asByte(x, y) == SHARK ) { nSharks++; Age = pAge->asInt(x, y) + 1; pAge->Set_Value(x, y, 0); Starve = pStarve->asInt(x, y) + 1; pStarve->Set_Value(x, y, 0); for(i=0, nNeighbors=0; i<8; i++) { GET_NEIGHBOR; if( pNext->asByte(ix, iy) == FISH ) { iNeighbor[nNeighbors++] = i; } } if( nNeighbors > 0 ) { GET_NEIGHBOR_RANDOMLY; nFishes--; pWator ->Set_Value(ix, iy, 0); pNext ->Set_Value(ix, iy, SHARK); pAge ->Set_Value(ix, iy, Age >= Shark_Birth ? 0 : Age); pStarve ->Set_Value(ix, iy, 0); if( Age >= Shark_Birth ) { pNext ->Set_Value( x, y, SHARK); pAge ->Set_Value( x, y, Shark_Birth * (double)rand() / (double)RAND_MAX); pStarve ->Set_Value( x, y, 0); } else { pWator ->Set_Value( x, y, 0); } } else if( Starve <= Shark_Starve ) { for(i=0, nNeighbors=0; i<8; i++) { GET_NEIGHBOR; if( pWator->asByte(ix, iy) == 0 && pNext->asByte(ix, iy) == 0 ) { iNeighbor[nNeighbors++] = i; } } if( nNeighbors > 0 ) { GET_NEIGHBOR_RANDOMLY; pNext ->Set_Value(ix, iy, SHARK); pAge ->Set_Value(ix, iy, Age >= Shark_Birth ? 0 : Age); pStarve ->Set_Value(ix, iy, Starve); if( Age >= Shark_Birth ) { pNext ->Set_Value( x, y, SHARK); pAge ->Set_Value( x, y, Shark_Birth * (double)rand() / (double)RAND_MAX); pStarve ->Set_Value( x, y, Starve); } else { pWator ->Set_Value( x, y, 0); } } else { pNext ->Set_Value( x, y, SHARK); pAge ->Set_Value( x, y, Age >= Shark_Birth ? 0 : Shark_Birth); pStarve ->Set_Value( x, y, Starve); } } else { nSharks--; } } } } pWator->Assign(pNext); return( (nFishes > 0 && nFishes < pWator->Get_NCells()) || nSharks > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_cellular_automata/Life.cpp0000664000175000017500000001752412565125410026155 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Life.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // Life.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Life.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLife::CLife(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("Conway's Life")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Conway's Life - a cellular automat.\n\n" "Reference:\n" "- Eigen, M., Winkler, R. (1985): " "'Das Spiel - Naturgesetze steuern den Zufall', " "Muenchen, 404p.\n") ); //----------------------------------------------------- // 2. Grids... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_Value( NULL , "NX" , _TL("Width (Cells)"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Value( NULL , "NY" , _TL("Height (Cells)"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Value( NULL, "FADECOLOR" , _TL("Fade Color Count"), _TL(""), PARAMETER_TYPE_Int, 63, 1, true, 255, true ); } //--------------------------------------------------------- CLife::~CLife(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLife::On_Execute(void) { int x, y, i; //----------------------------------------------------- pLife = SG_Create_Grid(SG_DATATYPE_Byte, Parameters("NX")->asInt(), Parameters("NY")->asInt()); pLife->Set_Name(_TL("Conway's Life")); Parameters("GRID")->Set_Value(pLife); nColors = Parameters("FADECOLOR")->asInt(); DataObject_Set_Colors(pLife, nColors, SG_COLORS_YELLOW_BLUE); pCount = SG_Create_Grid(pLife); //----------------------------------------------------- srand((unsigned)time(NULL)); pLife->Assign(0.0); for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { if( rand() > RAND_MAX / 2 ) { pLife->Set_Value(x, y, 1); } } } Next_Cycle(); DataObject_Update(pLife, 0, nColors, true); //----------------------------------------------------- for(i=1; Process_Get_Okay(true) && Next_Cycle(); i++) { DataObject_Update(pLife); Process_Set_Text(CSG_String::Format(SG_T("%s: %d"), _TL("Life Cycle"), i)); } //----------------------------------------------------- delete(pCount); if( is_Progress() ) { Message_Add(CSG_String::Format(SG_T("%s %d %s"), _TL("Dead after"), i, _TL("Life Cycles"))); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLife::Next_Cycle(void) { bool bContinue; int x, y, i, ix, iy; //----------------------------------------------------- bContinue = false; pCount->Assign(); //----------------------------------------------------- for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { if( (i = pLife->asByte(x, y)) == 0 ) { for(i=0; i<8; i++) { ix = pLife->Get_System().Get_xTo(i, x); if( ix < 0 ) { ix = pLife->Get_NX() - 1; } else if( ix >= pLife->Get_NX() ) { ix = 0; } iy = pLife->Get_System().Get_yTo(i, y); if( iy < 0 ) { iy = pLife->Get_NY() - 1; } else if( iy >= pLife->Get_NY() ) { iy = 0; } pCount->Add_Value(ix, iy, 1); } } else if( i > 1 && i < nColors ) { bContinue = true; } } } //----------------------------------------------------- for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { i = pCount->asByte(x, y); switch( i ) { case 2: i = pLife->asByte(x, y); if( i > 0 && i < nColors ) { pLife->Add_Value(x, y, 1); } break; case 3: pLife->Set_Value(x, y, 0); break; default: i = pLife->asByte(x, y); if( i < 1 ) { pLife->Set_Value(x, y, 1); } else if( i < nColors ) { pLife->Add_Value(x, y, 1); } } } } //----------------------------------------------------- return( bContinue ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_cellular_automata/Makefile.in0000664000175000017500000005463612622651172026647 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/simulation/sim_cellular_automata DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_cellular_automata_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_cellular_automata_la_OBJECTS = Life.lo MLB_Interface.lo \ Wator.lo libsim_cellular_automata_la_OBJECTS = \ $(am_libsim_cellular_automata_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_cellular_automata_la_SOURCES) DIST_SOURCES = $(libsim_cellular_automata_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_cellular_automata.la libsim_cellular_automata_la_SOURCES = \ Life.cpp\ MLB_Interface.cpp\ Wator.cpp\ Life.h\ MLB_Interface.h\ Wator.h libsim_cellular_automata_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) --foreign src/modules/simulation/sim_cellular_automata/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_cellular_automata/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_cellular_automata.la: $(libsim_cellular_automata_la_OBJECTS) $(libsim_cellular_automata_la_DEPENDENCIES) $(EXTRA_libsim_cellular_automata_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_cellular_automata_la_OBJECTS) $(libsim_cellular_automata_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Life.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Wator.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/simulation/sim_cellular_automata/MLB_Interface.cpp0000664000175000017500000001162612565125410027665 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Cellular Automata") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2002") ); case MLB_INFO_Description: return( _TL("Cellular Automata") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Cellular Automata") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Life.h" #include "Wator.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 CLife; break; case 1: pModule = new CWator; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/simulation/sim_cellular_automata/Makefile.am0000664000175000017500000000121412565125410026613 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_cellular_automata.la libsim_cellular_automata_la_SOURCES =\ Life.cpp\ MLB_Interface.cpp\ Wator.cpp\ Life.h\ MLB_Interface.h\ Wator.h libsim_cellular_automata_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/simulation/sim_cellular_automata/MLB_Interface.h0000664000175000017500000001001112565125410027315 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__sim_cellular_automata_H #define HEADER_INCLUDED__sim_cellular_automata_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef sim_cellular_automata_EXPORTS #define sim_cellular_automata_EXPORT _SAGA_DLL_EXPORT #else #define sim_cellular_automata_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__sim_cellular_automata_H saga-2.2.3/src/modules/simulation/sim_cellular_automata/Wator.h0000664000175000017500000001077412565125410026037 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Wator.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // Wator.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Wator_H #define HEADER_INCLUDED__Wator_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWator : public CSG_Module { public: CWator(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute(void); private: int Fish_Birth, Shark_Birth, Shark_Starve; sLong nFishes, nSharks; CSG_Grid *pWator, *pNext, *pAge, *pStarve; bool Next_Cycle(void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Wator_H saga-2.2.3/src/modules/simulation/sim_cellular_automata/Life.h0000664000175000017500000001070112565125410025610 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Life.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // Life.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__LIFE_H #define HEADER_INCLUDED__LIFE_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLife : public CSG_Module { public: CLife(void); virtual ~CLife(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute(void); private: int nColors; CSG_Grid *pLife, *pCount; bool Next_Cycle(void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__LIFE_H saga-2.2.3/src/modules/simulation/sim_erosion/0000775000175000017500000000000012634325746022554 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/simulation/sim_erosion/MMF_SAGA.cpp0000664000175000017500000011310012565125410024453 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MMF_SAGA.cpp 2455 2015-03-22 15:54:14Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_erosion // // // //-------------------------------------------------------// // // // MMF_SAGA.cpp // // // // Copyright (C) 2009-12 by // // Volker Wichmann // // Muhammad Setiawan // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Implementation of the CMMF_SAGA class. // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MMF_SAGA.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMMF_SAGA::CMMF_SAGA(void) { // CSG_Parameter *pNodeTerrain, *pNodeVegetation, *pNodeSoil, *pNodeClimate, *pNodeOptions, *pNodeOutput; Set_Name (_TL("MMF-SAGA Soil Erosion Model")); Set_Author (SG_T("(c) 2009-2012 V. Wichmann, M. Setiawan")); Set_Description(_TW("Soil erosion modelling with a modified MMF (Morgan-Morgan-Finney) model " "(Morgan & Duzant 2008).
" "This module is called MMF-SAGA because some things have been implemented differently " "compared to the original publication. The most important are:

" "
    " "
  • the extension of the model to support spatially distributed modelling
  • " "
  • the introduction of a \"Channel Network\" layer
  • " "
  • the introduction of a \"rainfall duration\" (time span) parameter
  • " "
  • the exposure of the flow depth parameter
  • " "
" "

" "A more detailed description of the model, its modifications, and " "model application is provided by Setiawan (2012), chapter 6.
" "Currently, a number of additional grid datasets are outputted to facilitate " "model evaluation. This can be easily changed within the source code.
" "

" "References:
" "Morgan, R.P.C. (2001): A simple approach to soil loss prediction: a revised " "Morgan-Morgan-Finney model. Catena 44: 305-322.

" "Morgan, R.P.C., Duzant, J.H. (2008): Modified MMF (Morgan-Morgan-Finney) model " "for evaluating effects of crops and vegetation cover on soil erosion. Earth " "Surf. Process. Landforms 32: 90-106.

" "" "Setiawan, M. A. (2012): Integrated Soil Erosion Management in the upper Serayu " "Watershed, Wonosobo District, Central Java Province, Indonesia. Dissertation at " "the Faculty of Geo- and Atmospheric Sciences of the University of Innsbruck, Austria." "

" )); // comments on equation numbers refer to Morgan & Duzant (2008) //pNodeTerrain = Parameters.Add_Node(NULL, "TERRAIN", _TL("Terrain"), _TL("Terrain parameters")); Parameters.Add_Grid( NULL, "DTM", _TL("Digital Terrain Model"), _TL("DTM, digital terrain model [m]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "S", _TL("Slope"), _TL("S, slope [rad]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "CHANNEL", _TL("Channel Network"), _TL("Channel network, all other cells NoData"), PARAMETER_INPUT_OPTIONAL ); //pNodeVegetation = Parameters.Add_Node(NULL, "VEGETATION", _TL("Vegetation"), _TL("Vegetation parameters")); Parameters.Add_Grid( NULL, "PI", _TL("Permament Interception"), _TL("PI, permanent interception expressed as the proportion [between 0-1] of rainfall"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "CC", _TL("Canopy Cover"), _TL("CC, canopy cover expressed as a portion [between 0-1] of the soil surface protected by vegetation or crop"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "PH", _TL("Plant Height"), _TL("PH, plant height [m], representing the effective height from which raindrops fall from the crop or vegetation"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "EtEo", _TL("Ratio Evapotranspiration"), _TL("Et/Eo, ratio of actual to potential evapotranspiration"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "GC", _TL("Ground cover"), _TL("GC, Ground cover expressed as a portion [between 0-1] of the soil surface protected by vegetation or crop cover on the ground"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "D", _TL("Diameter plant elements"), _TL("D, Average diameter [m] of the individual plants elements (stem, leaves) at the ground surface"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "NV", _TL("Number plant elements"), _TL("NV, Number of plant elements per unit area [number/unit area] at the ground surface"), PARAMETER_INPUT ); //pNodeSoil = Parameters.Add_Node(NULL, "SOIL", _TL("Soil"), _TL("Soil parameters")); Parameters.Add_Grid( NULL, "MS", _TL("Soil moisture (at FC)"), _TL("MS, Soil moisture at field capacity [% w/w]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "BD", _TL("Bulk density top layer"), _TL("BD, Bulk density of the top layer [Mg/m3]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "EHD", _TL("Effective hydrological depth"), _TL("EHD, Effective hydrological depth of the soil [m]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "LP", _TL("Sat. lateral permeability"), _TL("LP, Saturated lateral permeability of the soil [m/day]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "PER_C", _TL("Percentage clays"), _TL("c, Percentage clays [%]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "PER_Z", _TL("Percentage silt"), _TL("z, Percentage silt [%]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "PER_S", _TL("Percentage sand"), _TL("s, Percentage sand [%]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "ST", _TL("Percentage rock fragments"), _TL("ST, Percentage rock fragments on the soil surface [%]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "RFR", _TL("Surface roughness"), _TW("RFR, Surface roughness [cm/m]. In case the surface roughness is not provided as input, v_flow_t is " "set to 1.0, i.e. natural soil surface roughness is not accounted for."), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Table( NULL, "TAB_METEO", _TL("Meteorological data"), _TL("Meteorological data for multiple timestep modelling [model step (day); temperature (Celsius); rainfall (mm), rainfall intensity (mm/h); rainfall duration (day); timespan (days)]"), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_FilePath( Parameters("TAB_METEO"), "OUT_PATH", _TL("Output file path"), _TL("Full path to the directory for the output grids of each model step"), SG_T("\0*.*\0\0*.*\0"), _TL(""), true, true ); //pNodeClimate = Parameters.Add_Node(NULL, "CLIMATE", _TL("Climate"), _TL("Climate parameters")); Parameters.Add_Value( NULL, "INTERFLOW", _TL("Simulate Interflow"), _TL("Simulate interflow"), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("INTERFLOW"), "T", _TL("Mean temperature"), _TL("T, mean temperature [degree C]"), PARAMETER_TYPE_Double, 18.0 ); Parameters.Add_Value( Parameters("INTERFLOW"), "TIMESPAN", _TL("Timespan (days)"), _TL("The number of days to model."), PARAMETER_TYPE_Int, 30.0, 1.0, true, 365, true ); Parameters.Add_Grid( Parameters("INTERFLOW"), "IF", _TL("Interflow"), _TL("IF"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL, "R", _TL("Rainfall"), _TL("R, height of precipitation in timespan [mm]"), PARAMETER_TYPE_Double, 200.0 ); Parameters.Add_Value( NULL, "I", _TL("Rainfall intensity"), _TL("I, rainfall intensity [mm/h]"), PARAMETER_TYPE_Double, 20.0 ); Parameters.Add_Value( NULL, "Rn", _TL("Rainfall Duration"), _TL("Rn, number of rain days in timespan [-]"), PARAMETER_TYPE_Double, 20.0 ); CSG_String choices; for (int i=0; iasGrid(); if( !pDTM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } pS = Parameters("S")->asGrid(); pChannel = Parameters("CHANNEL")->asGrid(); pPI = Parameters("PI")->asGrid(); pCC = Parameters("CC")->asGrid(); pPH = Parameters("PH")->asGrid(); pMS = Parameters("MS")->asGrid(); pBD = Parameters("BD")->asGrid(); pEHD = Parameters("EHD")->asGrid(); pEtEo = Parameters("EtEo")->asGrid(); pLP = Parameters("LP")->asGrid(); pGC = Parameters("GC")->asGrid(); pPer_c = Parameters("PER_C")->asGrid(); pPer_z = Parameters("PER_Z")->asGrid(); pPer_s = Parameters("PER_S")->asGrid(); pST = Parameters("ST")->asGrid(); pD = Parameters("D")->asGrid(); pNV = Parameters("NV")->asGrid(); pRFR = Parameters("RFR")->asGrid(); pMeteoTab = Parameters("TAB_METEO")->asTable(); sOutPath = Parameters("OUT_PATH")->asString(); if (pMeteoTab != NULL) { if (sOutPath.Length() == 0) { SG_UI_Msg_Add_Error(_TL("No path for output files specified!")); SG_UI_Msg_Add(_TL("Please provide a path for the output files."), true); return (false); } iRuns = pMeteoTab->Get_Count(); } else iRuns = 1; // check if all input grids are valid within the bounds of the DTM //---------------------------------------------------------------- for (y=0; yis_NoData(x, y)) { InvalidGrid = SG_T(""); if (pS->is_NoData(x, y)) InvalidGrid = SG_T("S"); if (pPI->is_NoData(x, y)) InvalidGrid = SG_T("PI"); if (pCC->is_NoData(x, y)) InvalidGrid = SG_T("CC"); if (pPH->is_NoData(x, y)) InvalidGrid = SG_T("PH"); if (pMS->is_NoData(x, y)) InvalidGrid = SG_T("MS"); if (pBD->is_NoData(x, y)) InvalidGrid = SG_T("BD"); if (pEHD->is_NoData(x, y)) InvalidGrid = SG_T("EHD"); if (pEtEo->is_NoData(x, y)) InvalidGrid = SG_T("EtEo"); if (pLP->is_NoData(x, y)) InvalidGrid = SG_T("LP"); if (pGC->is_NoData(x, y)) InvalidGrid = SG_T("GC"); if (pPer_c->is_NoData(x, y)) InvalidGrid = SG_T("PER_C"); if (pPer_z->is_NoData(x, y)) InvalidGrid = SG_T("PER_Z"); if (pPer_s->is_NoData(x, y)) InvalidGrid = SG_T("PER_S"); if (pST->is_NoData(x, y)) InvalidGrid = SG_T("ST"); if (pD->is_NoData(x, y)) InvalidGrid = SG_T("D"); if (pNV->is_NoData(x, y)) InvalidGrid = SG_T("NV"); if (pRFR != NULL && pRFR->is_NoData(x, y)) InvalidGrid = SG_T("RFR"); if (InvalidGrid.Length() > 0) { Error_Set(CSG_String::Format(_TL("NoData encountered in input grid %s: x %d (%.2f), y %d (%.2f)"), InvalidGrid.c_str(), x, pDTM->Get_System().Get_xGrid_to_World(x), y, pDTM->Get_System().Get_yGrid_to_World(y))); return (false); } } } } #ifdef _TMP_OUT pRf = Parameters("Rf")->asGrid(); pKE = Parameters("KE")->asGrid(); pRc = Parameters("Rc")->asGrid(); pSLc = Parameters("SLc")->asGrid(); pSLz = Parameters("SLz")->asGrid(); pSLs = Parameters("SLs")->asGrid(); pW_up = Parameters("W_up")->asGrid(); pTCc = Parameters("TCc")->asGrid(); pTCz = Parameters("TCz")->asGrid(); pTCs = Parameters("TCs")->asGrid(); pGc = Parameters("Gc")->asGrid(); pGz = Parameters("Gz")->asGrid(); pGs = Parameters("Gs")->asGrid(); pTCondc = Parameters("TCONDc")->asGrid(); pTCondz = Parameters("TCONDz")->asGrid(); pTConds = Parameters("TCONDs")->asGrid(); pTCc->Assign_NoData(); pTCz->Assign_NoData(); pTCs->Assign_NoData(); pGc->Assign_NoData(); pGz->Assign_NoData(); pGs->Assign_NoData(); pTCondc->Assign_NoData(); pTCondz->Assign_NoData(); pTConds->Assign_NoData(); #endif pIF = Parameters("IF")->asGrid(); pQ = Parameters("Q")->asGrid(); pSL = Parameters("SL")->asGrid(); R = Parameters("R")->asDouble(); I = Parameters("I")->asDouble(); Rn = Parameters("Rn")->asDouble(); KE_I_method = Parameters("KE_I_METHOD")->asInt(); timespan = Parameters("TIMESPAN")->asInt(); flowd_va = Parameters("FLOWD_VA")->asDouble(); bChannelT = Parameters("CHANNELTRANSPORT")->asBool(); bInterflow = Parameters("INTERFLOW")->asBool(); T = Parameters("T")->asDouble(); if (bInterflow && pIF == NULL) { pIF = SG_Create_Grid(pDTM); bFreeIF = true; } // create temporary grids #ifndef _TMP_OUT pRf = SG_Create_Grid(pDTM->Get_System()); pKE = SG_Create_Grid(pDTM->Get_System()); pRc = SG_Create_Grid(pDTM->Get_System()); pSLc = SG_Create_Grid(pDTM->Get_System()); pSLz = SG_Create_Grid(pDTM->Get_System()); pSLs = SG_Create_Grid(pDTM->Get_System()); pW_up = SG_Create_Grid(pDTM->Get_System()); #endif for (int iRun=0; iRunGet_Record(iRun)->asInt(0); T = pMeteoTab->Get_Record(iRun)->asDouble(1); R = pMeteoTab->Get_Record(iRun)->asDouble(2); I = pMeteoTab->Get_Record(iRun)->asDouble(3); Rn = pMeteoTab->Get_Record(iRun)->asDouble(4); timespan = pMeteoTab->Get_Record(iRun)->asInt(5); } if (bInterflow && Rn > timespan) { Error_Set(CSG_String::Format(_TL("Number of raindays is greater than model timespan!"))); return (false); } // Initialize Grids pSLc->Assign(0.0); pSLz->Assign(0.0); pSLs->Assign(0.0); pQ->Assign(0.0); pW_up->Assign(0.0); if (bInterflow) pIF->Assign(0.0); // Estimation of rainfall energy (effective rainfall, leaf drainage, direct throughfall, kinetic energy) //------------------------------------------------------------------------------------------------------ for (y=0; yis_NoData(x, y) && !pPI->is_NoData(x, y) && !pCC->is_NoData(x, y) && !pPH->is_NoData(x, y)) { pRf->Set_Value(x, y, (R * (1-pPI->asDouble(x, y))) / cos(pS->asDouble(x, y))); // Equ. (1) LD = pRf->asDouble(x, y) * pCC->asDouble(x, y); // Equ. (2) DT = pRf->asDouble(x, y) - LD; // Equ. (3) switch (KE_I_method) // Equ. (4), see Table 2 in Morgan (2001) { case MMF_KE_I_WISCHMEIER_SMITH_1978: default: KE_DT = DT * (11.87 + 8.73 * log10(I)); break; case MMF_KE_I_MARSHALL_PALMER: KE_DT = DT * (8.95 + 8.44 * log10(I)); break; case MMF_KE_I_ZANCHI_TORRI_1980: KE_DT = DT * (9.81 + 11.25 * log10(I)); break; case MMF_KE_I_COUTINHO_TOMAS_1995: KE_DT = DT * (35.9 * (1 - 0.56 * exp(-0.034 * I))); break; case MMF_KE_I_HUDSON_1965: KE_DT = DT * (29.8 - (127.5 / I)); break; case MMF_KE_I_ONEGA_ET_AL_1998: KE_DT = DT * (9.81 + 10.6 * log10(I)); break; case MMF_KE_I_ROSEWELL_1986: KE_DT = DT * (29.0 * (1 - 0.6 * exp(-0.04 * I))); break; case MMF_KE_I_MCISAAC_1990: KE_DT = DT * (26.8 * (1 - 0.29 * exp(-0.049 * I))); break; } if (pPH->asDouble(x, y) < 0.15) KE_LD = 0.0; // Equ. (5) else KE_LD = LD * (15.8 * pow(pPH->asDouble(x, y), 0.5) - 5.87); // Equ. (6) pKE->Set_Value(x, y, KE_DT + KE_LD); // Equ. (7) } else { pRf->Set_NoData(x, y); pKE->Set_NoData(x, y); } } } // estimation of runoff //----------------------- if (bInterflow) { Z = 300 + (25 * T) + (0.05 * T * T * T); // Equ. (12), wrong in Morgan and Duzant (2008) -> original annual Turc equation uses T^3, not T^2 Rmod = R * (365/timespan); // scale up from timespan to annual values E = Rmod / sqrt(0.9 + (Rmod*Rmod)/(Z*Z)); // Equ. (11) E = E / (365/timespan); // calculate E for timespan } Ro = R / Rn; // Equ. (9) mean rain per rain day for (sLong n=0; nGet_Sorted(n, x, y, true, false); if (pDTM->is_NoData(x, y)) // pMS, pBD, pEHD, pEtEo, pRf, pLP, pS { pQ->Set_NoData(x, y); pSL->Set_NoData(x, y); pRc->Set_NoData(x, y); if (bInterflow) pIF->Set_NoData(x, y); } else { if (bInterflow) { Rc = (1000 * pMS->asDouble(x, y) * pBD->asDouble(x, y) * pEHD->asDouble(x, y) * pow(pEtEo->asDouble(x, y), 0.5)) - pIF->asDouble(x, y); // Equ. (8) if (Rc < 0.0) Rc = 0.0; pRc->Set_Value(x, y, Rc); } else pRc->Set_Value(x, y, 1000 * pMS->asDouble(x, y) * pBD->asDouble(x, y) * pEHD->asDouble(x, y) * pow(pEtEo->asDouble(x, y), 0.5)); // Equ. (8), modified L = Get_Cellsize() / cos(pS->asDouble(x, y)); // slope length, approx. from cellsize and slope if (pChannel != NULL && !pChannel->is_NoData(x, y)) Q = pRf->asDouble(x, y) + pQ->asDouble(x, y); else Q = (pRf->asDouble(x, y) + pQ->asDouble(x, y)) * exp((-1.0 * pRc->asDouble(x, y)) / Ro) * pow(L/10,0.1); // Equ. (9) //double Qe = pRf->asDouble(x, y) * exp((-1.0 * pRc->asDouble(x, y)) / Ro); if (bInterflow) { IF = ((R - E - Q) * pLP->asDouble(x, y) * sin(pS->asDouble(x, y))) / timespan; // Equ. (13) if (IF < 0) IF = 0.0; } z = pDTM->asDouble(x, y); dzSum = 0.0; W_down = 0.0; // uncomment this to just route number of cells to verify flow routing /*if (pChannel != NULL && !pChannel->is_NoData(x, y)) Q = 1.0 + pQ->asDouble(x, y); else Q = 0.0; if (bInterflow) IF = 0.0; */ if (pChannel != NULL && !pChannel->is_NoData(x, y)) { steepestN = pDTM->Get_Gradient_NeighborDir(x, y); dzSum = 1.0; } else // MFD Freeman 1991 { for (int i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( pDTM->is_InGrid(ix, iy) ) { d = z - pDTM->asDouble(ix, iy); } else { ix = Get_xTo(i + 4, x); iy = Get_yTo(i + 4, y); if( pDTM->is_InGrid(ix, iy) ) { d = pDTM->asDouble(ix, iy) - z; } else { d = 0.0; } } if( d > 0.0 ) { dzSum += (dz[i] = pow(d / Get_Length(i), Convergence)); } else { dz[i] = 0.0; } } } // flow routing //----------------------------------------------------- if (dzSum > 0.0) { if (pChannel != NULL && !pChannel->is_NoData(x, y)) { if (steepestN != -1) { ix = Get_xTo(steepestN, x); iy = Get_yTo(steepestN, y); pQ->Add_Value(ix, iy, Q); // distribute pW_up->Add_Value(ix, iy, Get_Length(steepestN)); // upslope CL of ix,iy W_down = Get_Length(steepestN); // downslope CL of x,y if (bInterflow) pIF->Add_Value(ix, iy, IF); } } else { d_Q = Q / dzSum; if (bInterflow) d_IF = IF / dzSum; for (int i=0; i<8; i++) { if (dz[i] > 0.0) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( pDTM->is_InGrid(ix, iy) ) { pQ->Add_Value(ix, iy, d_Q * dz[i]); // distribute f_w = 0.5 * Get_Cellsize() / Get_System()->Get_UnitLength(i); pW_up->Add_Value(ix, iy, f_w); // upslope CL of ix,iy W_down += f_w; // downslope CL of x,y if (bInterflow) pIF->Add_Value(ix, iy, d_IF * dz[i]); } } } } } pQ->Set_Value(x, y, Q); // write local values if (bInterflow) pIF->Set_Value(x, y, IF); if (bCalcSoil) { // detachment of soil particles ... per_c = pPer_c->asDouble(x, y); per_z = pPer_z->asDouble(x, y); per_s = pPer_s->asDouble(x, y); ST = pST->asDouble(x, y); KE = pKE->asDouble(x, y); GC = pGC->asDouble(x, y); sin_S = sin(pS->asDouble(x, y)); // ... by raindrop impact Fc = Kc * (per_c / 100.0) * (1.0 - ST) * KE * 0.001; // Equ. (14) Fz = Kz * (per_z / 100.0) * (1.0 - ST) * KE * 0.001; // Equ. (15) Fs = Ks * (per_s / 100.0) * (1.0 - ST) * KE * 0.001; // Equ. (16) F = Fc + Fz + Fs; // Equ. (17) // ... by runoff Hc = DRc * (per_c / 100.0) * pow(Q, 1.5) * (1.0 - (GC + ST)) * pow(sin_S, 0.3) * 0.001; // Equ. (18) Hz = DRz * (per_z / 100.0) * pow(Q, 1.5) * (1.0 - (GC + ST)) * pow(sin_S, 0.3) * 0.001; // Equ. (19) Hs = DRs * (per_s / 100.0) * pow(Q, 1.5) * (1.0 - (GC + ST)) * pow(sin_S, 0.3) * 0.001; // Equ. (20) H = Hc + Hz +Hs; // Equ. (21) // flow velocity ... /// input map with 3 classes // ... for standard bare soil n_manning = 0.015; d_flow = 0.005; slopeFract = tan(pS->asDouble(x, y)); if (slopeFract == 0.0) slopeFract = 0.001; // workaround for velocity calculations, otherwise v_flow and thus TC may become NaN! v_flow_b = 1.0 / n_manning * pow(d_flow, 0.67) * pow(slopeFract, 0.5); // Equ. (22) // ... actual flow velocity n_manning = 0.015; // if .... // global method //d_flow = 0.005; // unchannelled flow //d_flow = 0.01; // shallow rills //d_flow = 0.25; // deeper rills d_flow = flowd_va; // user supplied value v_flow_a = 1.0 / n_manning * pow(d_flow, 0.67) * pow(slopeFract, 0.5) * pow(M_EULER, (-0.018*ST)); // Equ. (23) // ... for vegetated conditions if (pGC->asDouble(x, y) > 0.01) // assuming bare soil as no ground cover v_flow_v = pow(((2 * 9.81) / (pD->asDouble(x, y) * pNV->asDouble(x, y))), 0.5) * pow(slopeFract, 0.5); // Equ. (24) else v_flow_v = 1.0; // bare soil // ... for the effect of tillage d_flow = 0.005; if (pRFR != NULL) { n_manning = pow(M_EULER, -2.1132 + 0.0349 * pRFR->asDouble(x, y)); // Equ. (27) v_flow_t = 1.0 / n_manning * pow(d_flow, 0.67) * pow(slopeFract, 0.5); } else { v_flow_t = 1.0; // if not under arable cultivation and natural soil surface roughness is not accounted for } // particle fall number //d_flow = 0.005; d_flow = flowd_va; // user supplied value if (pGC->asDouble(x, y) > 0.01) // assuming bare soil as no ground cover { Nf_c = (L * vs_c) / (v_flow_v * d_flow); // Equ. (28) Nf_z = (L * vs_z) / (v_flow_v * d_flow); // Equ. (29) Nf_s = (L * vs_s) / (v_flow_v * d_flow); // Equ. (30) } else // bare soil { Nf_c = (L * vs_c) / (v_flow_b * d_flow); // Equ. (28) Nf_z = (L * vs_z) / (v_flow_b * d_flow); // Equ. (29) Nf_s = (L * vs_s) / (v_flow_b * d_flow); // Equ. (30) } // percentage of detached sediment deposited DEPc = 44.1 * pow(Nf_c, 0.29); // Equ. (31) if (DEPc > 100.0) DEPc = 100.0; DEPz = 44.1 * pow(Nf_z, 0.29); // Equ. (32) if (DEPz > 100.0) DEPz = 100.0; DEPs = 44.1 * pow(Nf_s, 0.29); // Equ. (33) if (DEPs > 100.0) DEPs = 100.0; // delivery of detached particles to runoff if (W_down <= 0.0) W_down = 0.5 * Get_Cellsize(); if (pW_up->asDouble(x, y) == 0) W_up = W_down; Gc = (Fc + Hc) * (1.0 - DEPc / 100.0) + (pSLc->asDouble(x, y) * W_up/W_down); // Equ. (35) Gz = (Fz + Hz) * (1.0 - DEPz / 100.0) + (pSLz->asDouble(x, y) * W_up/W_down); // Equ. (36) Gs = (Fs + Hs) * (1.0 - DEPs / 100.0) + (pSLs->asDouble(x, y) * W_up/W_down); // Equ. (37) //G = Gc + Gz + Gs; // Equ. (38) // transport capacity of runoff v_flow = (v_flow_a * v_flow_v * v_flow_t) / v_flow_b; TCc = v_flow * (per_c / 100.0) * pow(Q, 2) * sin_S * 0.001; // Equ. (39) TCz = v_flow * (per_z / 100.0) * pow(Q, 2) * sin_S * 0.001; // Equ. (40) TCs = v_flow * (per_s / 100.0) * pow(Q, 2) * sin_S * 0.001; // Equ. (41) // sediment balance if (TCc >= Gc) { SLc = Gc; #ifdef _TMP_OUT pTCondc->Set_Value(x, y, TCOND_SED_LIMITED); #endif } else // recalculation { if (pGC->asDouble(x, y) > 0.01) // assuming bare soil as no ground cover Nf_c = (L * vs_c1) / (v_flow_v * d_flow); // Equ. (28) else // bare soil Nf_c = (L * vs_c1) / (v_flow_b * d_flow); // Equ. (28) DEPc = 44.1 * pow(Nf_c, 0.29); // Equ. (31) if (DEPc > 100.0) DEPc = 100.0; Gc = Gc * (1.0 - DEPc / 100.0); // Equ. (45) if (TCc >= Gc) { SLc = TCc; #ifdef _TMP_OUT pTCondc->Set_Value(x, y, TCOND_TRANS_LIMITED_TC); #endif } else { SLc = Gc; #ifdef _TMP_OUT pTCondc->Set_Value(x, y, TCONF_TRANS_LIMITED_G); #endif } } if (TCz >= Gz) { SLz = Gz; #ifdef _TMP_OUT pTCondz->Set_Value(x, y, 0); #endif } else // recalculation { if (pGC->asDouble(x, y) > 0.01) // assuming bare soil as no ground cover Nf_z = (L * vs_z1) / (v_flow_v * d_flow); // Equ. (28) else // bare soil Nf_z = (L * vs_z1) / (v_flow_b * d_flow); // Equ. (28) DEPz = 44.1 * pow(Nf_z, 0.29); // Equ. (31) if (DEPz > 100.0) DEPz = 100.0; Gz = Gz * (1.0 - DEPz / 100.0); // Equ. (46) if (TCz >= Gz) { SLz = TCz; #ifdef _TMP_OUT pTCondz->Set_Value(x, y, 1); #endif } else { SLz = Gz; #ifdef _TMP_OUT pTCondz->Set_Value(x, y, 2); #endif } } if (TCs >= Gs) { SLs = Gs; #ifdef _TMP_OUT pTConds->Set_Value(x, y, 0); #endif } else // recalculation { if (pGC->asDouble(x, y) > 0.01) // assuming bare soil as no ground cover Nf_s = (L * vs_s1) / (v_flow_v * d_flow); // Equ. (28) else // bare soil Nf_s = (L * vs_s1) / (v_flow_b * d_flow); // Equ. (28) DEPs = 44.1 * pow(Nf_s, 0.29); // Equ. (31) if (DEPs > 100.0) DEPs = 100.0; Gs = Gs * (1.0 - DEPs / 100.0); // Equ. (47) if (TCs >= Gs) { SLs = TCs; #ifdef _TMP_OUT pTConds->Set_Value(x, y, 1); #endif } else { SLs = Gs; #ifdef _TMP_OUT pTConds->Set_Value(x, y, 2); #endif } } SLc *= pDTM->Get_Cellarea(); SLz *= pDTM->Get_Cellarea(); SLs *= pDTM->Get_Cellarea(); // sediment routing //----------------------------------------------------- if (dzSum > 0.0) { if (pChannel != NULL && !pChannel->is_NoData(x, y) && bChannelT) // Transport along channel, ignore (new) sediment balance within channel { if (steepestN != -1) { ix = Get_xTo(steepestN, x); iy = Get_yTo(steepestN, y); pSLc->Add_Value(ix, iy, pSLc->asDouble(x, y)); pSLz->Add_Value(ix, iy, pSLz->asDouble(x, y)); pSLs->Add_Value(ix, iy, pSLs->asDouble(x, y)); } } else if (pChannel == NULL || (pChannel != NULL && pChannel->is_NoData(x, y))) // no channel grid used or no channel cell { d_SLc = SLc / dzSum; d_SLz = SLz / dzSum; d_SLs = SLs / dzSum; for (int i=0; i<8; i++) { if (dz[i] > 0.0) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( pDTM->is_InGrid(ix, iy) ) { pSLc->Add_Value(ix, iy, d_SLc * dz[i]); // distribute pSLz->Add_Value(ix, iy, d_SLz * dz[i]); pSLs->Add_Value(ix, iy, d_SLs * dz[i]); } } } } } if (pChannel != NULL && !pChannel->is_NoData(x, y)) // channel grid and channel cell: only write incoming material, ignore (new) sediment balance { pSL->Set_Value(x, y, pSLc->asDouble(x, y) + pSLz->asDouble(x, y) + pSLs->asDouble(x, y)); pSLc->Set_Value(x, y, pSLc->asDouble(x, y)); pSLz->Set_Value(x, y, pSLz->asDouble(x, y)); pSLs->Set_Value(x, y, pSLs->asDouble(x, y)); } else // calc mean annual soil loss { pSL->Set_Value(x, y, SLc + SLz + SLs); pSLc->Set_Value(x, y, SLc); pSLz->Set_Value(x, y, SLz); pSLs->Set_Value(x, y, SLs); } #ifdef _TMP_OUT pTCc->Set_Value(x, y, TCc * pDTM->Get_Cellarea()); pTCz->Set_Value(x, y, TCz * pDTM->Get_Cellarea()); pTCs->Set_Value(x, y, TCs * pDTM->Get_Cellarea()); pGc->Set_Value(x, y, Gc * pDTM->Get_Cellarea()); pGz->Set_Value(x, y, Gz * pDTM->Get_Cellarea()); pGs->Set_Value(x, y, Gs * pDTM->Get_Cellarea()); #endif }// bCalcSoil }// not NoData }// for if (pMeteoTab != NULL) { pQ->Save(CSG_String::Format(SG_T("%s\\%03d_Runoff"), sOutPath.c_str(), iRun + 1)); pSL->Save(CSG_String::Format(SG_T("%s\\%03d_SoilLoss"), sOutPath.c_str(), iRun + 1)); } }// for model step //----------------------------------------------------- // delete temporary grids #ifndef _TMP_OUT delete(pRf); delete(pKE); delete(pRc); delete(pSLc); delete(pSLz); delete(pSLs); delete(pW_up); #endif if (bFreeIF) delete(pIF); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/simulation/sim_erosion/MMF_SAGA.h0000664000175000017500000001273012565125410024127 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MMF_SAGA.h 2455 2015-03-22 15:54:14Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_erosion // // // //-------------------------------------------------------// // // // MMF_SAGA.h // // // // Copyright (C) 2009-12 by // // Volker Wichmann // // Muhammad Setiawan // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__MMF_SAGA_H #define HEADER_INCLUDED__MMF_SAGA_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // For debugging purposes the source code is currently configured // to output additional grid datasets; comment the line below and // recompile to disable this functionality. #define _TMP_OUT //--------------------------------------------------------- // coding of transport conditions #define TCOND_SED_LIMITED 0 // sediment limited #define TCOND_TRANS_LIMITED_TC 1 // transport limited (SL = TC) #define TCONF_TRANS_LIMITED_G 2 // transport limited (SL = G) //--------------------------------------------------------- typedef enum EMMF_KE_I_Key { MMF_KE_I_WISCHMEIER_SMITH_1978 = 0, MMF_KE_I_MARSHALL_PALMER, MMF_KE_I_ZANCHI_TORRI_1980, MMF_KE_I_COUTINHO_TOMAS_1995, MMF_KE_I_HUDSON_1965, MMF_KE_I_ONEGA_ET_AL_1998, MMF_KE_I_ROSEWELL_1986, MMF_KE_I_MCISAAC_1990, MMF_KE_I_Count } TMMF_KE_I_Key; //--------------------------------------------------------- const SG_Char gMMF_KE_I_Key_Name[MMF_KE_I_Count][64] = { SG_T("North America east of Rocky Mountains (Wischmeier & Smith 1978)"), SG_T("North-western Europe (Marshall & Palmer)"), SG_T("Mediterranean-type climates (Zanchi & Torri 1980)"), SG_T("Western Mediterranean (Coutinho & Tomas 1995)"), SG_T("Tropical climates (Hudson 1965)"), SG_T("Eastern Asia (Onaga et al. 1998)"), SG_T("Southern hemisphere climates (Rosewell 1986)"), SG_T("Bogor, West-Java, Indonesia (McISaac 1990)") }; //--------------------------------------------------------- class CMMF_SAGA : public CSG_Module_Grid { public: CMMF_SAGA(void); virtual ~CMMF_SAGA(void); protected: virtual bool On_Execute(void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__MMF_SAGA_H saga-2.2.3/src/modules/simulation/sim_erosion/Makefile.in0000664000175000017500000005422012622651172024614 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/simulation/sim_erosion DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_erosion_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_erosion_la_OBJECTS = MMF_SAGA.lo MLB_Interface.lo libsim_erosion_la_OBJECTS = $(am_libsim_erosion_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_erosion_la_SOURCES) DIST_SOURCES = $(libsim_erosion_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1537 2012-11-19 20:05:19Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_erosion.la libsim_erosion_la_SOURCES = \ MMF_SAGA.cpp\ MLB_Interface.cpp\ MMF_SAGA.h\ MLB_Interface.h libsim_erosion_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) --foreign src/modules/simulation/sim_erosion/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_erosion/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_erosion.la: $(libsim_erosion_la_OBJECTS) $(libsim_erosion_la_DEPENDENCIES) $(EXTRA_libsim_erosion_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_erosion_la_OBJECTS) $(libsim_erosion_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MMF_SAGA.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/simulation/sim_erosion/MLB_Interface.cpp0000664000175000017500000001121212565125410025634 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2454 2015-03-22 15:48:12Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_erosion // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return(_TL("Erosion")); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return(_TL("V. Wichmann, M. Setiawan (c) 2009-2012")); case MLB_INFO_Description: return(_TL("Modelling erosion processes.")); case MLB_INFO_Version: return(_TL("1.0")); case MLB_INFO_Menu_Path: return(_TL("Simulation|Erosion")); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "MMF_SAGA.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { CSG_Module *pModule; switch( i ) { case 0: pModule = new CMMF_SAGA; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/simulation/sim_erosion/Makefile.am0000664000175000017500000000114212565125410024573 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1537 2012-11-19 20:05:19Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_erosion.la libsim_erosion_la_SOURCES =\ MMF_SAGA.cpp\ MLB_Interface.cpp\ MMF_SAGA.h\ MLB_Interface.h libsim_erosion_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/simulation/sim_erosion/MLB_Interface.h0000664000175000017500000000771512565125410025316 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 2454 2015-03-22 15:48:12Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_erosion // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__sim_erosion_H #define HEADER_INCLUDED__sim_erosion_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef sim_erosion_EXPORTS #define sim_erosion_EXPORT _SAGA_DLL_EXPORT #else #define sim_erosion_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__sim_erosion_H saga-2.2.3/src/modules/projection/0000775000175000017500000000000012634325745020215 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/projection/Makefile.in0000664000175000017500000004554712622651170022270 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/projection DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 = pj_georeference pj_proj4 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) --foreign src/modules/projection/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/projection/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/projection/pj_proj4/0000775000175000017500000000000012634325745021744 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/projection/pj_proj4/PROJ4_Shapes.cpp0000664000175000017500000002010312565125415024600 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: PROJ4_Shapes.cpp 2289 2014-10-16 13:45:05Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Shapes.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "PROJ4_Shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPROJ4_Shapes::CPROJ4_Shapes(int Interface, bool bInputList) : CPROJ4_Base(Interface, bInputList) { //----------------------------------------------------- // 1. Info... Set_Name (CSG_String::Format(SG_T("[deprecated] %s (%s, %s)"), _TL("Proj.4"), Interface == PROJ4_INTERFACE_DIALOG ? _TL("Dialog") : _TL("Command Line Arguments"), m_bInputList ? _TL("List of Shapes Layers") : _TL("Shapes") )); Set_Author (SG_T("O. Conrad (c) 2004-8")); Set_Description (_TW( "Coordinate Transformation for Shapes.\n" "Based on the PROJ.4 Cartographic Projections library originally written by Gerald Evenden " "and later continued by the United States Department of the Interior, Geological Survey (USGS).\n" "Proj.4 Homepage\n" )); //----------------------------------------------------- // 2. In-/Output... if( m_bInputList ) { Parameters.Add_Shapes_List( Parameters("SOURCE_NODE") , "SOURCE", _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes_List( NULL , "TARGET", _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } else { Parameters.Add_Shapes( Parameters("SOURCE_NODE") , "SOURCE", _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( Parameters("TARGET_NODE") , "TARGET", _TL("Target"), _TL(""), PARAMETER_OUTPUT ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Shapes::On_Execute_Conversion(void) { bool bResult = false; CSG_Shapes *pSource, *pTarget; //----------------------------------------------------- if( m_bInputList ) { CSG_Parameter_Shapes_List *pSources, *pTargets; pSources = Parameters("SOURCE")->asShapesList(); pTargets = Parameters("TARGET")->asShapesList(); pTargets->Del_Items(); for(int i=0; iGet_Count() && Process_Get_Okay(false); i++) { pSource = pSources->asShapes(i); pTarget = SG_Create_Shapes(); if( _Get_Conversion(pSource, pTarget) ) { bResult = true; pTargets->Add_Item(pTarget); } else { delete( pTarget ); } } } else { bool bCopy; pSource = Parameters("SOURCE")->asShapes(); pTarget = Parameters("TARGET")->asShapes(); if( (bCopy = pSource == pTarget) == true ) { pTarget = SG_Create_Shapes(); } //------------------------------------------------- bResult = _Get_Conversion(pSource, pTarget); //------------------------------------------------- if( bCopy ) { pSource->Assign(pTarget); delete( pTarget ); } } return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Shapes::_Get_Conversion(CSG_Shapes *pSource, CSG_Shapes *pTarget) { if( pSource && pSource->is_Valid() && pTarget ) { int nDropped = 0; Process_Set_Text(CSG_String::Format(SG_T("%s: %s"), _TL("Processing"), pSource->Get_Name())); pTarget->Create(pSource->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pSource->Get_Name(), Get_Proj_Name().c_str()), pSource); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pSource->Get_Count()); iShape++) { CSG_Shape *pShape_Source = pSource->Get_Shape(iShape); CSG_Shape *pShape_Target = pTarget->Add_Shape(pShape_Source, SHAPE_COPY_ATTR); bool bDropped = false; for(int iPart=0; iPartGet_Part_Count() && !bDropped; iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart) && !bDropped; iPoint++) { TSG_Point Point = pShape_Source->Get_Point(iPoint, iPart); if( Get_Converted(Point.x, Point.y) ) { pShape_Target->Add_Point(Point.x, Point.y, iPart); } else { bDropped = true; } } } if( bDropped ) { nDropped++; pTarget->Del_Shape(pShape_Target); } } if( nDropped > 0 ) { Message_Add(CSG_String::Format(SG_T("%d %s"), nDropped, _TL("shapes have been dropped"))); } return( pTarget->Get_Count() > 0 ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/crs_transform_pointcloud.h0000664000175000017500000001050212565125415027230 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_transform_pointcloud.h 2147 2014-06-10 12:57:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_pointcloud.h // // // // Copyright (C) 2014 by // // Volker Wichmann // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_transform_pointcloud_H #define HEADER_INCLUDED__crs_transform_pointcloud_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Transform_PointCloud : public CCRS_Transform { public: CCRS_Transform_PointCloud(bool bList); protected: virtual bool On_Execute_Transformation (void); bool Transform (CSG_PointCloud *pSource, CSG_PointCloud *pTarget); private: bool m_bList; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_transform_pointcloud_H saga-2.2.3/src/modules/projection/pj_proj4/crs_transform.h0000664000175000017500000001224512565125415024776 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_transform.h 2147 2014-06-10 12:57:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_transform_H #define HEADER_INCLUDED__crs_transform_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CSG_CRSProjector { public: CSG_CRSProjector(void); virtual ~CSG_CRSProjector(void); bool Destroy (void); static CSG_String Get_Version (void); static CSG_String Get_Description (void); bool Set_Source (const CSG_Projection &Projection); const CSG_Projection & Get_Source (void) const { return( m_Source ); } bool Set_Target (const CSG_Projection &Projection); const CSG_Projection & Get_Target (void) const { return( m_Target ); } bool Set_Inverse (bool bOn = true); bool Get_Inverse (void) const { return( m_bInverse ); } bool Set_Precise_Mode (bool bOn = true); bool Get_Precise_Mode (void) const { return( m_pGCS != NULL ); } bool Get_Projection (double &x, double &y) const; bool Get_Projection (TSG_Point &Point) const; bool Get_Projection (CSG_Point &Point) const; bool Get_Projection (double &x, double &y, double &z) const; bool Get_Projection (TSG_Point_Z &Point) const; bool Get_Projection (CSG_Point_Z &Point) const; private: bool m_bInverse; void *m_pSource, *m_pTarget, *m_pGCS; CSG_Projection m_Source, m_Target; bool _Set_Projection (const CSG_Projection &Projection, void **ppProjection, bool bInverse); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_transform_H saga-2.2.3/src/modules/projection/pj_proj4/crs_distance.h0000664000175000017500000001371012565125415024553 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_distance.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_distance.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_distance_H #define HEADER_INCLUDED__crs_distance_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Distance_Calculator { public: CCRS_Distance_Calculator(void); CCRS_Distance_Calculator(const CSG_Projection &Projection, double Epsilon); virtual ~CCRS_Distance_Calculator(void); bool Create (const CSG_Projection &Projection, double Epsilon); double Get_Orthodrome (const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine); double Get_Loxodrome (const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine); private: double m_Epsilon; CSG_CRSProjector m_Projector, m_ProjToGCS; double Get_Distance (TSG_Point A, TSG_Point B); void Add_Segment (const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine, double *Length = NULL); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Distance_Lines : public CSG_Module { public: CCRS_Distance_Lines(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Distance_Points : public CCRS_Base { public: CCRS_Distance_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Distance_Interactive : public CSG_Module_Interactive { public: CCRS_Distance_Interactive(void); virtual CSG_String 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_Down; CSG_Projection m_Projection; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_distance_H saga-2.2.3/src/modules/projection/pj_proj4/PROJ4_Grid.h0000664000175000017500000001213412565125415023714 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: PROJ4_Grid.h 2212 2014-09-01 13:29:48Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Grid.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PROJ4_Grid_H #define HEADER_INCLUDED__PROJ4_Grid_H //--------------------------------------------------------- #include "PROJ4_Base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CPROJ4_Grid : public CPROJ4_Base { public: CPROJ4_Grid(int Interface, bool bInputList); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Alternatives") ); } protected: virtual bool On_Execute_Conversion (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: int m_Interpolation; CSG_Parameters_Grid_Target m_Grid_Target; 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 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); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PROJ4_Grid_H saga-2.2.3/src/modules/projection/pj_proj4/gcs_lon_range.h0000664000175000017500000001012512565125415024707 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gcs_lon_range.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // gcs_lon_range.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gcs_lon_range_H #define HEADER_INCLUDED__gcs_lon_range_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGCS_Grid_Longitude_Range : public CSG_Module_Grid { public: CGCS_Grid_Longitude_Range(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gcs_lon_range_H saga-2.2.3/src/modules/projection/pj_proj4/PROJ4_Grid.cpp0000664000175000017500000004130412565125415024250 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: PROJ4_Grid.cpp 2447 2015-03-19 14:43:42Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Grid.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "PROJ4_Grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPROJ4_Grid::CPROJ4_Grid(int Interface, bool bInputList) : CPROJ4_Base(Interface, bInputList) { //----------------------------------------------------- Set_Name (CSG_String::Format(SG_T("[deprecated] %s (%s, %s)"), _TL("Proj.4"), Interface == PROJ4_INTERFACE_DIALOG ? _TL("Dialog") : _TL("Command Line Arguments"), m_bInputList ? _TL("List of Grids") : _TL("Grid") )); Set_Author ("O. Conrad (c) 2004-8"); Set_Description (_TW( "Coordinate Transformation for Grids.\n" "Based on the PROJ.4 Cartographic Projections library originally written by Gerald Evenden " "and later continued by the United States Department of the Interior, Geological Survey (USGS).\n" "Proj.4 Homepage\n" )); //----------------------------------------------------- m_Grid_Target.Create(Add_Parameters("TARGET", _TL("Target Grid System"), _TL("")), false); if( m_bInputList ) { Parameters.Add_Grid_List( Parameters("SOURCE_NODE"), "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT, false ); Parameters.Add_Grid_List( NULL, "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } else { Parameters.Add_Grid( Parameters("SOURCE_NODE"), "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); m_Grid_Target.Add_Grid("TARGET", _TL("Target"), false); } m_Grid_Target.Add_Grid("OUT_X", _TL("X Coordinates"), true); m_Grid_Target.Add_Grid("OUT_Y", _TL("Y Coordinates"), true); //----------------------------------------------------- Parameters.Add_Choice( Parameters("TARGET_NODE") , "INTERPOLATION" , _TL("Interpolation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("Nearest Neigbhor"), _TL("Bilinear Interpolation"), _TL("Inverse Distance Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 4 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPROJ4_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CPROJ4_Base::On_Parameter_Changed(pParameters, pParameter); return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CPROJ4_Grid::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CPROJ4_Base::On_Parameters_Enable(pParameters, pParameter); return( m_Grid_Target.On_Parameters_Enable(pParameters, pParameter) ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Grid::On_Execute_Conversion(void) { TSG_Rect Extent; m_Interpolation = Parameters("INTERPOLATION")->asInt(); //----------------------------------------------------- if( m_bInputList ) { CSG_Parameter_Grid_List *pSources = Parameters("SOURCE")->asGridList(); CSG_Parameter_Grid_List *pTargets = Parameters("TARGET")->asGridList(); if( pSources->Get_Count() < 1 ) { return( false ); } if( Get_Target_Extent(pSources->asGrid(0), Extent) ) { m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), Extent, pSources->asGrid(0)->Get_NY()); } if( !Dlg_Parameters("TARGET") ) { return( false ); } CSG_Grid_System System(m_Grid_Target.Get_System()); //------------------------------------------------- if( System.is_Valid() ) { pTargets->Del_Items(); for(int i=0; iGet_Count(); i++) { pTargets->Add_Item(SG_Create_Grid(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 = Parameters("SOURCE")->asGrid(); if( Get_Target_Extent(pSource, Extent) ) { m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), Extent, pSource->Get_NY()); } if( !Dlg_Parameters("TARGET") ) { return( false ); } CSG_Grid *pTarget = m_Grid_Target.Get_Grid(m_Interpolation == 0 ? pSource->Get_Type() : SG_DATATYPE_Float); //------------------------------------------------- if( pTarget ) { return( Set_Grid(pSource, pTarget) ); } } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Grid::Set_Grids(CSG_Parameter_Grid_List *pSources, CSG_Parameter_Grid_List *pTargets) { if( !pSources || pSources->Get_Count() < 1 || !pTargets || pTargets->Get_Count() != pSources->Get_Count() || !Set_Inverse() ) { return( false ); } //------------------------------------------------- int x, y, i; double z; TSG_Point Pt_Source, Pt_Target; CSG_Grid_System System; CSG_Grid *pX, *pY; System = pTargets->asGrid(0)->Get_System(); Init_XY(System, &pX, &pY); //------------------------------------------------- for(y=0, Pt_Target.y=System.Get_YMin(); ySet_Value(x, y, Pt_Source.x); if( pY ) pY->Set_Value(x, y, Pt_Source.y); for(i=0; iGet_Count(); i++) { if( pSources->asGrid(i)->Get_Value(Pt_Source, z, m_Interpolation) ) { pTargets->asGrid(i)->Set_Value(x, y, z); } } } } } 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; iGet_Count(); i++) { pTarget->Add_Field(pSources->asGrid(i)->Get_Name(), pSources->asGrid(i)->Get_Type()); } for(y=0, Pt_Source.y=pSource->Get_YMin(); yGet_NY() && Set_Progress(y, pSource->Get_NY()); y++, Pt_Source.y+=pSource->Get_Cellsize()) { for(x=0, Pt_Source.x=pSource->Get_XMin(); xGet_NX(); x++, Pt_Source.x+=pSource->Get_Cellsize()) { if( !pSource->is_NoData(x, y) ) { Pt_Target = Pt_Source; if( Get_Converted(Pt_Target) ) { pShape = pTarget->Add_Shape(); pShape->Add_Point(Pt_Target); for(i=0; iGet_Count(); i++) { if( pSources->asGrid(i)->Get_Value(Pt_Source, z, m_Interpolation) ) { pShape->Set_Value(i, z); } else { pShape->Set_NoData(i); } } } } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Grid::Set_Grid(CSG_Grid *pSource, CSG_Grid *pTarget) { if( pSource && pTarget && Set_Inverse() ) { int x, y; double z; TSG_Point Pt_Source, Pt_Target; CSG_Grid *pX, *pY; Init_XY(pTarget->Get_System(), &pX, &pY); Init_Target(pSource, pTarget); //------------------------------------------------- for(y=0, Pt_Target.y=pTarget->Get_YMin(); yGet_NY() && Set_Progress(y, pTarget->Get_NY()); y++, Pt_Target.y+=pTarget->Get_Cellsize()) { for(x=0, Pt_Target.x=pTarget->Get_XMin(); xGet_NX(); x++, Pt_Target.x+=pTarget->Get_Cellsize()) { 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); if( pSource->Get_Value(Pt_Source, z, m_Interpolation) ) { pTarget->Set_Value(x, y, z); } } } } return( true ); } return( false ); } //--------------------------------------------------------- bool CPROJ4_Grid::Set_Shapes(CSG_Grid *pSource, CSG_Shapes *pTarget) { int x, y; TSG_Point Pt_Source, Pt_Target; CSG_Shape *pShape; if( pSource && pTarget ) { pTarget->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pSource->Get_Name(), Get_Proj_Name().c_str())); pTarget->Add_Field("Z", SG_DATATYPE_Double); for(y=0, Pt_Source.y=pSource->Get_YMin(); yGet_NY() && Set_Progress(y, pSource->Get_NY()); y++, Pt_Source.y+=pSource->Get_Cellsize()) { for(x=0, Pt_Source.x=pSource->Get_XMin(); xGet_NX(); x++, Pt_Source.x+=pSource->Get_Cellsize()) { if( !pSource->is_NoData(x, y) ) { Pt_Target = Pt_Source; if( Get_Converted(Pt_Target) ) { pShape = pTarget->Add_Shape(); pShape->Add_Point(Pt_Target); pShape->Set_Value(0, pSource->asDouble(x, y)); } } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Grid::Init_XY(const CSG_Grid_System &System, CSG_Grid **ppX, CSG_Grid **ppY) { *ppX = *ppY = NULL; if( (*ppX = m_Grid_Target.Get_Grid("OUT_X", SG_DATATYPE_Float)) != NULL ) { (*ppX)->Assign_NoData(); (*ppX)->Set_Name(_TL("X Coordinates")); } if( (*ppY = m_Grid_Target.Get_Grid("OUT_Y", SG_DATATYPE_Float)) != NULL ) { (*ppY)->Assign_NoData(); (*ppY)->Set_Name(_TL("Y Coordinates")); } return( true ); } //--------------------------------------------------------- bool CPROJ4_Grid::Init_Target(CSG_Grid *pSource, CSG_Grid *pTarget) { if( pSource && pTarget ) { pTarget->Set_NoData_Value_Range(pSource->Get_NoData_Value(), pSource->Get_NoData_hiValue()); pTarget->Set_Scaling(pSource->Get_Scaling(), pSource->Get_Offset()); 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(); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CPROJ4_Grid::Get_MinMax(TSG_Rect &r, double x, double y) { if( Get_Converted(x, y) ) { if( r.xMin > r.xMax ) { r.xMin = r.xMax = x; } else if( r.xMin > x ) { r.xMin = x; } else if( r.xMax < x ) { r.xMax = x; } if( r.yMin > r.yMax ) { r.yMin = r.yMax = y; } else if( r.yMin > y ) { r.yMin = y; } else if( r.yMax < y ) { r.yMax = y; } } } //--------------------------------------------------------- bool CPROJ4_Grid::Get_Target_Extent(CSG_Grid *pSource, TSG_Rect &Extent) { if( !pSource ) { return( false ); } int x, y, Resolution; Resolution = 256; Extent.xMin = Extent.yMin = 1.0; Extent.xMax = Extent.yMax = 0.0; switch( 1 ) { case 0: // corners { Get_MinMax(Extent, pSource->Get_XMin(), pSource->Get_YMin()); Get_MinMax(Extent, pSource->Get_XMax(), pSource->Get_YMin()); Get_MinMax(Extent, pSource->Get_XMin(), pSource->Get_YMax()); Get_MinMax(Extent, pSource->Get_XMax(), pSource->Get_YMax()); } break; case 1: // edges { double d; int yStep = 1 + pSource->Get_NY() / Resolution; for(y=0, d=pSource->Get_YMin(); yGet_NY(); y+=yStep, d+=yStep*pSource->Get_Cellsize()) { Get_MinMax(Extent, pSource->Get_XMin(), d); Get_MinMax(Extent, pSource->Get_XMax(), d); } int xStep = 1 + pSource->Get_NX() / Resolution; for(x=0, d=pSource->Get_XMin(); xGet_NX(); x+=xStep, d+=xStep*pSource->Get_Cellsize()) { Get_MinMax(Extent, d, pSource->Get_YMin()); Get_MinMax(Extent, d, pSource->Get_YMax()); } } break; case 2: // all cells { TSG_Point p; int xStep = 1 + pSource->Get_NX() / Resolution; int yStep = 1 + pSource->Get_NY() / Resolution; for(y=0, p.y=pSource->Get_YMin(); yGet_NY() && Set_Progress(y, pSource->Get_NY()); y+=yStep, p.y+=yStep*pSource->Get_Cellsize()) { for(x=0, p.x=pSource->Get_XMin(); xGet_NX(); x+=xStep, p.x+=xStep*pSource->Get_Cellsize()) { if( !pSource->is_NoData(x, y) ) { Get_MinMax(Extent, p.x, p.y); } } } } break; } return( is_Progress() && Extent.xMin < Extent.xMax && Extent.yMin < Extent.yMax ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/crs_indicatrix.h0000664000175000017500000001035112565125415025115 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_indicatrix.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_indicatrix.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_indicatrix_H #define HEADER_INCLUDED__crs_indicatrix_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Indicatrix : public CCRS_Transform { public: CCRS_Indicatrix(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Execute_Transformation (void); private: double m_Scale, m_Size; CSG_Points m_Circle; bool Get_Indicatrix (double lon, double lat, CSG_Shape *pIndicatrix); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_indicatrix_H saga-2.2.3/src/modules/projection/pj_proj4/gcs_graticule.h0000664000175000017500000001117612565125415024731 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gcs_graticule.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // gcs_graticule.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gcs_graticule_H #define HEADER_INCLUDED__gcs_graticule_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGCS_Graticule : public CCRS_Base { public: CGCS_Graticule(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_CRSProjector m_Projector; bool Get_Graticule (const CSG_Rect &Extent); bool Get_Extent (const CSG_Rect &Extent, CSG_Rect &rGCS); bool Get_Coordinate (const CSG_Rect &Extent, CSG_Shapes *pCoordinates, CSG_Shape *pLine, int Axis); double Get_Interval (const CSG_Rect &Extent); CSG_String Get_Degree (double Value, int Precision); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gcs_graticule_H saga-2.2.3/src/modules/projection/pj_proj4/crs_transform_pointcloud.cpp0000664000175000017500000001732612565125415027576 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_transform_pointcloud.cpp 2147 2014-06-10 12:57:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_pointcloud.cpp // // // // Copyright (C) 2014 by // // Volker Wichmann // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_transform_pointcloud.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Transform_PointCloud::CCRS_Transform_PointCloud(bool bList) { m_bList = bList; //----------------------------------------------------- Set_Name (m_bList ? _TL("Coordinate Transformation (Point Cloud List)") : _TL("Coordinate Transformation (Point Cloud)") ); Set_Author (SG_T("V. Wichmann, O. Conrad (c) 2014")); Set_Description (_TW( "Coordinate transformation for point clouds.\n" )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- if( m_bList ) { Parameters.Add_PointCloud_List( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_PointCloud_List( NULL , "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } //----------------------------------------------------- else { Parameters.Add_PointCloud( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_PointCloud( NULL , "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_PointCloud::On_Execute_Transformation(void) { if( m_bList ) { CSG_Parameter_PointCloud_List *pSources, *pTargets; pSources = Parameters("SOURCE")->asPointCloudList(); pTargets = Parameters("TARGET")->asPointCloudList(); pTargets->Del_Items(); for(int i=0; iGet_Count() && Process_Get_Okay(false); i++) { CSG_PointCloud *pSource = pSources->asPointCloud(i); CSG_PointCloud *pTarget = SG_Create_PointCloud(pSource); pTarget->Set_Name(CSG_String::Format(SG_T("%s_transformed"), pSource->Get_Name())); if( Transform(pSource, pTarget) ) { pTargets->Add_Item(pTarget); } else { delete(pTarget); } } return( pTargets->Get_Count() > 0 ); } else { CSG_PointCloud *pSource = Parameters("SOURCE")->asPointCloud(); CSG_PointCloud *pTarget = Parameters("TARGET")->asPointCloud(); if( pSource == pTarget ) { CSG_String sName = pSource->Get_Name(); pTarget = SG_Create_PointCloud(pSource); if( Transform(pSource, pTarget) ) { pSource->Assign(pTarget); pSource->Set_Name(CSG_String::Format(SG_T("%s_transformed"), sName.c_str())); return( true ); } else { delete(pTarget); return( false ); } } else { pTarget->Create(pSource); pTarget->Set_Name(CSG_String::Format(SG_T("%s_transformed"), pSource->Get_Name())); } return( Transform(pSource, pTarget) ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_PointCloud::Transform(CSG_PointCloud *pSource, CSG_PointCloud *pTarget) { if( !pTarget || !pSource || !pSource->is_Valid() ) { return( false ); } if( !m_Projector.Set_Source(pSource->Get_Projection()) ) { return( false ); } int nDropped = 0; Process_Set_Text(CSG_String::Format(SG_T("%s: %s"), _TL("Processing"), pSource->Get_Name())); for(int iPoint=0; iPointGet_Point_Count() && Set_Progress(iPoint, pSource->Get_Point_Count()); iPoint++) { TSG_Point_Z Point = pSource->Get_Point(iPoint); if( m_Projector.Get_Projection(Point.x, Point.y, Point.z) ) { pTarget->Add_Point(Point.x, Point.y, Point.z); for(int iField=0; iFieldGet_Attribute_Count(); iField++) { pTarget->Set_Attribute(iField, pSource->Get_Attribute(iPoint, iField)); } } else { nDropped++; } } if( nDropped > 0 ) { Message_Add(CSG_String::Format(SG_T("%s: %d %s"), pTarget->Get_Name(), nDropped, _TL("points have been dropped"))); } pTarget->Get_Projection() = m_Projector.Get_Target(); return( pTarget->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/gcs_lon_range.cpp0000664000175000017500000001634212565125415025251 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gcs_lon_range.cpp 2208 2014-08-27 16:00:51Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // gcs_lon_range.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gcs_lon_range.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGCS_Grid_Longitude_Range::CGCS_Grid_Longitude_Range(void) { //----------------------------------------------------- Set_Name (_TL("Change Longitudinal Range for Grids")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Change the longitudinal range of grids using geographic coordinates, " "i.e. from 0 - 360 to -180 - 180 and vice versa." )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, false ); Parameters.Add_Choice( NULL , "DIRECTION" , _TL("Direction"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), SG_T("0 - 360 >> -180 - 180"), SG_T("-180 - 180 >> 0 - 360") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGCS_Grid_Longitude_Range::On_Execute(void) { CSG_Parameter_Grid_List *pInput = Parameters("INPUT" )->asGridList(); CSG_Parameter_Grid_List *pOutput = Parameters("OUTPUT")->asGridList(); if( pInput->Get_Count() <= 0 ) { Message_Dlg(_TL("nothing to do: no data in selection")); return( false ); } pOutput->Del_Items(); //----------------------------------------------------- int xZero; CSG_Grid_System Target; //----------------------------------------------------- if( Parameters("DIRECTION")->asInt() == 0 ) // 0 - 360 >> -180 - 180 { if( Get_XMax() <= 180.0 ) { Message_Add(_TL("Nothing to do. Raster is already within target range.")); return( true ); } else if( Get_XMin() >= 180.0 ) { xZero = 0; Target.Assign(Get_Cellsize(), Get_XMin() - 360.0, Get_YMin(), Get_NX(), Get_NY()); } else if( Get_XMax() - 360.0 < Get_XMin() - Get_Cellsize() ) { Error_Set(_TL("Nothing to do be done. Raster splitting is not supported.")); return( false ); } else { xZero = (int)(0.5 + 180.0 / Get_Cellsize()); Target.Assign(Get_Cellsize(), Get_XMin() - 180.0, Get_YMin(), Get_NX(), Get_NY()); } } //----------------------------------------------------- else // -180 - 180 >> 0 - 360 { if( Get_XMin() >= 0.0 ) { Message_Add(_TL("Nothing to do. Raster is already within target range.")); return( true ); } else if( Get_XMax() <= 0.0 ) { xZero = 0; Target.Assign(Get_Cellsize(), Get_XMin() + 360.0, Get_YMin(), Get_NX(), Get_NY()); } else if( Get_XMin() + 360.0 > Get_XMax() + Get_Cellsize() ) { Error_Set(_TL("Nothing to do be done. Raster splitting is not supported.")); return( false ); } else { xZero = (int)(0.5 + 180.0 / Get_Cellsize()); Target.Assign(Get_Cellsize(), Get_XMin() - 180.0, Get_YMin(), Get_NX(), Get_NY()); } } //----------------------------------------------------- for(int i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Grid *pIn = pInput->asGrid(i); CSG_Grid *pOut = SG_Create_Grid(Target, pIn->Get_Type()); pOut->Set_Name(pIn->Get_Name()); pOut->Set_NoData_Value_Range(pIn->Get_NoData_Value(), pIn->Get_NoData_hiValue()); pOut->Set_Scaling(pIn->Get_Scaling(), pIn->Get_Offset()); pOutput->Add_Item(pOut); for(int y=0; y= Get_NX() ) { xx = 0; } pOut->Set_Value(xx, y, pIn->asDouble(x, y)); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/crs_base.h0000664000175000017500000001277112565125415023701 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_base.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_base.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_base_H #define HEADER_INCLUDED__crs_base_H //--------------------------------------------------------- #include "crs_transform.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Base : public CSG_Module { public: CCRS_Base(void); virtual bool do_Sync_Projections (void) { return( false ); } protected: virtual bool On_Before_Execution (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); bool Get_Projection (CSG_Projection &Projection); private: CSG_Projection m_Projection; bool Set_User_Parameters (CSG_Parameters *pParameters); bool Add_User_Projection (const CSG_String &sID, const CSG_String &sName, const CSG_String &sArgs); CSG_String Get_User_Definition (CSG_Parameters &pParameters); bool Set_User_Definition (CSG_Parameters &pParameters, const CSG_String &Proj4); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Picker : public CCRS_Base { public: CCRS_Picker(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Transform : public CCRS_Base { public: CCRS_Transform(void) {} protected: CSG_CRSProjector m_Projector; virtual bool On_Execute (void); virtual bool On_Execute_Transformation (void) = 0; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_base_H saga-2.2.3/src/modules/projection/pj_proj4/crs_grid_geogcoords.h0000664000175000017500000001016312565125415026120 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_grid_geogcoords.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_grid_geogcoords.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_grid_geogcoords_H #define HEADER_INCLUDED__crs_grid_geogcoords_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Grid_GeogCoords : public CSG_Module_Grid { public: CCRS_Grid_GeogCoords(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_grid_geogcoords_H saga-2.2.3/src/modules/projection/pj_proj4/Makefile.in0000664000175000017500000005762712622651170024021 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/projection/pj_proj4 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libpj_proj4_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libpj_proj4_la_OBJECTS = MLB_Interface.lo crs_assign.lo crs_base.lo \ crs_distance.lo crs_grid_geogcoords.lo crs_indicatrix.lo \ crs_transform.lo crs_transform_grid.lo \ crs_transform_pointcloud.lo crs_transform_shapes.lo \ gcs_graticule.lo gcs_lon_range.lo PROJ4_Base.lo PROJ4_Grid.lo \ PROJ4_Shapes.lo libpj_proj4_la_OBJECTS = $(am_libpj_proj4_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libpj_proj4_la_SOURCES) DIST_SOURCES = $(libpj_proj4_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 2462 2015-03-27 16:29:25Z oconrad $ # DEP_LIBS = -lproj @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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 $(LOCAL_INCS) AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) $(LOCAL_LIBS) pkglib_LTLIBRARIES = libpj_proj4.la libpj_proj4_la_SOURCES = \ MLB_Interface.cpp\ crs_assign.cpp\ crs_base.cpp\ crs_distance.cpp\ crs_grid_geogcoords.cpp\ crs_indicatrix.cpp\ crs_transform.cpp\ crs_transform_grid.cpp\ crs_transform_pointcloud.cpp\ crs_transform_shapes.cpp\ gcs_graticule.cpp\ gcs_lon_range.cpp\ PROJ4_Base.cpp\ PROJ4_Grid.cpp\ PROJ4_Shapes.cpp\ MLB_Interface.h\ crs_assign.h\ crs_base.h\ crs_distance.h\ crs_grid_geogcoords.h\ crs_indicatrix.h\ crs_transform.h\ crs_transform_grid.h\ crs_transform_pointcloud.h\ crs_transform_shapes.h\ gcs_graticule.h\ gcs_lon_range.h\ PROJ4_Base.h\ PROJ4_Grid.h\ PROJ4_Shapes.h libpj_proj4_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) --foreign src/modules/projection/pj_proj4/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/projection/pj_proj4/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libpj_proj4.la: $(libpj_proj4_la_OBJECTS) $(libpj_proj4_la_DEPENDENCIES) $(EXTRA_libpj_proj4_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libpj_proj4_la_OBJECTS) $(libpj_proj4_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PROJ4_Base.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PROJ4_Grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PROJ4_Shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_assign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_base.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_distance.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_grid_geogcoords.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_indicatrix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_transform.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_transform_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_transform_pointcloud.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_transform_shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gcs_graticule.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gcs_lon_range.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/projection/pj_proj4/crs_transform_grid.h0000664000175000017500000001223612565125415026003 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_transform_grid.h 2212 2014-09-01 13:29:48Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_transform_grid_H #define HEADER_INCLUDED__crs_transform_grid_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Transform_Grid : public CCRS_Transform { public: CCRS_Transform_Grid(bool bList); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute_Transformation (void); private: bool m_bList; int m_Interpolation; CSG_Parameters_Grid_Target m_Grid_Target; CSG_Grid m_Target_Area; bool Transform (CSG_Grid *pGrid ); bool Transform (CSG_Parameter_Grid_List *pGrids); bool Transform (CSG_Grid *pGrid , CSG_Grid *pTarget ); bool Transform (CSG_Parameter_Grid_List *pGrids, CSG_Parameter_Grid_List *pTargets, const CSG_Grid_System &Target_System); bool Transform (CSG_Grid *pGrid , CSG_Shapes *pPoints); bool Transform (CSG_Parameter_Grid_List *pGrids, CSG_Shapes *pPoints); void Get_MinMax (TSG_Rect &r, double x, double y); bool Get_Target_System (const CSG_Grid_System &System, bool bEdge); bool Set_Target_Area (const CSG_Grid_System &Source, const CSG_Grid_System &Target); bool is_In_Target_Area (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_transform_grid_H saga-2.2.3/src/modules/projection/pj_proj4/PROJ4_Shapes.h0000664000175000017500000001050412565125415024251 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: PROJ4_Shapes.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Shapes.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PROJ4_Shapes_H #define HEADER_INCLUDED__PROJ4_Shapes_H //--------------------------------------------------------- #include "PROJ4_Base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CPROJ4_Shapes : public CPROJ4_Base { public: CPROJ4_Shapes(int Interface, bool bInputList); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Alternatives") ); } protected: virtual bool On_Execute_Conversion (void); private: bool _Get_Conversion (CSG_Shapes *pSource, CSG_Shapes *pTarget); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PROJ4_Shapes_H saga-2.2.3/src/modules/projection/pj_proj4/crs_transform_grid.cpp0000664000175000017500000005205612565125415026342 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_transform_grid.cpp 2334 2014-11-11 15:29:33Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_transform_grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Transform_Grid::CCRS_Transform_Grid(bool bList) { CSG_Parameter *pNode; m_bList = bList; //----------------------------------------------------- Set_Name (m_bList ? _TL("Coordinate Transformation (Grid List)") : _TL("Coordinate Transformation (Grid)") ); Set_Author ("O. Conrad (c) 2010"); Set_Description (_TW( "Coordinate transformation for grids.\n" )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- m_Grid_Target.Create(Add_Parameters("TARGET", _TL("Target Grid System"), _TL("")), false); if( m_bList ) { pNode = Parameters.Add_Grid_List( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } //----------------------------------------------------- else { pNode = Parameters.Add_Grid( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); m_Grid_Target.Add_Grid("GRID", _TL("Target"), false); } m_Grid_Target.Add_Grid("OUT_X", _TL("X Coordinates"), true); m_Grid_Target.Add_Grid("OUT_Y", _TL("Y Coordinates"), true); //----------------------------------------------------- Parameters.Add_Choice( pNode , "INTERPOLATION" , _TL("Interpolation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("Nearest Neigbhor"), _TL("Bilinear Interpolation"), _TL("Inverse Distance Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 4 ); Parameters.Add_Value( pNode , "KEEP_TYPE" , _TL("Preserve Data Type"), _TL(""), PARAMETER_TYPE_Bool, true ); //----------------------------------------------------- Parameters.Add_Value( pNode , "TARGET_AREA" , _TL("Use Target Area Polygon"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CCRS_Transform_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CCRS_Transform::On_Parameter_Changed(pParameters, pParameter); return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CCRS_Transform_Grid::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CCRS_Transform::On_Parameters_Enable(pParameters, pParameter); return( m_Grid_Target.On_Parameters_Enable(pParameters, pParameter) ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Grid::On_Execute_Transformation(void) { m_Interpolation = Parameters("INTERPOLATION")->asInt(); //----------------------------------------------------- if( m_bList ) { int i; CSG_Parameters Grids; CSG_Parameter_Grid_List *pSources, *pTargets, *pGrids; pSources = Parameters("SOURCE")->asGridList(); pTargets = Parameters("GRIDS" )->asGridList(); pTargets->Del_Items(); pGrids = Grids.Add_Grid_List(NULL, "GRD", SG_T(""), SG_T(""), PARAMETER_INPUT, false)->asGridList(); for(i=0; iGet_Count(); i++) { if( pSources->asGrid(i)->Get_Projection().is_Okay() ) { pGrids->Add_Item(pSources->asGrid(i)); } else { Error_Set(CSG_String::Format(SG_T("%s: %s\n"), _TL("unknown projection"), pSources->asGrid(i)->Get_Name())); } } pSources = Grids.Add_Grid_List(NULL, "SRC", SG_T(""), SG_T(""), PARAMETER_INPUT, false)->asGridList(); while( pGrids->Get_Count() > 0 ) { pSources->Add_Item(pGrids->asGrid(pGrids->Get_Count() - 1)); pGrids ->Del_Item(pGrids->Get_Count() - 1); for(i=pGrids->Get_Count()-1; i>=0; i--) { if( pGrids->asGrid(i)->Get_Projection() == pSources->asGrid(0)->Get_Projection() ) { pSources->Add_Item(pGrids->asGrid(i)); pGrids ->Del_Item(i); } } m_Projector.Set_Inverse(false); Transform(pSources); pSources->Del_Items(); } return( pTargets->Get_Count() > 0 ); } //----------------------------------------------------- else { return( Transform(Parameters("SOURCE")->asGrid()) ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Grid *pGrid) { if( pGrid->Get_Projection().is_Okay() && m_Projector.Set_Source(pGrid->Get_Projection()) && Get_Target_System(pGrid->Get_System(), true) ) { TSG_Data_Type Type = m_Interpolation == 0 || Parameters("KEEP_TYPE")->asBool() ? pGrid->Get_Type() : SG_DATATYPE_Float; return( Transform(pGrid, m_Grid_Target.Get_Grid("GRID", Type)) ); } return( false ); } //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Parameter_Grid_List *pGrids) { if( pGrids->Get_Count() > 0 && m_Projector.Set_Source(pGrids->asGrid(0)->Get_Projection()) && Get_Target_System(pGrids->asGrid(0)->Get_System(), true) ) { CSG_Grid_System System(m_Grid_Target.Get_System()); return( Transform(pGrids, Parameters("GRIDS")->asGridList(), System) ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Grid *pGrid, CSG_Grid *pTarget) { if( !m_Projector.Set_Inverse(true) || !pTarget || !pGrid ) { return( false ); } //----------------------------------------------------- CSG_Grid *pX, *pY; if( (pX = m_Grid_Target.Get_Grid("OUT_X")) != NULL ) { pX->Assign_NoData(); pX->Set_Name(_TL("X Coordinates")); pX->Get_Projection().Create(m_Projector.Get_Target()); } if( (pY = m_Grid_Target.Get_Grid("OUT_Y")) != NULL ) { pY->Assign_NoData(); pY->Set_Name(_TL("Y Coordinates")); pY->Get_Projection().Create(m_Projector.Get_Target()); } //----------------------------------------------------- Set_Target_Area(pGrid->Get_System(), pTarget->Get_System()); bool bGeogCS_Adjust = m_Projector.Get_Source().Get_Type() == SG_PROJ_TYPE_CS_Geographic && pGrid->Get_XMax() > 180.0; //------------------------------------------------- pTarget->Set_NoData_Value_Range (pGrid->Get_NoData_Value(), pGrid->Get_NoData_hiValue()); pTarget->Set_Scaling (pGrid->Get_Scaling(), pGrid->Get_Offset()); pTarget->Set_Name (CSG_String::Format(SG_T("%s"), pGrid->Get_Name())); pTarget->Set_Unit (pGrid->Get_Unit()); pTarget->Assign_NoData(); pTarget->Get_Projection().Create(m_Projector.Get_Target()); //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, pTarget->Get_NY()); y++) { double yTarget = pTarget->Get_YMin() + y * pTarget->Get_Cellsize(); // #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double z, ySource, xSource = pTarget->Get_XMin() + x * pTarget->Get_Cellsize(); if( is_In_Target_Area(x, y) && m_Projector.Get_Projection(xSource, ySource = yTarget) ) { if( pX ) pX->Set_Value(x, y, xSource); if( pY ) pY->Set_Value(x, y, ySource); if( bGeogCS_Adjust && xSource < 0.0 ) { xSource += 360.0; } if( pGrid->Get_Value(xSource, ySource, z, m_Interpolation) ) { pTarget->Set_Value(x, y, z); } } } } //----------------------------------------------------- m_Target_Area.Destroy(); return( true ); } //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Parameter_Grid_List *pSources, CSG_Parameter_Grid_List *pTargets, const CSG_Grid_System &Target_System) { if( !m_Projector.Set_Inverse(true) || !pTargets || !pSources || pSources->Get_Count() < 1 ) { return( false ); } //----------------------------------------------------- CSG_Grid *pX, *pY; if( (pX = m_Grid_Target.Get_Grid("OUT_X")) != NULL ) { pX->Assign_NoData(); pX->Set_Name(_TL("X Coordinates")); pX->Get_Projection().Create(m_Projector.Get_Target()); } if( (pY = m_Grid_Target.Get_Grid("OUT_Y")) != NULL ) { pY->Assign_NoData(); pY->Set_Name(_TL("Y Coordinates")); pY->Get_Projection().Create(m_Projector.Get_Target()); } //----------------------------------------------------- bool bGeogCS_Adjust = m_Projector.Get_Source().Get_Type() == SG_PROJ_TYPE_CS_Geographic && pSources->asGrid(0)->Get_System().Get_XMax() > 180.0; Set_Target_Area(pSources->asGrid(0)->Get_System(), Target_System); //----------------------------------------------------- int i, n = pTargets->Get_Count(); for(i=0; iGet_Count(); i++) { CSG_Grid *pSource = pSources->asGrid(i); CSG_Grid *pTarget = SG_Create_Grid(Target_System, m_Interpolation == 0 ? pSource->Get_Type() : SG_DATATYPE_Float); if( pTarget ) { pTarget->Set_NoData_Value_Range (pSource->Get_NoData_Value(), pSource->Get_NoData_hiValue()); pTarget->Set_Scaling (pSource->Get_Scaling(), pSource->Get_Offset()); pTarget->Set_Name (CSG_String::Format(SG_T("%s"), pSource->Get_Name())); pTarget->Set_Unit (pSource->Get_Unit()); pTarget->Assign_NoData(); pTarget->Get_Projection().Create(m_Projector.Get_Target()); pTargets->Add_Item(pTarget); } } //------------------------------------------------- for(int y=0; ySet_Value(x, y, xSource); if( pY ) pY->Set_Value(x, y, ySource); if( bGeogCS_Adjust && xSource < 0.0 ) { xSource += 360.0; } for(i=0; iGet_Count(); i++) { if( pSources->asGrid(i)->Get_Value(xSource, ySource, z, m_Interpolation) ) { pTargets->asGrid(n + i)->Set_Value(x, y, z); } } } } } //----------------------------------------------------- m_Target_Area.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Grid *pGrid, CSG_Shapes *pPoints) { if( !pPoints || !pGrid ) { return( false ); } if( !m_Projector.Set_Source(pGrid->Get_Projection()) ) { return( false ); } int x, y; TSG_Point Point; pPoints->Create(SHAPE_TYPE_Point, _TL("Points")); pPoints->Get_Projection() = m_Projector.Get_Target(); pPoints->Add_Field(pGrid->Get_Name(), pGrid->Get_Type()); for(y=0, Point.y=pGrid->Get_YMin(); yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++, Point.y+=pGrid->Get_Cellsize()) { for(x=0, Point.x=pGrid->Get_XMin(); xGet_NX(); x++, Point.x+=pGrid->Get_Cellsize()) { TSG_Point Point_Transformed = Point; if( !pGrid->is_NoData(x, y) && m_Projector.Get_Projection(Point_Transformed) ) { CSG_Shape *pPoint = pPoints->Add_Shape(); pPoint->Add_Point(Point_Transformed); pPoint->Set_Value(0, pGrid->asDouble(x, y)); } } } return( true ); } //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Parameter_Grid_List *pGrids, CSG_Shapes *pPoints) { if( !pPoints || !pGrids || pGrids->Get_Count() < 1 ) { return( false ); } CSG_Grid *pGrid = pGrids->asGrid(0); if( !m_Projector.Set_Source(pGrid->Get_Projection()) ) { return( false ); } int x, y, i; TSG_Point Point; pPoints->Create(SHAPE_TYPE_Point, _TL("Points")); pPoints->Get_Projection() = m_Projector.Get_Target(); for(i=0; iGet_Count(); i++) { pPoints->Add_Field(pGrids->asGrid(i)->Get_Name(), pGrids->asGrid(i)->Get_Type()); } for(y=0, Point.y=pGrid->Get_YMin(); yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++, Point.y+=pGrid->Get_Cellsize()) { for(x=0, Point.x=pGrid->Get_XMin(); xGet_NX(); x++, Point.x+=pGrid->Get_Cellsize()) { TSG_Point Point_Transformed = Point; if( m_Projector.Get_Projection(Point_Transformed) ) { CSG_Shape *pPoint = pPoints->Add_Shape(); pPoint->Add_Point(Point_Transformed); for(i=0; iGet_Count(); i++) { if( !pGrids->asGrid(i)->is_NoData(x, y) ) { pPoint->Set_Value(i, pGrids->asGrid(i)->asDouble(x, y)); } else { pPoint->Set_NoData(i); } } } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CCRS_Transform_Grid::Get_MinMax(TSG_Rect &r, double x, double y) { if( m_Projector.Get_Projection(x, y) ) { if( r.xMin > r.xMax ) { r.xMin = r.xMax = x; } else if( r.xMin > x ) { r.xMin = x; } else if( r.xMax < x ) { r.xMax = x; } if( r.yMin > r.yMax ) { r.yMin = r.yMax = y; } else if( r.yMin > y ) { r.yMin = y; } else if( r.yMax < y ) { r.yMax = y; } } } //--------------------------------------------------------- bool CCRS_Transform_Grid::Get_Target_System(const CSG_Grid_System &System, bool bEdge) { int x, y, Resolution; TSG_Rect Extent; Extent.xMin = Extent.yMin = 1.0; Extent.xMax = Extent.yMax = 0.0; Get_MinMax(Extent, System.Get_XMin(), System.Get_YMin()); Get_MinMax(Extent, System.Get_XMax(), System.Get_YMin()); Get_MinMax(Extent, System.Get_XMin(), System.Get_YMax()); Get_MinMax(Extent, System.Get_XMax(), System.Get_YMax()); Resolution = 256; switch( 1 ) { case 1: // edges { double d; int yStep = 1 + System.Get_NY() / Resolution; for(y=0, d=System.Get_YMin(); yasBool() == false ) { m_Target_Area.Destroy(); return( true ); } //----------------------------------------------------- CSG_Rect r(Source.Get_Extent()); if( m_Projector.Get_Source().Get_Type() == SG_PROJ_TYPE_CS_Geographic ) { if( r.Get_XMax() > 180.0 ) r.Move(-180.0, 0.0); if( r.Get_YMin() < -90.0 ) r.m_rect.yMin = -90.0; if( r.Get_YMax() < 90.0 ) r.m_rect.yMax = 90.0; } //----------------------------------------------------- CSG_Shapes Area(SHAPE_TYPE_Polygon); CSG_Shape_Polygon *pArea = (CSG_Shape_Polygon *)Area.Add_Shape(); TSG_Point p, q; double dx = Source.Get_XRange() / 100.0; double dy = Source.Get_YRange() / 100.0; m_Projector.Set_Inverse(false); for(p.x=r.Get_XMin(), p.y=r.Get_YMin(); p.yAdd_Point(q); } for(p.x=r.Get_XMin(), p.y=r.Get_YMax(); p.xAdd_Point(q); } for(p.x=r.Get_XMax(), p.y=r.Get_YMax(); p.y>r.Get_YMin(); p.y-=dy) { m_Projector.Get_Projection(q = p); pArea->Add_Point(q); } for(p.x=r.Get_XMax(), p.y=r.Get_YMin(); p.x>r.Get_XMin(); p.x-=dx) { m_Projector.Get_Projection(q = p); pArea->Add_Point(q); } m_Projector.Set_Inverse(true); //----------------------------------------------------- m_Target_Area.Create(Target, SG_DATATYPE_Char); m_Target_Area.Set_NoData_Value(0); for(int y=0; yContains(Target.Get_xGrid_to_World(x), yWorld) ? 1 : 0); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- inline bool CCRS_Transform_Grid::is_In_Target_Area(int x, int y) { return( !m_Target_Area.is_Valid() || m_Target_Area.is_InGrid(x, y) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/PROJ4_Base.cpp0000664000175000017500000006703312565125415024244 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: PROJ4_Base.cpp 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Base.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "PROJ4_Base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PRM_ADD_BOL(key, name, val) pParms->Add_Value(NULL, key, name, _TL(""), PARAMETER_TYPE_Bool , val); #define PRM_ADD_INT(key, name, val) pParms->Add_Value(NULL, key, name, _TL(""), PARAMETER_TYPE_Int , val); #define PRM_ADD_FLT(key, name, val) pParms->Add_Value(NULL, key, name, _TL(""), PARAMETER_TYPE_Double, val); //--------------------------------------------------------- #define STR_ADD_BOL(key, val) (val ? CSG_String::Format(SG_T("+%s "), key) : SG_T("")) #define STR_ADD_INT(key, val) CSG_String::Format(SG_T("+%s=%d "), key, val) #define STR_ADD_FLT(key, val) CSG_String::Format(SG_T("+%s=%f "), key, val) #define STR_ADD_STR(key, val) CSG_String::Format(SG_T("+%s=%s "), key, val) //--------------------------------------------------------- #define BESSEL_A 6377397.16 #define BESSEL_B 6356078.76 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPROJ4_Base::CPROJ4_Base(int Interface, bool bInputList) { CSG_Parameter *pNode; m_Interface = Interface; m_bInputList = bInputList; //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "SOURCE_NODE" , _TL("Source Parameters"), _TL("") ); pNode = Parameters.Add_Node( NULL , "TARGET_NODE" , _TL("Target Parameters"), _TL("") ); pNode = Parameters.Add_Node( NULL , "GENERAL_NODE", _TL("General Settings"), _TL("") ); //----------------------------------------------------- switch( m_Interface ) { //----------------------------------------------------- case PROJ4_INTERFACE_SIMPLE: default: Parameters.Add_String( Parameters("SOURCE_NODE") , "SOURCE_PROJ" , _TL("Source Projection Parameters"), _TL(""), SG_T("+proj=tmerc +datum=potsdam +lon_0=9 +x_0=3500000") ); Parameters.Add_String( Parameters("TARGET_NODE") , "TARGET_PROJ" , _TL("Target Projection Parameters"), _TL(""), SG_T("+proj=tmerc +datum=potsdam +lon_0=12 +x_0=4500000") ); break; //----------------------------------------------------- case PROJ4_INTERFACE_DIALOG: pNode = Parameters.Add_Parameters( Parameters("SOURCE_NODE") , "SOURCE_PROJ" , _TL("Source Projection Parameters"), _TL("") ); _Init_Projection(*pNode->asParameters()); pNode = Parameters.Add_Parameters( Parameters("TARGET_NODE") , "TARGET_PROJ" , _TL("Target Projection Parameters"), _TL("") ); _Init_Projection(*pNode->asParameters()); break; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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() && 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; CSG_String sSrc, sDst; //----------------------------------------------------- if( _Get_Projections(sSrc, sDst) ) { if( (m_pPrjSrc = pj_init_plus(sSrc.b_str())) == NULL ) { Error_Set(CSG_String::Format(SG_T("%s:\n%s"), _TL("projection initialization failure"), SG_STR_MBTOSG(pj_strerrno(pj_errno)))); } if( (m_pPrjDst = pj_init_plus(sDst.b_str())) == NULL ) { Error_Set(CSG_String::Format(SG_T("%s:\n%s"), _TL("projection initialization failure"), SG_STR_MBTOSG(pj_strerrno(pj_errno)))); } Message_Add(CSG_String::Format(SG_T("\n%s: %s\n"), _TL("Source"), sSrc.c_str()), false); Message_Add(CSG_String::Format(SG_T("\n%s: %s\n"), _TL("Target"), sDst.c_str()), false); //------------------------------------------------- if( m_pPrjSrc && m_pPrjDst ) { if( m_pPrjSrc->inv == NULL ) { Error_Set(_TL("Inverse transformation not available for selected projection type.")); } else { m_bInverse = false; bResult = On_Execute_Conversion(); } } //------------------------------------------------- if( m_pPrjSrc ) { pj_free(m_pPrjSrc); } if( m_pPrjDst ) { pj_free(m_pPrjDst); } } //----------------------------------------------------- return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Base::Set_Inverse(bool bOn) { if( m_bInverse == bOn ) { return( true ); } if( m_pPrjDst && m_pPrjDst->inv ) { m_bInverse = bOn; PJ *tmp = m_pPrjSrc; m_pPrjSrc = m_pPrjDst; m_pPrjDst = tmp; return( true ); } Error_Set(_TL("Inverse transformation not available for selected projection type.")); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CPROJ4_Base::Get_Proj_Name(bool bDestination) { PJ *pProjection = bDestination ? m_pPrjDst : m_pPrjSrc; if( pProjection ) { return( CSG_String(pProjection->descr).BeforeFirst('\n') ); } return( _TL("") ); } //--------------------------------------------------------- bool CPROJ4_Base::Get_Converted(TSG_Point &Point) { return( Get_Converted(Point.x, Point.y) ); } bool CPROJ4_Base::Get_Converted(double &x, double &y) { if( m_pPrjSrc && m_pPrjDst ) { double z = 0.0; if( pj_is_latlong(m_pPrjSrc) ) { x *= DEG_TO_RAD; y *= DEG_TO_RAD; } if( pj_transform(m_pPrjSrc, m_pPrjDst, 1, 0, &x, &y, &z) == 0 ) { if( pj_is_latlong(m_pPrjDst) ) { x *= RAD_TO_DEG; y *= RAD_TO_DEG; } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Base::_Get_Projections(CSG_String &sPrjSrc, CSG_String &sPrjDst) { switch( m_Interface ) { //----------------------------------------------------- case PROJ4_INTERFACE_SIMPLE: default: sPrjSrc = Parameters("SOURCE_PROJ")->asString(); sPrjDst = Parameters("TARGET_PROJ")->asString(); return( true ); //----------------------------------------------------- case PROJ4_INTERFACE_DIALOG: return( _Get_Projection(sPrjSrc, *Parameters("SOURCE_PROJ")->asParameters()), _Get_Projection(sPrjDst, *Parameters("TARGET_PROJ")->asParameters()) ); } } //--------------------------------------------------------- bool CPROJ4_Base::_Get_Projection(CSG_String &sPrj, CSG_Parameters &P) { //----------------------------------------------------- sPrj .Clear(); sPrj += STR_ADD_STR(SG_T("proj") , SG_STR_MBTOSG(pj_list[P("PROJ_TYPE")->asInt()].id)); 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()); 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 ) { sPrj += STR_ADD_FLT(SG_T("k_0") , P("K_0" )->asDouble()); } sPrj += STR_ADD_STR(SG_T("units") , SG_STR_MBTOSG(pj_units[P("UNIT")->asInt()].id)); //----------------------------------------------------- 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; //----------------------------------------------------- case 1: // user defined datum switch( P("ELLIPSOID")->asInt() ) { case 0: // Predefined Ellipsoid sPrj += STR_ADD_STR(SG_T("ellps") , SG_STR_MBTOSG(pj_ellps[P("ELLPS_PREDEF")->asInt()].id)); break; case 1: // Semiminor axis sPrj += STR_ADD_FLT(SG_T("a") , P("ELLPS_A" )->asDouble()); sPrj += STR_ADD_FLT(SG_T("b") , P("ELLPS_B" )->asDouble()); break; case 2: // Flattening sPrj += STR_ADD_FLT(SG_T("a") , P("ELLPS_A" )->asDouble()); sPrj += STR_ADD_FLT(SG_T("f") , P("ELLPS_F" )->asDouble()); break; case 3: // Reciprocal Flattening sPrj += STR_ADD_FLT(SG_T("a") , P("ELLPS_A" )->asDouble()); sPrj += STR_ADD_FLT(SG_T("rf") , P("ELLPS_RF")->asDouble()); break; case 4: // Eccentricity sPrj += STR_ADD_FLT(SG_T("a") , P("ELLPS_A" )->asDouble()); sPrj += STR_ADD_FLT(SG_T("e") , P("ELLPS_E" )->asDouble()); break; case 5: // Eccentricity Squared sPrj += STR_ADD_FLT(SG_T("a") , P("ELLPS_A" )->asDouble()); sPrj += STR_ADD_FLT(SG_T("es") , P("ELLPS_ES")->asDouble()); break; } switch( P("DATUM_SHIFT")->asInt() ) { case 1: // 3 parameters sPrj += CSG_String::Format(SG_T("+towgs84=%f,%f,%f "), P("DS_DX")->asDouble(), P("DS_DY")->asDouble(), P("DS_DZ")->asDouble() ); break; case 2: // 7 parameters sPrj += CSG_String::Format(SG_T("+towgs84=%f,%f,%f,%f,%f,%f,%f "), P("DS_DX")->asDouble(), P("DS_DY")->asDouble(), P("DS_DZ")->asDouble(), P("DS_RX")->asDouble(), P("DS_RY")->asDouble(), P("DS_RZ")->asDouble(), P("DS_SC")->asDouble() ); break; } break; } // datum shift grid... if( SG_File_Exists(P("DATUM_GRID")->asString()) ) { sPrj += STR_ADD_STR(SG_T("nadgrids"), P("DATUM_GRID")->asString()); } //----------------------------------------------------- CSG_Parameters *pParms = Get_Parameters(SG_STR_MBTOSG(pj_list[P("PROJ_TYPE")->asInt()].id)); if( pParms == NULL || pParms->Get_Count() <= 0 ) { return( true ); } if( Dlg_Parameters(SG_STR_MBTOSG(pj_list[P("PROJ_TYPE")->asInt()].id)) ) { for(int i=0; iGet_Count(); i++) { CSG_Parameter *p = pParms->Get_Parameter(i); switch( p->Get_Type() ) { case PARAMETER_TYPE_Bool: sPrj += STR_ADD_BOL(p->Get_Identifier(), p->asBool()); break; case PARAMETER_TYPE_Int: sPrj += STR_ADD_INT(p->Get_Identifier(), p->asInt()); break; case PARAMETER_TYPE_Double: sPrj += STR_ADD_FLT(p->Get_Identifier(), p->asDouble()); break; } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // Initializations // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Base::_Init_Projection(CSG_Parameters &P) { CSG_String sList, sName, sDesc, sArgs; CSG_Parameter *pNode_0, *pNode_1, *pNode_2, *pNode_3; pNode_0 = NULL; //----------------------------------------------------- // Projections... sDesc = _TL("Available Projections:"); sList.Clear(); for(struct PJ_LIST *pProjection=pj_list; pProjection->id; ++pProjection) { sArgs = *pProjection->descr; sName = sArgs.BeforeFirst('\n'); sArgs = sArgs.AfterFirst ('\n').AfterFirst('\n').AfterFirst('\t'); sList += CSG_String::Format(SG_T("%s|"), sName.c_str()); sDesc += CSG_String::Format(SG_T("\n[%s] %s (%s)"), SG_STR_MBTOSG(pProjection->id), sName.c_str(), sArgs.c_str()); _Init_Projection(pProjection->id, sName, sArgs); } if( sList.Length() > 0 ) { P.Add_Choice(NULL, "PROJ_TYPE", _TL("Projection Type"), sDesc, sList); } //----------------------------------------------------- // Datums... pNode_1 = P.Add_Choice( pNode_0, "DATUM_DEF" , _TL("Datum Definition"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Predefined Datum"), _TL("User Defined Datum") ) ); //----------------------------------------------------- // Predefined datum... sList.Clear(); for(struct PJ_DATUMS *pDatum=pj_datums; pDatum->id; ++pDatum) { sList += CSG_String::Format(SG_T("[%s]"), SG_STR_MBTOSG(pDatum->id)); if( SG_STR_MBTOSG(pDatum->comments) != NULL && SG_STR_MBTOSG(*pDatum->comments) != NULL ) { sList += CSG_String::Format(SG_T(" %s"), SG_STR_MBTOSG(pDatum->comments)); } sList += '|'; } if( sList.Length() > 0 ) { pNode_2 = P.Add_Choice(pNode_1, "DATUM", _TL("Predefined Datum"), _TL(""), sList); } //----------------------------------------------------- // 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( pNode_1, "NODE_USER_DATUM" , _TL("User Defined Datum"), _TL("") ); //----------------------------------------------------- pNode_3 = P.Add_Choice( pNode_2, "ELLIPSOID" , _TL("Ellipsoid Definition"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("Predefined Standard Ellipsoids"), _TL("Semimajor Axis and Semiminor Axis"), _TL("Semimajor Axis and Flattening"), _TL("Semimajor Axis and Reciprocal Flattening"), _TL("Semimajor Axis and Eccentricity"), _TL("Semimajor Axis and Eccentricity Squared") ) ); //----------------------------------------------------- sList.Clear(); for(struct PJ_ELLPS *pEllipse=pj_ellps; pEllipse->id; ++pEllipse) { sList += CSG_String::Format(SG_T("[%s] %s (%s, %s)|"), SG_STR_MBTOSG(pEllipse->id), SG_STR_MBTOSG(pEllipse->name), SG_STR_MBTOSG(pEllipse->major), SG_STR_MBTOSG(pEllipse->ell)); } if( sList.Length() > 0 ) { P.Add_Choice(pNode_3, "ELLPS_PREDEF", _TL("Predefined Standard Ellipsoids"), _TL(""), sList); } //----------------------------------------------------- P.Add_Value( pNode_3, "ELLPS_A" , _TL("Semimajor Axis (a)"), _TL("Semimajor axis or equatorial radius."), PARAMETER_TYPE_Double , BESSEL_A ); P.Add_Value( pNode_3, "ELLPS_B" , _TL("Semiminor Axis (b)"), _TL("Semiminor axis or polar radius."), PARAMETER_TYPE_Double , BESSEL_B ); P.Add_Value( pNode_3, "ELLPS_F" , _TL("Flattening (f)"), _TL(""), PARAMETER_TYPE_Double , (BESSEL_A - BESSEL_B) / BESSEL_A ); P.Add_Value( pNode_3, "ELLPS_RF" , _TL("Reciprocal Flattening (rf)"), _TL(""), PARAMETER_TYPE_Double , BESSEL_A / (BESSEL_A - BESSEL_B) ); P.Add_Value( pNode_3, "ELLPS_E" , _TL("Eccentricity (e)"), _TL(""), PARAMETER_TYPE_Double , sqrt(BESSEL_A*BESSEL_A + BESSEL_B*BESSEL_B) ); P.Add_Value( pNode_3, "ELLPS_ES" , _TL("Squared Eccentricity (es)"), _TL(""), PARAMETER_TYPE_Double , BESSEL_A*BESSEL_A + BESSEL_B*BESSEL_B ); //----------------------------------------------------- pNode_3 = P.Add_Choice( pNode_2, "DATUM_SHIFT" , _TL("Datum Shift"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("none"), _TL("3 parameters (translation only)"), _TL("7 parameters"), _TL("Datum Shift Grid") ) ); P.Add_Value( pNode_3, "DS_DX" , _TL("Translation X"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_DY" , _TL("Translation Y"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_DZ" , _TL("Translation Z"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_RX" , _TL("Rotation X"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_RY" , _TL("Rotation Y"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_RZ" , _TL("Rotation Z"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_SC" , _TL("Scaling"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); //----------------------------------------------------- // General Settings... pNode_1 = P.Add_Node( pNode_0, "NODE_GENERAL" , _TL("General Settings"), _TL("") ); //----------------------------------------------------- P.Add_Value( pNode_1, "LON_0" , _TL("Central Meridian"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); P.Add_Value( pNode_1, "LAT_0" , _TL("Central Parallel"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); P.Add_Value( pNode_1, "X_0" , _TL("False Easting"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); P.Add_Value( pNode_1, "Y_0" , _TL("False Northing"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); P.Add_Value( pNode_1, "K_0" , _TL("Scale Factor"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); //----------------------------------------------------- sList.Clear(); for(struct PJ_UNITS *pUnit=pj_units; pUnit->id; ++pUnit) { sList += CSG_String::Format(SG_T("%s (%s)|"), SG_STR_MBTOSG(pUnit->name), SG_STR_MBTOSG(pUnit->to_meter)); } if( sList.Length() > 0 ) { P.Add_Choice(pNode_1, "UNIT", _TL("Unit"), _TL(""), sList, 1); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Base::_Init_Projection(const CSG_String &sID, const CSG_String &sName, const CSG_String &sArgs) { if( sArgs.Length() == 0 ) { return( false ); } CSG_Parameters *pParms = Add_Parameters(sID, sName, sArgs); //----------------------------------------------------- // Cylindrical Projections... if( !sID.CmpNoCase(SG_T("cea")) // Equal Area Cylindrical || !sID.CmpNoCase(SG_T("eqc")) // Equidistant Cylindrical (Plate Caree) || !sID.CmpNoCase(SG_T("merc")) ) // Mercator { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 0.0); } if( !sID.CmpNoCase(SG_T("utm")) ) // Universal Transverse Mercator (UTM) { PRM_ADD_INT("zone" , _TL("Zone") , 32); PRM_ADD_BOL("south" , _TL("South") , false); } if( !sID.CmpNoCase(SG_T("omerc")) ) // Oblique Mercator { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1" ) ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 50.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2" ) , 20.0); } //----------------------------------------------------- // Pseudocylindrical Projections... if( !sID.CmpNoCase(SG_T("gn_sinu")) ) // General Sinusoidal Series { PRM_ADD_FLT("m" , SG_T("m") , 0.5); PRM_ADD_FLT("n" , SG_T("n") , 1.0 + M_PI_045); } if( !sID.CmpNoCase(SG_T("loxim")) ) // Loximuthal { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } if( !sID.CmpNoCase(SG_T("urmfps")) ) // Urmaev Flat-Polar Sinusoidal { PRM_ADD_FLT("n" , SG_T("n") , 1.0); } if( !sID.CmpNoCase(SG_T("urm5")) ) // Urmaev V { PRM_ADD_FLT("n" , SG_T("n") , 1.0); PRM_ADD_FLT("q" , SG_T("q") , 1.0); PRM_ADD_FLT("alphi" , SG_T("alphi") , 45.0); } if( !sID.CmpNoCase(SG_T("wink1")) // Winkel I || !sID.CmpNoCase(SG_T("wag3")) ) // Wagner III { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("wink2")) ) // Winkel II { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } //----------------------------------------------------- // Conic Projections... if( !sID.CmpNoCase(SG_T("aea")) // Albers Equal Area || !sID.CmpNoCase(SG_T("eqdc")) // Equidistant Conic || !sID.CmpNoCase(SG_T("euler")) // Euler || !sID.CmpNoCase(SG_T("imw_p")) // International Map of the World Polyconic || !sID.CmpNoCase(SG_T("murd1")) // Murdoch I || !sID.CmpNoCase(SG_T("murd2")) // Murdoch II || !sID.CmpNoCase(SG_T("murd3")) // Murdoch III || !sID.CmpNoCase(SG_T("pconic")) // Perspective Conic || !sID.CmpNoCase(SG_T("tissot")) // Tissot || !sID.CmpNoCase(SG_T("vitk1")) ) // Vitkovsky I { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); } if( !sID.CmpNoCase(SG_T("lcc")) ) // Lambert Conformal Conic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); } if( !sID.CmpNoCase(SG_T("leac")) ) // Lambert Equal Area Conic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 45.0); PRM_ADD_BOL("south" , _TL("South") , false); } if( !sID.CmpNoCase(SG_T("rpoly")) ) // Rectangular Polyconic { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("mpoly")) ) // Modified Polyconic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); PRM_ADD_BOL("lotsa" , _TL("Lotsa") , true); } if( !sID.CmpNoCase(SG_T("bonne")) ) // Bonne { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 45.0); } //----------------------------------------------------- // Azimuthal Projections... if( !sID.CmpNoCase(SG_T("stere")) ) // Stereographic { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("ups")) ) // Universal Polar Stereographic { PRM_ADD_BOL("south" , _TL("South") , true); } if( !sID.CmpNoCase(SG_T("airy")) ) // Airy { PRM_ADD_FLT("lat_b" , _TL("Latitude B") , 45.0); PRM_ADD_BOL("no_cut" , _TL("No Cut") , true); } if( !sID.CmpNoCase(SG_T("nsper")) ) // Near-sided perspective { PRM_ADD_FLT("h" , _TL("Height of view point") , 1.0); } if( !sID.CmpNoCase(SG_T("aeqd")) ) // Azimuthal Equidistant { PRM_ADD_BOL("guam" , _TL("guam") , true); } if( !sID.CmpNoCase(SG_T("hammer")) ) // Hammer & Eckert-Greifendorff { PRM_ADD_FLT("W" , _TL("W") , 0.5); PRM_ADD_FLT("M" , _TL("M") , 1.0); } if( !sID.CmpNoCase(SG_T("wintri")) ) // Winkel Tripel { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } //----------------------------------------------------- // Miscellaneous Projections... if( !sID.CmpNoCase(SG_T("ocea")) // Oblique Cylindrical Equal Area || !sID.CmpNoCase(SG_T("tpeqd")) ) // Two Point Equidistant { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1") ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 50.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2" ) , 20.0); } if( !sID.CmpNoCase(SG_T("lsat")) ) // Space oblique for LANDSAT { PRM_ADD_INT("lsat" , _TL("Landsat") , 1.0); PRM_ADD_INT("path" , _TL("Path") , 1.0); } if( !sID.CmpNoCase(SG_T("labrd")) ) // Laborde { PRM_ADD_FLT("azi" , _TL("Azimuth" ) , 19.0); } if( !sID.CmpNoCase(SG_T("lagrng")) ) // Lagrange { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 0.0); PRM_ADD_FLT("W" , _TL("W") , 2.0); } if( !sID.CmpNoCase(SG_T("chamb")) ) // Chamberlin Trimetric { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 30.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1" ) ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 40.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2") , 00.0); PRM_ADD_FLT("lat_3" , _TL("Latitude 3") , 50.0); PRM_ADD_FLT("lon_3" , _TL("Longitude 3" ) , 20.0); } if( !sID.CmpNoCase(SG_T("oea")) ) // Oblated Equal Area { PRM_ADD_FLT("m" , _TL("m") , 1.0); PRM_ADD_FLT("n" , _TL("n") , 1.0); PRM_ADD_FLT("theta" , _TL("theta") , 45.0); } if( !sID.CmpNoCase(SG_T("tpers")) ) // Tilted perspective { PRM_ADD_FLT("tilt" , _TL("Tilt") , 45.0); PRM_ADD_FLT("azi" , _TL("Azimuth") , 45.0); PRM_ADD_FLT("h" , _TL("h") , 1000.0); } if( !sID.CmpNoCase(SG_T("ob_tran")) ) // General Oblique Transformation { PRM_ADD_FLT("o_lat_p" , _TL("Latitude Pole") , 40.0); PRM_ADD_FLT("o_lon_p" , _TL("Longitude Pole") , 40.0); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/crs_assign.cpp0000664000175000017500000001436612565125415024610 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_assign.cpp 2322 2014-11-03 21:29:57Z johanvdw $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_assign.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_assign.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Assign::CCRS_Assign(void) { //----------------------------------------------------- Set_Name (_TL("Set Coordinate Reference System")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "The module allows one to define the Coordinate Reference System (CRS) " "of the supplied data sets. The module applies no transformation to " "the data sets, it just updates their CRS metadata.\n" "A complete and correct description of the CRS of a dataset is necessary " "in order to be able to actually apply a projection with one of the " "'Coordinate Transformation' modules later.\n\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT_OPTIONAL ); // Parameters.Add_TIN_List( // NULL , "TINS" , _TL("TINs"), // _TL(""), // PARAMETER_INPUT_OPTIONAL // ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Assign::On_Execute(void) { int nTotal = Parameters("GRIDS" )->asList()->Get_Count() + Parameters("SHAPES")->asList()->Get_Count(); // + Parameters("TINS" )->asList()->Get_Count(); if( nTotal <= 0 ) { Message_Dlg(_TL("nothing to do: no data in selection")); return( false ); } //----------------------------------------------------- CSG_Projection Projection; if( !Get_Projection(Projection) ) { return( false ); } //----------------------------------------------------- int nProjected = 0; nProjected += Set_Projections(Projection, Parameters("GRIDS" )->asList()); nProjected += Set_Projections(Projection, Parameters("SHAPES")->asList()); // nProjected += Set_Projections(Projection, Parameters("TINS") ->asList()); //----------------------------------------------------- return( nProjected > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CCRS_Assign::Set_Projections(const CSG_Projection &Projection, CSG_Parameter_List *pList) { int nProjected = 0; for(int i=0; iGet_Count(); i++) { if( pList->asDataObject(i)->Get_Projection().Create(Projection) ) { pList->asDataObject(i)->Set_Modified(); DataObject_Update(pList->asDataObject(i)); nProjected++; } } return( nProjected ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/crs_indicatrix.cpp0000664000175000017500000002207012565125415025451 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_indicatrix.cpp 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_indicatrix.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_indicatrix.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Indicatrix::CCRS_Indicatrix(void) { //----------------------------------------------------- Set_Name (_TL("Tissot's Indicatrix")); Set_Author ("O. Conrad (c) 2014"); Set_Description (_TW( "Creates a shapes layer with Tissot's indicatrices for chosen projection." )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "TARGET" , _TL("Indicatrix"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "NY" , _TL("Number in Latitudinal Direction"), _TL(""), PARAMETER_TYPE_Int, 5, 1, true ); Parameters.Add_Value( NULL , "NX" , _TL("Number in Meridional Direction"), _TL(""), PARAMETER_TYPE_Int, 11, 1, true ); Parameters.Add_Value( NULL , "SCALE" , _TL("Size"), _TL(""), PARAMETER_TYPE_Double, 25.0, 1.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { FIELD_LON = 0, FIELD_LAT, FIELD_h, FIELD_k, FIELD_a, FIELD_b, FIELD_w, FIELD_PHI }; //--------------------------------------------------------- bool CCRS_Indicatrix::On_Execute_Transformation(void) { //----------------------------------------------------- double yStep = 180.0 / Parameters("NY")->asDouble(); double xStep = 360.0 / Parameters("NX")->asDouble(); m_Size = 1.0; m_Scale = (40000000.0 / 360.0) * (yStep < xStep ? yStep : xStep) * 0.005 * Parameters("SCALE")->asDouble() / m_Size; //----------------------------------------------------- m_Circle.Add(0.0, 0.0); m_Circle.Add(sin(M_PI_090), cos(M_PI_090)); m_Circle.Add(0.0, 0.0); for(double a=0.0; aasShapes(); pTarget->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), _TL("Indicatrix"), m_Projector.Get_Target().Get_Name().c_str())); pTarget->Get_Projection() = m_Projector.Get_Target(); pTarget->Add_Field("LON", SG_DATATYPE_Double); pTarget->Add_Field("LAT", SG_DATATYPE_Double); pTarget->Add_Field("h" , SG_DATATYPE_Double); pTarget->Add_Field("k" , SG_DATATYPE_Double); pTarget->Add_Field("a" , SG_DATATYPE_Double); pTarget->Add_Field("b" , SG_DATATYPE_Double); pTarget->Add_Field("w" , SG_DATATYPE_Double); pTarget->Add_Field("PHI", SG_DATATYPE_Double); //----------------------------------------------------- int nDropped = 0; for(double lat=-90.0+yStep/2.0; lat<90.0; lat+=yStep) { for(double lon=-180.0+xStep/2.0; lon<180.0; lon+=xStep) { CSG_Shape *pIndicatrix = pTarget->Add_Shape(); if( !Get_Indicatrix(lon, lat, pIndicatrix) ) { nDropped++; pTarget->Del_Shape(pIndicatrix); } } } //----------------------------------------------------- if( nDropped > 0 ) { Message_Add(CSG_String::Format(SG_T("%s: %d %s"), pTarget->Get_Name(), nDropped, _TL("shapes have been dropped"))); } m_Circle.Clear(); return( pTarget->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Indicatrix::Get_Indicatrix(double lon, double lat, CSG_Shape *pIndicatrix) { m_Projector.Set_Source( CSG_Projection(CSG_String::Format(SG_T("+proj=ortho +lon_0=%f +lat_0=%f +datum=WGS84"), lon, lat), SG_PROJ_FMT_Proj4) ); TSG_Point Center, Point; Center.x = 0.0; Center.y = 0.0; if( !m_Projector.Get_Projection(Center) ) { return( false ); } //----------------------------------------------------- Point.x = m_Size; Point.y = 0.0; if( !m_Projector.Get_Projection(Point) ) { return( false ); } double h = SG_Get_Distance(Center, Point) / m_Size; //----------------------------------------------------- Point.x = 0.0; Point.y = m_Size; if( !m_Projector.Get_Projection(Point) ) { return( false ); } double k = SG_Get_Distance(Center, Point) / m_Size; //----------------------------------------------------- double a = h > k ? h : k; // major semi-axis double b = h > k ? k : h; // minor semi-axis for(int iPoint=0; iPoint= 3 ) { double d = SG_Get_Distance(Center, Point) / m_Size; if( a < d ) { a = d; } else if( b > d ) { b = d; } } Point.x = Center.x + m_Scale * (Point.x - Center.x); Point.y = Center.y + m_Scale * (Point.y - Center.y); pIndicatrix->Add_Point(Point); } //----------------------------------------------------- double w = 2.0 * M_RAD_TO_DEG * asin((a - b) / (a + b)); double phi = a * b; pIndicatrix->Set_Value(FIELD_LON, SG_Get_Rounded(lon, 2)); pIndicatrix->Set_Value(FIELD_LAT, SG_Get_Rounded(lat, 2)); pIndicatrix->Set_Value(FIELD_h , SG_Get_Rounded(h , 2)); pIndicatrix->Set_Value(FIELD_k , SG_Get_Rounded(k , 2)); pIndicatrix->Set_Value(FIELD_a , SG_Get_Rounded(a , 2)); pIndicatrix->Set_Value(FIELD_b , SG_Get_Rounded(b , 2)); pIndicatrix->Set_Value(FIELD_w , SG_Get_Rounded(w , 1)); pIndicatrix->Set_Value(FIELD_PHI, SG_Get_Rounded(phi, 1)); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/crs_transform_shapes.cpp0000664000175000017500000001677212565125415026705 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_transform_shapes.cpp 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_shapes.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_transform_shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Transform_Shapes::CCRS_Transform_Shapes(bool bList) { m_bList = bList; //----------------------------------------------------- Set_Name (m_bList ? _TL("Coordinate Transformation (Shapes List)") : _TL("Coordinate Transformation (Shapes)") ); Set_Author (SG_T("O. Conrad (c) 2010")); Set_Description (_TW( "Coordinate transformation for shapes.\n" )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- if( m_bList ) { Parameters.Add_Shapes_List( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes_List( NULL , "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } //----------------------------------------------------- else { Parameters.Add_Shapes( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Shapes::On_Execute_Transformation(void) { if( m_bList ) { CSG_Parameter_Shapes_List *pSources, *pTargets; pSources = Parameters("SOURCE")->asShapesList(); pTargets = Parameters("TARGET")->asShapesList(); pTargets->Del_Items(); for(int i=0; iGet_Count() && Process_Get_Okay(false); i++) { CSG_Shapes *pSource = pSources->asShapes(i); CSG_Shapes *pTarget = SG_Create_Shapes(pSource); if( Transform(pSource, pTarget) ) { pTargets->Add_Item(pTarget); } else { delete(pTarget); } } return( pTargets->Get_Count() > 0 ); } else { CSG_Shapes *pSource = Parameters("SOURCE")->asShapes(); CSG_Shapes *pTarget = Parameters("TARGET")->asShapes(); if( pSource == pTarget ) { pTarget = SG_Create_Shapes(pSource); if( Transform(pSource, pTarget) ) { pSource->Assign(pTarget); return( true ); } else { delete(pTarget); return( false ); } } else { pTarget->Create(pSource->Get_Type(), pSource->Get_Name(), pSource, pSource->Get_Vertex_Type()); } return( Transform(pSource, pTarget) ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Shapes::Transform(CSG_Shapes *pSource, CSG_Shapes *pTarget) { if( !pTarget || !pSource || !pSource->is_Valid() ) { return( false ); } if( !m_Projector.Set_Source(pSource->Get_Projection()) ) { return( false ); } int nDropped = 0; Process_Set_Text(CSG_String::Format(SG_T("%s: %s"), _TL("Processing"), pSource->Get_Name())); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pSource->Get_Count()); iShape++) { CSG_Shape *pShape_Source = pSource->Get_Shape(iShape); CSG_Shape *pShape_Target = pTarget->Add_Shape(pShape_Source, SHAPE_COPY_ATTR); for(int iPart=0; iPartGet_Part_Count() && pShape_Target; iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart) && pShape_Target; iPoint++) { TSG_Point Point = pShape_Source->Get_Point(iPoint, iPart); if( m_Projector.Get_Projection(Point.x, Point.y) ) { pShape_Target->Add_Point(Point.x, Point.y, iPart); } else { nDropped++; pTarget->Del_Shape(pShape_Target); pShape_Target = NULL; } } } } if( nDropped > 0 ) { Message_Add(CSG_String::Format(SG_T("%s: %d %s"), pTarget->Get_Name(), nDropped, _TL("shapes have been dropped"))); } pTarget->Get_Projection() = m_Projector.Get_Target(); return( pTarget->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/crs_transform_shapes.h0000664000175000017500000001025212565125415026335 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_transform_shapes.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_shapes.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_transform_shapes_H #define HEADER_INCLUDED__crs_transform_shapes_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Transform_Shapes : public CCRS_Transform { public: CCRS_Transform_Shapes(bool bList); protected: virtual bool On_Execute_Transformation (void); bool Transform (CSG_Shapes *pSource, CSG_Shapes *pTarget); private: bool m_bList; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_transform_shapes_H saga-2.2.3/src/modules/projection/pj_proj4/crs_distance.cpp0000664000175000017500000004067512565125415025120 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_distance.cpp 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_distance.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_distance.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Distance_Calculator::CCRS_Distance_Calculator(void) {} //--------------------------------------------------------- CCRS_Distance_Calculator::CCRS_Distance_Calculator(const CSG_Projection &Projection, double Epsilon) { Create(Projection, Epsilon); } //--------------------------------------------------------- CCRS_Distance_Calculator::~CCRS_Distance_Calculator(void) {} //--------------------------------------------------------- bool CCRS_Distance_Calculator::Create(const CSG_Projection &Projection, double Epsilon) { if( !m_ProjToGCS.Set_Source(Projection) || !m_ProjToGCS.Set_Target(CSG_Projection("+proj=longlat +datum=WGS84", SG_PROJ_FMT_Proj4)) || !m_Projector.Set_Target(Projection) ) { return( false ); } m_Epsilon = Epsilon; return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CCRS_Distance_Calculator::Get_Orthodrome(const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine) { static const TSG_Point P0 = { 0.0, 0.0 }; TSG_Point P = A; if( m_ProjToGCS.Get_Projection(P) ) { m_Projector.Set_Source(CSG_Projection( CSG_String::Format("+proj=aeqd +R=6371000 +lon_0=%f +lat_0=%f", P.x, P.y), SG_PROJ_FMT_Proj4) ); m_Projector.Set_Inverse(); if( m_Projector.Get_Projection(P = B) ) { m_Projector.Set_Inverse(false); Add_Segment(P0, P, pLine); return( SG_Get_Distance(P0, P) ); } } return( Get_Distance(A, B) ); } //--------------------------------------------------------- double CCRS_Distance_Calculator::Get_Loxodrome(const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine) { TSG_Point AA, BB; m_Projector.Set_Source(CSG_Projection("+proj=merc +datum=WGS84", SG_PROJ_FMT_Proj4)); m_Projector.Set_Inverse(); if( m_Projector.Get_Projection(AA = A) && m_Projector.Get_Projection(BB = B) ) { double Length = 0.0; m_Projector.Set_Inverse(false); Add_Segment(AA, BB, pLine, &Length); return( Length ); } return( Get_Distance(A, B) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CCRS_Distance_Calculator::Get_Distance(TSG_Point A, TSG_Point B) { if( m_ProjToGCS.Get_Projection(A) && m_ProjToGCS.Get_Projection(B) ) { return( SG_Get_Distance_Polar(A, B) ); } return( 0.0 ); } //--------------------------------------------------------- void CCRS_Distance_Calculator::Add_Segment(const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine, double *Length) { if( SG_Get_Distance(A, B) >= m_Epsilon ) { TSG_Point C, CC; C.x = CC.x = A.x + 0.5 * (B.x - A.x); C.y = CC.y = A.y + 0.5 * (B.y - A.y); if( m_Projector.Get_Projection(CC) ) { Add_Segment(A, C, pLine); pLine->Add_Point(CC); Add_Segment(C, B, pLine); } } else if( Length != NULL ) { TSG_Point AA, BB; if( m_Projector.Get_Projection(AA = A) && m_Projector.Get_Projection(BB = B) ) { *Length += Get_Distance(AA, BB); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Distance_Lines::CCRS_Distance_Lines(void) { //----------------------------------------------------- Set_Name (_TL("Geographic Distances")); Set_Author ("O. Conrad (c) 2015"); Set_Description (_TW( "Calculates for all segments of the input lines the planar, great elliptic, " "and loxodrome distance and re-projects the latter two to the projection " "of the input lines. " )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "PLANAR" , _TL("Segments"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "ORTHODROME" , _TL("Great Elliptic"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "LOXODROME" , _TL("Loxodrome"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Epsilon"), _TL("defines the maximum resolution [km] for the re-projected distance segments"), PARAMETER_TYPE_Double, 100.0, 1.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Distance_Lines::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPlanars = Parameters("PLANAR" )->asShapes(); CSG_Shapes *pOrthodromes = Parameters("ORTHODROME")->asShapes(); CSG_Shapes *pLoxodromes = Parameters("LOXODROME" )->asShapes(); //----------------------------------------------------- CCRS_Distance_Calculator Distance; if( !Distance.Create(pPlanars->Get_Projection(), Parameters("EPSILON")->asDouble() * 1000.0) ) { Error_Set(_TL("projection initialization failed")); return( false ); } //----------------------------------------------------- pOrthodromes->Create(pPlanars->Get_Type(), CSG_String::Format("%s [%s]", pPlanars->Get_Name(), _TL("Orthodromes")), pPlanars); pOrthodromes->Add_Field("LENGTH_PLAN", SG_DATATYPE_Double); pOrthodromes->Add_Field("LENGTH" , SG_DATATYPE_Double); pLoxodromes ->Create(pPlanars->Get_Type(), CSG_String::Format("%s [%s]", pPlanars->Get_Name(), _TL("Loxodromes" )), pPlanars); pLoxodromes ->Add_Field("LENGTH_PLAN", SG_DATATYPE_Double); pLoxodromes ->Add_Field("LENGTH" , SG_DATATYPE_Double); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pPlanars->Get_Count()); iShape++) { CSG_Shape_Line *pProj = (CSG_Shape_Line *)pPlanars->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pProj->Get_Point_Count(iPart) > 1 ) { TSG_Point A, B = pProj->Get_Point(0, iPart); CSG_Shape_Line *pOrthodrome = (CSG_Shape_Line *)pOrthodromes->Add_Shape(pProj, SHAPE_COPY_ATTR); CSG_Shape_Line *pLoxodrome = (CSG_Shape_Line *)pLoxodromes->Add_Shape(pProj, SHAPE_COPY_ATTR); pOrthodrome->Set_Value(pPlanars->Get_Field_Count() + 0, pProj->Get_Length(iPart)); pLoxodrome ->Set_Value(pPlanars->Get_Field_Count() + 0, pProj->Get_Length(iPart)); pOrthodrome->Add_Point(B); pLoxodrome ->Add_Point(B); double dOrthodrome = 0.0; double dLoxodrome = 0.0; for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { A = B; B = pProj->Get_Point(iPoint, iPart); dOrthodrome += Distance.Get_Orthodrome(A, B, pOrthodrome); dLoxodrome += Distance.Get_Loxodrome (A, B, pLoxodrome ); pOrthodrome->Add_Point(B); pLoxodrome ->Add_Point(B); } pOrthodrome->Set_Value(pPlanars->Get_Field_Count() + 1, dOrthodrome); pLoxodrome ->Set_Value(pPlanars->Get_Field_Count() + 1, dLoxodrome ); } } } //----------------------------------------------------- return( pOrthodromes->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Distance_Points::CCRS_Distance_Points(void) { Set_Name (_TL("Geographic Distances (Pair of Coordinates)")); Set_Author ("O. Conrad (c) 2015"); Set_Description (_TW( "Calculates for all segments of the input lines the planar, great elliptic, " "and loxodrome distance and re-projects the latter two to the projection " "of the input lines. " )); Parameters.Add_Shapes( NULL , "DISTANCES" , _TL("Geographic Distances"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); CSG_Parameter *pNode; pNode = Parameters.Add_Node(NULL, "NODE_A", _TL("From"), _TL("")); Parameters.Add_Value(pNode, "COORD_X1", _TL("X"), _TL(""), PARAMETER_TYPE_Double, 10.0); Parameters.Add_Value(pNode, "COORD_Y1", _TL("Y"), _TL(""), PARAMETER_TYPE_Double, 53.5); pNode = Parameters.Add_Node(NULL, "NODE_B", _TL("To" ), _TL("")); Parameters.Add_Value(pNode, "COORD_X2", _TL("X"), _TL(""), PARAMETER_TYPE_Double, 116.5); Parameters.Add_Value(pNode, "COORD_Y2", _TL("Y"), _TL(""), PARAMETER_TYPE_Double, 6.4); Parameters.Add_Value( NULL , "EPSILON" , _TL("Epsilon"), _TL("defines the maximum resolution [km] for the re-projected distance segments"), PARAMETER_TYPE_Double, 100.0, 1.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Distance_Points::On_Execute(void) { //----------------------------------------------------- CSG_Projection Projection; if( !Get_Projection(Projection) ) { return( false ); } //----------------------------------------------------- CCRS_Distance_Calculator Distance; if( !Distance.Create(Projection, Parameters("EPSILON")->asDouble() * 1000.0) ) { Error_Set(_TL("projection initialization failed")); return( false ); } //----------------------------------------------------- TSG_Point A, B; A.x = Parameters("COORD_X1")->asDouble(); A.y = Parameters("COORD_Y1")->asDouble(); B.x = Parameters("COORD_X2")->asDouble(); B.y = Parameters("COORD_Y2")->asDouble(); //----------------------------------------------------- CSG_Shapes *pDistances = Parameters("DISTANCES")->asShapes(); pDistances ->Create(SHAPE_TYPE_Line, CSG_String::Format("%s", _TL("Geographic Distances"))); pDistances ->Add_Field("TYPE" , SG_DATATYPE_String); pDistances ->Add_Field("LENGTH", SG_DATATYPE_Double); pDistances ->Get_Projection().Create(Projection); //----------------------------------------------------- CSG_Shape *pPlanar = pDistances->Add_Shape(); pPlanar ->Set_Value(0, "Planar" ); CSG_Shape *pOrthodrome = pDistances->Add_Shape(); pOrthodrome->Set_Value(0, "Orthodrome"); CSG_Shape *pLoxodrome = pDistances->Add_Shape(); pLoxodrome ->Set_Value(0, "Loxodrome" ); pPlanar ->Add_Point(A); pOrthodrome->Add_Point(A); pLoxodrome ->Add_Point(A); pPlanar ->Set_Value(1, SG_Get_Distance (A, B )); pOrthodrome->Set_Value(1, Distance.Get_Orthodrome(A, B, pOrthodrome)); pLoxodrome ->Set_Value(1, Distance.Get_Loxodrome (A, B, pLoxodrome )); pPlanar ->Add_Point(B); pOrthodrome->Add_Point(B); pLoxodrome ->Add_Point(B); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Distance_Interactive::CCRS_Distance_Interactive(void) { Set_Name (_TL("Geographic Distances")); Set_Author ("O. Conrad (c) 2015"); Set_Description (_TW( "Calculates for all segments of the input lines the planar, great elliptic, " "and loxodrome distance and re-projects the latter two to the projection " "of the input lines. " )); Parameters.Add_Shapes( NULL , "DISTANCES" , _TL("Geographic Distances"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Epsilon"), _TL("defines the maximum resolution [km] for the re-projected distance segments"), PARAMETER_TYPE_Double, 100.0, 1.0, true ); Set_Drag_Mode(MODULE_INTERACTIVE_DRAG_LINE); } //--------------------------------------------------------- bool CCRS_Distance_Interactive::On_Execute(void) { CCRS_Picker CRS; if( !Dlg_Parameters(CRS.Get_Parameters(), CRS.Get_Name()) ) { m_Projection.Destroy(); return( false ); } return( m_Projection.Create(CRS.Get_Parameters()->Get_Parameter("CRS_PROJ4")->asString(), SG_PROJ_FMT_Proj4) ); } //--------------------------------------------------------- bool CCRS_Distance_Interactive::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { if( Mode == MODULE_INTERACTIVE_LDOWN ) { m_Down = ptWorld; } else if( Mode == MODULE_INTERACTIVE_LUP ) { if( m_Down != ptWorld ) { CCRS_Distance_Points Distance; Distance.Set_Parameter("DISTANCES", Parameters("DISTANCES")->asShapes()); Distance.Set_Parameter("EPSILON" , Parameters("EPSILON" )->asDouble()); Distance.Set_Parameter("CRS_PROJ4", m_Projection.Get_Proj4()); Distance.Set_Parameter("COORD_X1" , m_Down .Get_X()); Distance.Set_Parameter("COORD_Y1" , m_Down .Get_Y()); Distance.Set_Parameter("COORD_X2" , ptWorld.Get_X()); Distance.Set_Parameter("COORD_Y2" , ptWorld.Get_Y()); Distance.Execute(); DataObject_Update(Parameters("DISTANCES")->asShapes()); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/gcs_graticule.cpp0000664000175000017500000004327712565125415025273 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gcs_graticule.cpp 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // gcs_graticule.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gcs_graticule.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define AXIS_LEFT 1 #define AXIS_RIGHT 2 #define AXIS_BOTTOM 3 #define AXIS_TOP 4 //--------------------------------------------------------- enum { DEG_PREC_AUTO, DEG_PREC_FULL, DEG_PREC_SEC, DEG_PREC_MIN, DEG_PREC_DEG }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGCS_Graticule::CGCS_Graticule(void) { CSG_Parameter *pNode_0, *pNode_1; //----------------------------------------------------- Set_Name (_TL("Latitude/Longitude Graticule")); Set_Author (SG_T("O. Conrad (c) 2014")); Set_Description (_TW( "Creates a longitude/latitude graticule for the extent and projection of the input shapes layer. " )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "GRATICULE" , _TL("Graticule"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "COORDS" , _TL("Frame Coordinates"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); pNode_0 = Parameters.Add_Node( NULL , "NODE_GRID" , _TL("Graticule"), _TL("") ); pNode_1 = Parameters.Add_Node(pNode_0, "NODE_X" , _TL("X Range"), _TL("")); Parameters.Add_Value(pNode_1, "XMIN", _TL("Minimum"), _TL(""), PARAMETER_TYPE_Double); Parameters.Add_Value(pNode_1, "XMAX", _TL("Maximum"), _TL(""), PARAMETER_TYPE_Double); pNode_1 = Parameters.Add_Node(pNode_0, "NODE_Y" , _TL("Y Range"), _TL("")); Parameters.Add_Value(pNode_1, "YMIN", _TL("Minimum"), _TL(""), PARAMETER_TYPE_Double); Parameters.Add_Value(pNode_1, "YMAX", _TL("Maximum"), _TL(""), PARAMETER_TYPE_Double); Parameters.Add_Choice( pNode_0 , "INTERVAL" , _TL("Interval"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("fixed interval"), _TL("fitted interval") ), 0 ); Parameters.Add_Value( pNode_0 , "FIXED" , _TL("Fixed Interval (Degree)"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true, 20.0 ); Parameters.Add_Value( pNode_0 , "FITTED" , _TL("Number of Intervals"), _TL(""), PARAMETER_TYPE_Int, 10, 1, true ); Parameters.Add_Value( pNode_0 , "RESOLUTION" , _TL("Minimum Resolution (Degree)"), _TL(""), PARAMETER_TYPE_Double, 0.5, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGCS_Graticule::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CRS_GRID" )) || !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CRS_SHAPES")) ) { CSG_Rect r(!SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CRS_GRID")) ? pParameter->asParameters()->Get_Parameter("PICK")->asGrid ()->Get_Extent() : pParameter->asParameters()->Get_Parameter("PICK")->asShapes()->Get_Extent() ); if( r.Get_XRange() > 0.0 && r.Get_YRange() > 0.0 ) { 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()); } } return( CCRS_Base::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CGCS_Graticule::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("INTERVAL")) ) { pParameters->Get_Parameter("FIXED" )->Set_Enabled(pParameter->asInt() == 0); pParameters->Get_Parameter("FITTED")->Set_Enabled(pParameter->asInt() == 1); } return( CCRS_Base::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGCS_Graticule::On_Execute(void) { //----------------------------------------------------- CSG_Projection Projection; if( !Get_Projection(Projection) ) { return( false ); } //----------------------------------------------------- m_Projector.Set_Source(CSG_Projection("+proj=longlat +ellps=WGS84 +datum=WGS84", SG_PROJ_FMT_Proj4)); if( !m_Projector.Set_Target(Projection) ) { m_Projector.Destroy(); return( false ); } //----------------------------------------------------- CSG_Rect Extent( Parameters("XMIN")->asDouble(), Parameters("YMIN")->asDouble(), Parameters("XMAX")->asDouble(), Parameters("YMAX")->asDouble() ); if( !Get_Graticule(Extent) ) { m_Projector.Destroy(); return( false ); } //----------------------------------------------------- m_Projector.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGCS_Graticule::Get_Graticule(const CSG_Rect &Extent) { double x, y, Interval; CSG_Rect r; if( !Get_Extent(Extent, r) || (Interval = Get_Interval(r)) <= 0.0 ) { return( false ); } //----------------------------------------------------- r.m_rect.xMin = Interval * floor(r.Get_XMin() / Interval); r.m_rect.xMax = Interval * ceil (r.Get_XMax() / Interval); r.m_rect.yMin = Interval * floor(r.Get_YMin() / Interval); r.m_rect.yMax = Interval * ceil (r.Get_YMax() / Interval); r.Inflate(Interval, false); if( r.Get_XMin() < -180.0 ) r.m_rect.xMin = -180.0; if( r.Get_XMax() > 180.0 ) r.m_rect.xMax = 180.0; if( r.Get_YMin() < -90.0 ) r.m_rect.yMin = -90.0; if( r.Get_YMax() > 90.0 ) r.m_rect.yMax = 90.0; //----------------------------------------------------- double Resolution = Parameters("RESOLUTION")->asDouble(); if( Resolution <= 0.0 ) Resolution = Interval; if( Interval > Resolution ) { Resolution = Interval / ceil(Interval / Resolution); } //----------------------------------------------------- CSG_Shapes *pGraticule = Parameters("GRATICULE")->asShapes(); pGraticule->Create(SHAPE_TYPE_Line); pGraticule->Set_Name(_TL("Graticule")); pGraticule->Add_Field("TYPE" , SG_DATATYPE_String); pGraticule->Add_Field("LABEL" , SG_DATATYPE_String); pGraticule->Add_Field("DEGREE", SG_DATATYPE_Double); //----------------------------------------------------- CSG_Shapes *pCoordinates = Parameters("COORDS")->asShapes(); if( pCoordinates ) { pCoordinates->Create(SHAPE_TYPE_Point); pCoordinates->Set_Name(_TL("Coordinates")); pCoordinates->Add_Field("TYPE" , SG_DATATYPE_String); pCoordinates->Add_Field("LABEL", SG_DATATYPE_String); } //----------------------------------------------------- CSG_Shapes Clip(SHAPE_TYPE_Polygon); CSG_Shape *pClip = Clip.Add_Shape(); pClip->Add_Point(Extent.Get_XMin(), Extent.Get_YMin()); pClip->Add_Point(Extent.Get_XMin(), Extent.Get_YMax()); pClip->Add_Point(Extent.Get_XMax(), Extent.Get_YMax()); pClip->Add_Point(Extent.Get_XMax(), Extent.Get_YMin()); pClip->Add_Point(Extent.Get_XMin(), Extent.Get_YMin()); //----------------------------------------------------- for(y=r.Get_YMin(); y<=r.Get_YMax(); y+=Interval) { CSG_Shape *pLine = pGraticule->Add_Shape(); pLine->Set_Value(0, "LAT"); pLine->Set_Value(1, Get_Degree(y, DEG_PREC_DEG)); pLine->Set_Value(2, y); for(x=r.Get_XMin(); x<=r.Get_XMax(); x+=Interval) { CSG_Point p(x, y); m_Projector.Get_Projection(p); pLine->Add_Point(p); if( Resolution < Interval && x < r.Get_XMax() ) { for(double i=x+Resolution; iAdd_Point(p); } } } Get_Coordinate(Extent, pCoordinates, pLine, AXIS_LEFT); Get_Coordinate(Extent, pCoordinates, pLine, AXIS_RIGHT); if( !SG_Polygon_Intersection(pLine, pClip) ) { pGraticule->Del_Shape(pLine); } } //----------------------------------------------------- for(x=r.Get_XMin(); x<=r.Get_XMax(); x+=Interval) { CSG_Shape *pLine = pGraticule->Add_Shape(); pLine->Set_Value(0, "LON"); pLine->Set_Value(1, Get_Degree(x, DEG_PREC_DEG)); pLine->Set_Value(2, x); for(y=r.Get_YMin(); y<=r.Get_YMax(); y+=Interval) { CSG_Point p(x, y); m_Projector.Get_Projection(p); pLine->Add_Point(p); if( Resolution < Interval && y < r.Get_YMax() ) { for(double i=y+Resolution; iAdd_Point(p); } } } Get_Coordinate(Extent, pCoordinates, pLine, AXIS_BOTTOM); Get_Coordinate(Extent, pCoordinates, pLine, AXIS_TOP); if( !SG_Polygon_Intersection(pLine, pClip) ) { pGraticule->Del_Shape(pLine); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGCS_Graticule::Get_Coordinate(const CSG_Rect &Extent, CSG_Shapes *pCoordinates, CSG_Shape *pLine, int Axis) { if( !pCoordinates || !Extent.Intersects(pLine->Get_Extent()) || pLine->Get_Point_Count(0) < 2 ) { return( false ); } TSG_Point A[2], B[2], C; switch( Axis ) { case AXIS_LEFT : A[0].x = A[1].x = Extent.Get_XMin(); A[0].y = Extent.Get_YMin(); A[1].y = Extent.Get_YMax(); break; case AXIS_RIGHT : A[0].x = A[1].x = Extent.Get_XMax(); A[0].y = Extent.Get_YMin(); A[1].y = Extent.Get_YMax(); break; case AXIS_BOTTOM: A[0].y = A[1].y = Extent.Get_YMin(); A[0].x = Extent.Get_XMin(); A[1].x = Extent.Get_XMax(); break; case AXIS_TOP : A[0].y = A[1].y = Extent.Get_YMax(); A[0].x = Extent.Get_XMin(); A[1].x = Extent.Get_XMax(); break; default: return( false ); } //----------------------------------------------------- B[1] = pLine->Get_Point(0); for(int i=1; iGet_Point_Count(); i++) { B[0] = B[1]; B[1] = pLine->Get_Point(i); if( SG_Get_Crossing(C, A[0], A[1], B[0], B[1], true) ) { CSG_Shape *pPoint = pCoordinates->Add_Shape(); pPoint->Add_Point(C); pPoint->Set_Value(0, CSG_String(pLine->asString(0)) + (Axis == AXIS_LEFT || Axis == AXIS_BOTTOM ? "_MIN" : "_MAX")); pPoint->Set_Value(1, pLine->asString(1)); return( true ); } } //----------------------------------------------------- switch( Axis ) { case AXIS_LEFT : C = pLine->Get_Point(0, 0, true ); break; case AXIS_RIGHT : C = pLine->Get_Point(0, 0, false); break; case AXIS_BOTTOM: C = pLine->Get_Point(0, 0, true ); break; case AXIS_TOP : C = pLine->Get_Point(0, 0, false); break; } if( Extent.Contains(C) ) { CSG_Shape *pPoint = pCoordinates->Add_Shape(); pPoint->Add_Point(C); pPoint->Set_Value(0, CSG_String(pLine->asString(0)) + (Axis == AXIS_LEFT || Axis == AXIS_BOTTOM ? "_MIN" : "_MAX")); pPoint->Set_Value(1, pLine->asString(1)); return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CGCS_Graticule::Get_Interval(const CSG_Rect &Extent) { if( Parameters("INTERVAL")->asInt() == 0 ) { return( Parameters("FIXED")->asDouble() ); } double Interval = Extent.Get_XRange() > Extent.Get_YRange() ? Extent.Get_XRange() : Extent.Get_YRange(); if( Interval > 360 ) { Interval = 360; } Interval = Interval / Parameters("FITTED")->asInt(); double d = pow(10.0, (int)(log10(Interval)) - (Interval < 1.0 ? 1.0 : 0.0)); Interval = (int)(Interval / d) * d; return( Interval ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGCS_Graticule::Get_Extent(const CSG_Rect &Extent, CSG_Rect &r) { if( m_Projector.Set_Inverse() ) { double x, y, d; CSG_Point p(Extent.Get_XMin(), Extent.Get_YMin()); m_Projector.Get_Projection(p); r.Assign(p, p); d = Extent.Get_XRange() / 10.0; for(y=Extent.Get_YMin(), x=Extent.Get_XMin(); x<=Extent.Get_XMax(); x+=d) { p.Assign(x, y); m_Projector.Get_Projection(p); r.Union(p); } for(y=Extent.Get_YMax(), x=Extent.Get_XMin(); x<=Extent.Get_XMax(); x+=d) { p.Assign(x, y); m_Projector.Get_Projection(p); r.Union(p); } d = Extent.Get_YRange() / 10.0; for(x=Extent.Get_XMin(), y=Extent.Get_YMin(); y<=Extent.Get_YMax(); y+=d) { p.Assign(x, y); m_Projector.Get_Projection(p); r.Union(p); } for(x=Extent.Get_XMax(), y=Extent.Get_YMin(); y<=Extent.Get_YMax(); y+=d) { p.Assign(x, y); m_Projector.Get_Projection(p); r.Union(p); } m_Projector.Set_Inverse(false); if( r.Get_XMin() < -180 ) r.m_rect.xMin = -180; else if( r.Get_XMax() > 180 ) r.m_rect.xMax = 180; if( r.Get_YMin() < -90 ) r.m_rect.yMin = -90; else if( r.Get_YMax() > 90 ) r.m_rect.yMax = 90; return( r.Get_XRange() > 0.0 && r.Get_YRange() > 0.0 ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CGCS_Graticule::Get_Degree(double Value, int Precision) { if( Precision == DEG_PREC_DEG ) { return( SG_Get_String(Value, -12) + "\xb0" ); } SG_Char c; int d, h; double s; CSG_String String; if( Value < 0.0 ) { Value = -Value; c = SG_T('-'); } else { c = SG_T('+'); } Value = fmod(Value, 360.0); d = (int)Value; Value = 60.0 * (Value - d); h = (int)Value; Value = 60.0 * (Value - h); s = Value; if( s > 0.0 || Precision == DEG_PREC_FULL ) { String.Printf(SG_T("%c%d\xb0%02d'%02.*f''"), c, d, h, SG_Get_Significant_Decimals(s), s); } else if( h > 0 || Precision == DEG_PREC_MIN ) { String.Printf(SG_T("%c%d\xb0%02d'" ), c, d, h); } else { String.Printf(SG_T("%c%d\xb0" ), c, d); } return( String ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/MLB_Interface.cpp0000664000175000017500000001424012565125415025036 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2462 2015-03-27 16:29:25Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 "crs_transform.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Proj.4") ); case MLB_INFO_Category: return( _TL("Projection") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2004-14") ); case MLB_INFO_Description: return( CSG_CRSProjector::Get_Description() ); case MLB_INFO_Version: return( _TL("2.0") ); case MLB_INFO_Menu_Path: return( _TL("Projection") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "crs_assign.h" #include "crs_transform_shapes.h" #include "crs_transform_grid.h" #include "PROJ4_Shapes.h" #include "PROJ4_Grid.h" #include "gcs_lon_range.h" #include "gcs_graticule.h" #include "crs_indicatrix.h" #include "crs_grid_geogcoords.h" #include "crs_transform_pointcloud.h" #include "crs_distance.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CCRS_Assign() ); case 1: return( new CCRS_Transform_Shapes (true ) ); case 2: return( new CCRS_Transform_Shapes (false) ); case 3: return( new CCRS_Transform_Grid (true ) ); case 4: return( new CCRS_Transform_Grid (false) ); case 18: return( new CCRS_Transform_PointCloud(true ) ); case 19: return( new CCRS_Transform_PointCloud(false) ); case 15: return( new CCRS_Picker() ); case 13: return( new CGCS_Grid_Longitude_Range() ); case 14: return( new CGCS_Graticule() ); case 16: return( new CCRS_Indicatrix() ); case 17: return( new CCRS_Grid_GeogCoords() ); case 20: return( new CCRS_Distance_Lines() ); case 21: return( new CCRS_Distance_Points() ); case 22: return( new CCRS_Distance_Interactive() ); case 5: return( new CPROJ4_Shapes (PROJ4_INTERFACE_SIMPLE, false) ); case 6: return( new CPROJ4_Shapes (PROJ4_INTERFACE_DIALOG, false) ); case 7: return( new CPROJ4_Grid (PROJ4_INTERFACE_SIMPLE, false) ); case 8: return( new CPROJ4_Grid (PROJ4_INTERFACE_DIALOG, false) ); case 9: return( new CPROJ4_Shapes (PROJ4_INTERFACE_SIMPLE, true) ); case 10: return( new CPROJ4_Shapes (PROJ4_INTERFACE_DIALOG, true) ); case 11: return( new CPROJ4_Grid (PROJ4_INTERFACE_SIMPLE, true) ); case 12: return( new CPROJ4_Grid (PROJ4_INTERFACE_DIALOG, true) ); case 23: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/projection/pj_proj4/crs_transform.cpp0000664000175000017500000002433312565125415025332 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_transform.cpp 2147 2014-06-10 12:57:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_transform.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PROJ4_FREE(p) if( p ) { pj_free((PJ *)p); p = NULL; } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_CRSProjector::CSG_CRSProjector(void) { m_bInverse = false; m_pSource = NULL; m_pTarget = NULL; m_pGCS = NULL; } //--------------------------------------------------------- CSG_CRSProjector::~CSG_CRSProjector(void) { Destroy(); } //--------------------------------------------------------- bool CSG_CRSProjector::Destroy(void) { m_bInverse = false; PROJ4_FREE(m_pSource); PROJ4_FREE(m_pTarget); PROJ4_FREE(m_pGCS); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CSG_CRSProjector::Get_Version(void) { return( pj_release ); } //--------------------------------------------------------- CSG_String CSG_CRSProjector::Get_Description(void) { CSG_String s; s += _TL("Projection routines make use of the Proj.4 Cartographic Projections library."); s += "\n"; s += _TW("Proj.4 was originally developed by Gerald Evenden and later continued by the " "United States Department of the Interior, Geological Survey (USGS)."); s += "\n"; s += _TL("Proj.4 Version is ") + Get_Version(); s += "\n"; s += "Proj.4 Homepage"; return( s ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_CRSProjector::_Set_Projection(const CSG_Projection &Projection, void **ppProjection, bool bInverse) { PROJ4_FREE(*ppProjection); //------------------------------------------------- if( (*ppProjection = pj_init_plus(Projection.Get_Proj4())) == NULL ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("Proj4 [%s]: %s"), _TL("initialization"), SG_STR_MBTOSG(pj_strerrno(pj_errno)))); return( false ); } //------------------------------------------------- if( bInverse && ((PJ *)(*ppProjection))->inv == NULL ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("Proj4 [%s]: %s"), _TL("initialization"), _TL("inverse transformation not available"))); return( false ); } return( true ); } //--------------------------------------------------------- bool CSG_CRSProjector::Set_Source(const CSG_Projection &Projection) { SG_UI_Msg_Add_Execution(CSG_String::Format(SG_T("\n%s: %s"), _TL("source"), Projection.Get_Proj4().c_str()), false); return( _Set_Projection(Projection, &m_pSource, true) && m_Source.Create(Projection) ); } //--------------------------------------------------------- bool CSG_CRSProjector::Set_Target(const CSG_Projection &Projection) { SG_UI_Msg_Add_Execution(CSG_String::Format(SG_T("\n%s: %s"), _TL("target"), Projection.Get_Proj4().c_str()), false); return( _Set_Projection(Projection, &m_pTarget, false) && m_Target.Create(Projection) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_CRSProjector::Set_Inverse(bool bOn) { if( m_bInverse == bOn ) { return( true ); } if( m_pTarget && ((PJ *)m_pTarget)->inv ) { m_bInverse = bOn; void *pTMP = m_pSource; m_pSource = m_pTarget; m_pTarget = pTMP; return( true ); } SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("Proj4 [%s]: %s"), _TL("initialization"), _TL("inverse transformation not available"))); return( false ); } //--------------------------------------------------------- bool CSG_CRSProjector::Set_Precise_Mode(bool bOn) { if( bOn ) { if( m_pGCS == NULL ) { return( (m_pGCS = pj_init_plus("+proj=longlat +datum=WGS84")) != NULL ); } } else { PROJ4_FREE(m_pGCS); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(double &x, double &y) const { if( !m_pSource || !m_pTarget ) { return( false ); } if( pj_is_latlong((PJ *)m_pSource) ) { x *= DEG_TO_RAD; y *= DEG_TO_RAD; } if( m_pGCS ) // precise datum conversion { if( pj_transform((PJ *)m_pSource, (PJ *)m_pGCS , 1, 0, &x, &y, NULL) != 0 || pj_transform((PJ *)m_pGCS , (PJ *)m_pTarget, 1, 0, &x, &y, NULL) != 0 ) { return( false ); } } else // direct projection { if( pj_transform((PJ *)m_pSource, (PJ *)m_pTarget, 1, 0, &x, &y, NULL) != 0 ) { return( false ); } } if( pj_is_latlong((PJ *)m_pTarget) ) { x *= RAD_TO_DEG; y *= RAD_TO_DEG; } return( true ); } //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(TSG_Point &Point) const { return( Get_Projection(Point.x, Point.y) ); } //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(CSG_Point &Point) const { double x = Point.Get_X(); double y = Point.Get_Y(); if( Get_Projection(x, y) ) { Point.Assign(x, y); return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(double &x, double &y, double &z) const { if( !m_pSource || !m_pTarget ) { return( false ); } if( pj_is_latlong((PJ *)m_pSource) ) { x *= DEG_TO_RAD; y *= DEG_TO_RAD; } if( m_pGCS ) // precise datum conversion { if( pj_transform((PJ *)m_pSource, (PJ *)m_pGCS , 1, 0, &x, &y, &z) != 0 || pj_transform((PJ *)m_pGCS , (PJ *)m_pTarget, 1, 0, &x, &y, &z) != 0 ) { return( false ); } } else // direct projection { if( pj_transform((PJ *)m_pSource, (PJ *)m_pTarget, 1, 0, &x, &y, &z) != 0 ) { return( false ); } } if( pj_is_latlong((PJ *)m_pTarget) ) { x *= RAD_TO_DEG; y *= RAD_TO_DEG; } return( true ); } //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(TSG_Point_Z &Point) const { return( Get_Projection(Point.x, Point.y, Point.z) ); } //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(CSG_Point_Z &Point) const { double x = Point.Get_X(); double y = Point.Get_Y(); double z = Point.Get_Z(); if( Get_Projection(x, y, z) ) { Point.Assign(x, y, z); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/Makefile.am0000664000175000017500000000221512565125415023773 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 2462 2015-03-27 16:29:25Z oconrad $ # DEP_LIBS = -lproj 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 $(LOCAL_INCS) AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) $(LOCAL_LIBS) pkglib_LTLIBRARIES = libpj_proj4.la libpj_proj4_la_SOURCES =\ MLB_Interface.cpp\ crs_assign.cpp\ crs_base.cpp\ crs_distance.cpp\ crs_grid_geogcoords.cpp\ crs_indicatrix.cpp\ crs_transform.cpp\ crs_transform_grid.cpp\ crs_transform_pointcloud.cpp\ crs_transform_shapes.cpp\ gcs_graticule.cpp\ gcs_lon_range.cpp\ PROJ4_Base.cpp\ PROJ4_Grid.cpp\ PROJ4_Shapes.cpp\ MLB_Interface.h\ crs_assign.h\ crs_base.h\ crs_distance.h\ crs_grid_geogcoords.h\ crs_indicatrix.h\ crs_transform.h\ crs_transform_grid.h\ crs_transform_pointcloud.h\ crs_transform_shapes.h\ gcs_graticule.h\ gcs_lon_range.h\ PROJ4_Base.h\ PROJ4_Grid.h\ PROJ4_Shapes.h libpj_proj4_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/projection/pj_proj4/MLB_Interface.h0000664000175000017500000000767412565125415024520 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__pj_proj4_H #define HEADER_INCLUDED__pj_proj4_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef pj_proj4_EXPORTS #define pj_proj4_EXPORT _SAGA_DLL_EXPORT #else #define pj_proj4_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pj_proj4_H saga-2.2.3/src/modules/projection/pj_proj4/crs_grid_geogcoords.cpp0000664000175000017500000001330012565125415026447 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_grid_geogcoords.cpp 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_grid_geogcoords.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_grid_geogcoords.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Grid_GeogCoords::CCRS_Grid_GeogCoords(void) { //----------------------------------------------------- Set_Name (_TL("Geographic Coordinate Grids")); Set_Author ("O. Conrad (c) 2014"); Set_Description (_TW( "Creates for a given grid geographic coordinate information, " "i.e. two grids specifying the longitude and latitude for each cell. " "The coodinate system of the input grid has to be defined. " )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "LON" , _TL("Longitude"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "LAT" , _TL("Latitude"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Grid_GeogCoords::On_Execute(void) { CSG_CRSProjector Projector; if( !Projector.Set_Source(Parameters("GRID")->asGrid()->Get_Projection()) ) { Error_Set(_TL("Could not initialize grid projection.")); return( false ); } Projector.Set_Target(CSG_Projection("+proj=longlat +ellps=WGS84 +datum=WGS84", SG_PROJ_FMT_Proj4)); //----------------------------------------------------- CSG_Grid *pLon = Parameters("LON")->asGrid(); CSG_Grid *pLat = Parameters("LAT")->asGrid(); for(int y=0; ySet_Value(x, y, p.Get_X()); pLat->Set_Value(x, y, p.Get_Y()); } else { pLon->Set_NoData(x, y); pLat->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/crs_assign.h0000664000175000017500000001013212565125415024240 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_assign.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_assign.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_assign_H #define HEADER_INCLUDED__crs_assign_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Assign : public CCRS_Base { public: CCRS_Assign(void); protected: virtual bool On_Execute (void); private: int Set_Projections (const CSG_Projection &Projection, CSG_Parameter_List *pList); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_assign_H saga-2.2.3/src/modules/projection/pj_proj4/crs_base.cpp0000664000175000017500000011321612565125415024230 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_base.cpp 2469 2015-04-17 13:02:24Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_base.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_base.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Base::CCRS_Base(void) { m_Projection.Create(4326); CSG_Parameter *pNode_0, *pNode_1; //----------------------------------------------------- if( SG_UI_Get_Window_Main() == NULL ) { Parameters.Add_Choice( NULL , "CRS_METHOD" , _TL("Get CRS Definition from..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Proj4 Parameters"), _TL("EPSG Code"), _TL("Well Known Text File") ), 0 ); } //----------------------------------------------------- pNode_0 = Parameters.Add_String( NULL , "CRS_PROJ4" , _TL("Proj4 Parameters"), _TL(""), m_Projection.Get_Proj4(), true ); if( SG_UI_Get_Window_Main() ) { Parameters.Add_Parameters( pNode_0 , "CRS_DIALOG" , _TL("User Defined"), _TL("") ); Set_User_Parameters(Parameters("CRS_DIALOG")->asParameters()); } //----------------------------------------------------- if( SG_UI_Get_Window_Main() ) { pNode_1 = Parameters.Add_Parameters(pNode_0, "CRS_GRID" , _TL("Loaded Grid") , _TL("")); pNode_1->asParameters()->Add_Grid( NULL , "PICK" , _TL("Grid"), _TL(""), PARAMETER_INPUT_OPTIONAL, false ); pNode_1 = Parameters.Add_Parameters(pNode_0, "CRS_SHAPES", _TL("Loaded Shapes"), _TL("")); pNode_1->asParameters()->Add_Shapes( NULL , "PICK" , _TL("Shapes"), _TL(""), PARAMETER_INPUT_OPTIONAL ); } //----------------------------------------------------- Parameters.Add_FilePath( pNode_0 , "CRS_FILE" , _TL("Well Known Text File"), _TL(""), CSG_String::Format( SG_T("%s|*.prj;*.wkt;*.txt|%s|*.prj|%s|*.wkt|%s|*.txt|%s|*.*"), _TL("All Recognized Files"), _TL("ESRI WKT Files (*.prj)"), _TL("WKT Files (*.wkt)"), _TL("Text Files (*.txt)"), _TL("All Files") ) ); //----------------------------------------------------- pNode_1 = Parameters.Add_Value( pNode_0 , "CRS_EPSG" , _TL("EPSG Code"), _TL(""), PARAMETER_TYPE_Int, m_Projection.Get_EPSG(), -1, true ); if( SG_UI_Get_Window_Main() ) { Parameters.Add_Choice( pNode_1 , "CRS_EPSG_GEOGCS" , _TL("Geographic Coordinate Systems"), _TL(""), SG_Get_Projections().Get_Names_List(SG_PROJ_TYPE_CS_Geographic) ); Parameters.Add_Choice( pNode_1 , "CRS_EPSG_PROJCS" , _TL("Projected Coordinate Systems"), _TL(""), SG_Get_Projections().Get_Names_List(SG_PROJ_TYPE_CS_Projected) ); } //----------------------------------------------------- Parameters.Add_Value( NULL , "PRECISE" , _TL("Precise Datum Conversion"), _TL("avoids precision problems when source and target crs use different geodedtic datums."), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Base::On_Before_Execution(void) { m_Projection.Create(Parameters("CRS_PROJ4")->asString(), SG_PROJ_FMT_Proj4); if( m_Projection.is_Okay() && Parameters("CRS_DIALOG") ) { Set_User_Definition(*Parameters("CRS_DIALOG")->asParameters(), Parameters("CRS_PROJ4")->asString()); } return( true ); } //--------------------------------------------------------- int CCRS_Base::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { //----------------------------------------------------- if( !SG_STR_CMP(pParameters->Get_Identifier(), "CRS_DIALOG") ) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "PROJ_TYPE") ) { pParameters->Get_Parameter("OPTIONS")->asParameters()->Assign(Get_Parameters(SG_STR_MBTOSG(pj_list[pParameter->asInt()].id))); } return( 1 ); } //----------------------------------------------------- CSG_Projection Projection; //----------------------------------------------------- if( pParameters->Get_Parameter("CRS_PROJ4") ) { Projection.Create(pParameter->asString(), SG_PROJ_FMT_Proj4); } //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_DIALOG") ) { Projection.Create(Get_User_Definition(*pParameter->asParameters()), SG_PROJ_FMT_Proj4); } //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_FILE") ) { Projection.Load(pParameter->asString()); pParameter->Set_Value(CSG_String("")); // clear } //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_EPSG") ) { if (!Projection.Create(pParameter->asInt())) { SG_UI_Dlg_Message(_TL("Unkown EPSG Code"), _TL("WARNING")); } } //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_EPSG_GEOGCS") || !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_EPSG_PROJCS") ) { int EPSG; if( pParameter->asChoice()->Get_Data(EPSG) ) { Projection.Create(EPSG); } } //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_GRID") || !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_SHAPES") ) { CSG_Data_Object *pPick = pParameter->asParameters()->Get_Parameter("PICK")->asDataObject(); if( pPick && pPick->Get_Projection().is_Okay() ) { Projection.Create(pPick->Get_Projection()); } } //----------------------------------------------------- if( Projection.is_Okay() ) { m_Projection = Projection; pParameters->Get_Parameter("CRS_PROJ4")->Set_Value(m_Projection.Get_Proj4()); pParameters->Get_Parameter("CRS_EPSG" )->Set_Value(m_Projection.Get_EPSG ()); if( pParameters->Get_Parameter("CRS_DIALOG") ) { Set_User_Definition(*pParameters->Get_Parameter("CRS_DIALOG")->asParameters(), m_Projection.Get_Proj4()); } } //----------------------------------------------------- return( 1 ); } //--------------------------------------------------------- int CCRS_Base::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameters->Get_Identifier(), "CRS_DIALOG") ) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "PROJ_TYPE") ) { // pParameters->Get_Parameter("OPTIONS")->asParameters()->Assign(Get_Parameters(SG_STR_MBTOSG(pj_list[pParameter->asInt()].id))); pParameters->Get_Parameter("OPTIONS")->Set_Enabled(pParameters->Get_Parameter("OPTIONS")->asParameters()->Get_Count() > 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DATUM_DEF") ) { int Value = pParameter->asInt(); pParameters->Get_Parameter("DATUM" )->Set_Enabled(Value == 0); pParameters->Get_Parameter("ELLIPSOID")->Set_Enabled(Value == 1); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "ELLIPSOID") ) { int Value = pParameter->asInt(); pParameters->Get_Parameter("ELLPS_DEF")->Set_Enabled(Value == 0); pParameters->Get_Parameter("ELLPS_A" )->Set_Enabled(Value != 0); pParameters->Get_Parameter("ELLPS_B" )->Set_Enabled(Value == 1); pParameters->Get_Parameter("ELLPS_F" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("ELLPS_RF" )->Set_Enabled(Value == 3); pParameters->Get_Parameter("ELLPS_E" )->Set_Enabled(Value == 4); pParameters->Get_Parameter("ELLPS_ES" )->Set_Enabled(Value == 5); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DATUM_SHIFT") ) { int Value = pParameter->asInt(); pParameters->Get_Parameter("DS_DX" )->Set_Enabled(Value == 1 || Value == 2); pParameters->Get_Parameter("DS_DY" )->Set_Enabled(Value == 1 || Value == 2); pParameters->Get_Parameter("DS_DZ" )->Set_Enabled(Value == 1 || Value == 2); pParameters->Get_Parameter("DS_RX" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("DS_RY" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("DS_RZ" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("DS_SC" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("DATUM_GRID")->Set_Enabled(Value == 3); } } //----------------------------------------------------- return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Base::Get_Projection(CSG_Projection &Projection) { if( !Parameters("CRS_METHOD") ) { Projection = m_Projection; } else switch( Parameters("CRS_METHOD")->asInt() ) { default: // Proj4 Parameters if( !Projection.Create(Parameters("CRS_PROJ4")->asString(), SG_PROJ_FMT_Proj4) ) { Error_Set(_TL("Proj4 definition string error")); } break; case 1: // EPSG Code if( !Projection.Create(Parameters("CRS_EPSG" )->asInt()) ) { Error_Set(_TL("EPSG code error")); } break; case 2: // Well Known Text File if( !Projection.Load (Parameters("CRS_FILE" )->asString()) ) { Error_Set(_TL("Well Known Text file error")); } break; } return( Projection.is_Okay() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define WGS84_ELLPS_A 6378137.000 #define WGS84_ELLPS_B 6356752.314 //--------------------------------------------------------- bool CCRS_Base::Set_User_Parameters(CSG_Parameters *pParameters) { CSG_Parameter *pNode_0 = NULL, *pNode_1, *pNode_2; CSG_String sProjections, sName, sDescription, sArguments, sDatums, sEllipsoids, sUnits; /////////////////////////////////////////////////////// // Projection ----------------------------------------- sDescription = _TL("Available Projections:"); for(struct PJ_LIST *pProjection=pj_list; pProjection->id; ++pProjection) { sArguments = *pProjection->descr; sName = sArguments.BeforeFirst('\n'); sArguments = sArguments.AfterFirst ('\n').AfterFirst('\n').AfterFirst('\t'); sProjections += CSG_String::Format(SG_T("{%s}%s|") , SG_STR_MBTOSG(pProjection->id), sName.c_str()); sDescription += CSG_String::Format(SG_T("\n[%s] %s (%s)"), SG_STR_MBTOSG(pProjection->id), sName.c_str(), sArguments.c_str()); Add_User_Projection(pProjection->id, sName, sArguments); } // Datums --------------------------------------------- for(struct PJ_DATUMS *pDatum=pj_datums; pDatum->id; ++pDatum) { CSG_String id (pDatum->id); CSG_String comments(pDatum->comments); sDatums += CSG_String::Format(SG_T("{%s}%s|"), id.c_str(), comments.Length() ? comments.c_str() : id.c_str()); } // Ellipsoids ----------------------------------------- for(struct PJ_ELLPS *pEllipse=pj_ellps; pEllipse->id; ++pEllipse) { sEllipsoids += CSG_String::Format(SG_T("{%s}%s (%s, %s)|"), SG_STR_MBTOSG(pEllipse->id), SG_STR_MBTOSG(pEllipse->name), SG_STR_MBTOSG(pEllipse->major), SG_STR_MBTOSG(pEllipse->ell)); } // Units ---------------------------------------------- for(struct PJ_UNITS *pUnit=pj_units; pUnit->id; ++pUnit) { sUnits += CSG_String::Format(SG_T("{%s}%s (%s)|"), SG_STR_MBTOSG(pUnit->id), SG_STR_MBTOSG(pUnit->name), SG_STR_MBTOSG(pUnit->to_meter)); } /////////////////////////////////////////////////////// //----------------------------------------------------- // Projection... if( sProjections.Length() == 0 ) { return( false ); } pParameters->Add_Choice (pNode_0, "PROJ_TYPE" , _TL("Projection Type") , sDescription, sProjections); //----------------------------------------------------- // Datum... pNode_1 = pParameters->Add_Choice( pNode_0, "DATUM_DEF" , _TL("Datum Definition"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Predefined Datum"), _TL("User Defined Datum") ) ); //----------------------------------------------------- // Predefined Datum... pParameters->Add_Choice (pNode_1, "DATUM" , _TL("Predefined Datum") , _TL(""), sDatums); //----------------------------------------------------- // Ellipsoid... pNode_2 = pParameters->Add_Choice( pNode_1, "ELLIPSOID" , _TL("Ellipsoid Definition"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("Predefined Ellipsoids"), _TL("Semimajor Axis and Semiminor Axis"), _TL("Semimajor Axis and Flattening"), _TL("Semimajor Axis and Reciprocal Flattening"), _TL("Semimajor Axis and Eccentricity"), _TL("Semimajor Axis and Eccentricity Squared") ) ); pParameters->Add_Choice (pNode_2, "ELLPS_DEF" , _TL("Predefined Ellipsoids") , _TL(""), sEllipsoids); pParameters->Add_Value (pNode_2, "ELLPS_A" , _TL("Semimajor Axis (a)") , _TL(""), PARAMETER_TYPE_Double, WGS84_ELLPS_A); pParameters->Add_Value (pNode_2, "ELLPS_B" , _TL("Semiminor Axis (b)") , _TL(""), PARAMETER_TYPE_Double, WGS84_ELLPS_B); pParameters->Add_Value (pNode_2, "ELLPS_F" , _TL("Flattening (f)") , _TL(""), PARAMETER_TYPE_Double, (WGS84_ELLPS_A - WGS84_ELLPS_B) / WGS84_ELLPS_A); pParameters->Add_Value (pNode_2, "ELLPS_RF" , _TL("Reciprocal Flattening (rf)") , _TL(""), PARAMETER_TYPE_Double, WGS84_ELLPS_A / (WGS84_ELLPS_A - WGS84_ELLPS_B)); pParameters->Add_Value (pNode_2, "ELLPS_E" , _TL("Eccentricity (e)") , _TL(""), PARAMETER_TYPE_Double, sqrt(WGS84_ELLPS_A*WGS84_ELLPS_A + WGS84_ELLPS_B*WGS84_ELLPS_B)); pParameters->Add_Value (pNode_2, "ELLPS_ES" , _TL("Squared Eccentricity (es)") , _TL(""), PARAMETER_TYPE_Double, WGS84_ELLPS_A*WGS84_ELLPS_A + WGS84_ELLPS_B*WGS84_ELLPS_B); //----------------------------------------------------- // Datum Shift... pNode_2 = pParameters->Add_Choice( pNode_1, "DATUM_SHIFT" , _TL("Datum Shift"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("none"), _TL("3 parameters (translation only)"), _TL("7 parameters"), _TL("Datum Shift Grid") ) ); pParameters->Add_Value (pNode_2, "DS_DX" , _TL("Translation X") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_DY" , _TL("Translation Y") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_DZ" , _TL("Translation Z") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_RX" , _TL("Rotation X") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_RY" , _TL("Rotation Y") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_RZ" , _TL("Rotation Z") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_SC" , _TL("Scaling") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_FilePath( pNode_2, "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 ); //----------------------------------------------------- // General Settings... pNode_1 = pParameters->Add_Node(pNode_0, "NODE_GENERAL" , _TL("General Settings"), _TL("")); pParameters->Add_Value (pNode_1, "LON_0" , _TL("Central Meridian") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_1, "LAT_0" , _TL("Central Parallel") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_1, "X_0" , _TL("False Easting") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_1, "Y_0" , _TL("False Northing") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_1, "K_0" , _TL("Scale Factor") , _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true); pParameters->Add_Choice (pNode_1, "UNIT" , _TL("Unit") , _TL(""), sUnits, 1); pParameters->Add_Value (pNode_1, "NO_DEFS" , _TL("Ignore Defaults") , _TL(""), PARAMETER_TYPE_Bool, false); pParameters->Add_Value (pNode_1, "OVER" , _TL("Allow longitudes outside -180 to 180 Range") , _TL(""), PARAMETER_TYPE_Bool, false); //----------------------------------------------------- pParameters->Add_Parameters( pNode_0, "OPTIONS" , _TL("Projection Settings"), _TL("") ); pParameters->Get_Parameter("OPTIONS")->asParameters()->Assign(Get_Parameters(SG_STR_MBTOSG(pj_list[0].id))); //----------------------------------------------------- return( true ); } //--------------------------------------------------------- #define PRM_ADD_BOL(key, name, val) pParms->Add_Value (NULL, key, name, _TL(""), PARAMETER_TYPE_Bool , val); #define PRM_ADD_INT(key, name, val) pParms->Add_Value (NULL, key, name, _TL(""), PARAMETER_TYPE_Int , val); #define PRM_ADD_FLT(key, name, val) pParms->Add_Value (NULL, key, name, _TL(""), PARAMETER_TYPE_Double, val); #define PRM_ADD_STR(key, name, val) pParms->Add_String(NULL, key, name, _TL(""), val); #define PRM_ADD_CHO(key, name, val) pParms->Add_Choice(NULL, key, name, _TL(""), val); //--------------------------------------------------------- bool CCRS_Base::Add_User_Projection(const CSG_String &sID, const CSG_String &sName, const CSG_String &sArgs) { if( sArgs.Length() == 0 ) { return( false ); } CSG_Parameters *pParms = Add_Parameters(sID, sName, sArgs); // pParms->Add_Info_String(NULL, "DESC", _TL("Description"), _TL(""), sArgs.c_str(), true); //----------------------------------------------------- // Cylindrical Projections... if( !sID.CmpNoCase(SG_T("cea")) // Equal Area Cylindrical || !sID.CmpNoCase(SG_T("eqc")) // Equidistant Cylindrical (Plate Caree) || !sID.CmpNoCase(SG_T("merc")) ) // Mercator { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 0.0); } if( !sID.CmpNoCase(SG_T("utm")) ) // Universal Transverse Mercator (UTM) { PRM_ADD_INT("zone" , _TL("Zone") , 32); PRM_ADD_BOL("south" , _TL("South") , false); } if( !sID.CmpNoCase(SG_T("omerc")) ) // Oblique Mercator { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1" ) ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 50.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2" ) , 20.0); } //----------------------------------------------------- // Pseudocylindrical Projections... if( !sID.CmpNoCase(SG_T("gn_sinu")) ) // General Sinusoidal Series { PRM_ADD_FLT("m" , SG_T("m") , 0.5); PRM_ADD_FLT("n" , SG_T("n") , 1.0 + M_PI_045); } if( !sID.CmpNoCase(SG_T("loxim")) ) // Loximuthal { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } if( !sID.CmpNoCase(SG_T("urmfps")) ) // Urmaev Flat-Polar Sinusoidal { PRM_ADD_FLT("n" , SG_T("n") , 1.0); } if( !sID.CmpNoCase(SG_T("urm5")) ) // Urmaev V { PRM_ADD_FLT("n" , SG_T("n") , 1.0); PRM_ADD_FLT("q" , SG_T("q") , 1.0); PRM_ADD_FLT("alphi" , SG_T("alphi") , 45.0); } if( !sID.CmpNoCase(SG_T("wink1")) // Winkel I || !sID.CmpNoCase(SG_T("wag3")) ) // Wagner III { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("wink2")) ) // Winkel II { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } //----------------------------------------------------- // Conic Projections... if( !sID.CmpNoCase(SG_T("aea")) // Albers Equal Area || !sID.CmpNoCase(SG_T("eqdc")) // Equidistant Conic || !sID.CmpNoCase(SG_T("euler")) // Euler || !sID.CmpNoCase(SG_T("imw_p")) // International Map of the World Polyconic || !sID.CmpNoCase(SG_T("murd1")) // Murdoch I || !sID.CmpNoCase(SG_T("murd2")) // Murdoch II || !sID.CmpNoCase(SG_T("murd3")) // Murdoch III || !sID.CmpNoCase(SG_T("pconic")) // Perspective Conic || !sID.CmpNoCase(SG_T("tissot")) // Tissot || !sID.CmpNoCase(SG_T("vitk1")) ) // Vitkovsky I { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); } if( !sID.CmpNoCase(SG_T("lcc")) ) // Lambert Conformal Conic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); } if( !sID.CmpNoCase(SG_T("leac")) ) // Lambert Equal Area Conic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 45.0); PRM_ADD_BOL("south" , _TL("South") , false); } if( !sID.CmpNoCase(SG_T("rpoly")) ) // Rectangular Polyconic { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("mpoly")) ) // Modified Polyconic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); PRM_ADD_BOL("lotsa" , _TL("Lotsa") , true); } if( !sID.CmpNoCase(SG_T("bonne")) ) // Bonne { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 45.0); } //----------------------------------------------------- // Azimuthal Projections... if( !sID.CmpNoCase(SG_T("stere")) ) // Stereographic { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("ups")) ) // Universal Polar Stereographic { PRM_ADD_BOL("south" , _TL("South") , true); } if( !sID.CmpNoCase(SG_T("airy")) ) // Airy { PRM_ADD_FLT("lat_b" , _TL("Latitude B") , 45.0); PRM_ADD_BOL("no_cut" , _TL("No Cut") , true); } if( !sID.CmpNoCase(SG_T("nsper")) ) // Near-sided perspective { PRM_ADD_FLT("h" , _TL("Height of view point") , 1.0); } if( !sID.CmpNoCase(SG_T("aeqd")) ) // Azimuthal Equidistant { PRM_ADD_BOL("guam" , _TL("guam") , true); } if( !sID.CmpNoCase(SG_T("hammer")) ) // Hammer & Eckert-Greifendorff { PRM_ADD_FLT("W" , _TL("W") , 0.5); PRM_ADD_FLT("M" , _TL("M") , 1.0); } if( !sID.CmpNoCase(SG_T("wintri")) ) // Winkel Tripel { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } //----------------------------------------------------- // Miscellaneous Projections... if( !sID.CmpNoCase(SG_T("ocea")) // Oblique Cylindrical Equal Area || !sID.CmpNoCase(SG_T("tpeqd")) ) // Two Point Equidistant { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1") ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 50.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2" ) , 20.0); } if( !sID.CmpNoCase(SG_T("geos")) ) // Geostationary Satellite View { PRM_ADD_FLT("h" , _TL("Satellite Height [m]") , 35785831.0); PRM_ADD_CHO("sweep" , _TL("Sweep Angle") , "x|y|"); } if( !sID.CmpNoCase(SG_T("lsat")) ) // Space oblique for LANDSAT { PRM_ADD_INT("lsat" , _TL("Landsat Satellite (1-5)"), 1.0); PRM_ADD_INT("path" , _TL("Path (1-255/233 1-3/4-5"), 1.0); } if( !sID.CmpNoCase(SG_T("labrd")) ) // Laborde { PRM_ADD_FLT("azi" , _TL("Azimuth" ) , 19.0); } if( !sID.CmpNoCase(SG_T("lagrng")) ) // Lagrange { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 0.0); PRM_ADD_FLT("W" , _TL("W") , 2.0); } if( !sID.CmpNoCase(SG_T("chamb")) ) // Chamberlin Trimetric { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 30.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1" ) ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 40.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2") , 00.0); PRM_ADD_FLT("lat_3" , _TL("Latitude 3") , 50.0); PRM_ADD_FLT("lon_3" , _TL("Longitude 3" ) , 20.0); } if( !sID.CmpNoCase(SG_T("oea")) ) // Oblated Equal Area { PRM_ADD_FLT("m" , _TL("m") , 1.0); PRM_ADD_FLT("n" , _TL("n") , 1.0); PRM_ADD_FLT("theta" , _TL("theta") , 45.0); } if( !sID.CmpNoCase(SG_T("tpers")) ) // Tilted perspective { PRM_ADD_FLT("tilt" , _TL("Tilt") , 45.0); PRM_ADD_FLT("azi" , _TL("Azimuth") , 45.0); PRM_ADD_FLT("h" , _TL("h") , 1000.0); } if( !sID.CmpNoCase(SG_T("ob_tran")) ) // General Oblique Transformation { PRM_ADD_FLT("o_lat_p" , _TL("Latitude Pole") , 40.0); PRM_ADD_FLT("o_lon_p" , _TL("Longitude Pole") , 40.0); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PROJ4_ADD_BOL(key, val) if( val ) Proj4 += CSG_String::Format(SG_T("+%s "), CSG_String(key).c_str()); #define PROJ4_ADD_INT(key, val) Proj4 += CSG_String::Format(SG_T("+%s=%d "), CSG_String(key).c_str(), val); #define PROJ4_ADD_FLT(key, val) Proj4 += CSG_String::Format(SG_T("+%s=%s "), CSG_String(key).c_str(), SG_Get_String(val, -32).c_str()); #define PROJ4_ADD_STR(key, val) Proj4 += CSG_String::Format(SG_T("+%s=%s "), CSG_String(key).c_str(), CSG_String(val).c_str()); //--------------------------------------------------------- CSG_String CCRS_Base::Get_User_Definition(CSG_Parameters &P) { CSG_String Proj4; //----------------------------------------------------- PROJ4_ADD_STR("proj" , pj_list[P("PROJ_TYPE")->asInt()].id); if( P("LON_0")->asDouble() ) PROJ4_ADD_FLT("lon_0", P("LON_0")->asDouble()); if( P("LAT_0")->asDouble() ) PROJ4_ADD_FLT("lat_0", P("LAT_0")->asDouble()); if( P("X_0" )->asDouble() ) PROJ4_ADD_FLT("x_0" , P("X_0" )->asDouble()); if( P("Y_0" )->asDouble() ) PROJ4_ADD_FLT("y_0" , P("Y_0" )->asDouble()); if( P("K_0")->asDouble() != 1.0 && P("K_0")->asDouble() > 0.0 ) { PROJ4_ADD_FLT("k_0", P("K_0")->asDouble()); } PROJ4_ADD_STR("units", pj_units[P("UNIT")->asInt()].id); //----------------------------------------------------- switch( P("DATUM_DEF")->asInt() ) { case 0: // predefined datum PROJ4_ADD_STR("datum", pj_datums[P("DATUM")->asInt()].id); break; //----------------------------------------------------- case 1: // user defined datum switch( P("ELLIPSOID")->asInt() ) { case 0: // Predefined Ellipsoid PROJ4_ADD_STR("ellps", pj_ellps[P("ELLPS_DEF")->asInt()].id); break; case 1: // Semiminor axis PROJ4_ADD_FLT("a" , P("ELLPS_A" )->asDouble()); PROJ4_ADD_FLT("b" , P("ELLPS_B" )->asDouble()); break; case 2: // Flattening PROJ4_ADD_FLT("a" , P("ELLPS_A" )->asDouble()); PROJ4_ADD_FLT("f" , P("ELLPS_F" )->asDouble()); break; case 3: // Reciprocal Flattening PROJ4_ADD_FLT("a" , P("ELLPS_A" )->asDouble()); PROJ4_ADD_FLT("rf" , P("ELLPS_RF")->asDouble()); break; case 4: // Eccentricity PROJ4_ADD_FLT("a" , P("ELLPS_A" )->asDouble()); PROJ4_ADD_FLT("e" , P("ELLPS_E" )->asDouble()); break; case 5: // Eccentricity Squared PROJ4_ADD_FLT("a" , P("ELLPS_A" )->asDouble()); PROJ4_ADD_FLT("es" , P("ELLPS_ES")->asDouble()); break; } switch( P("DATUM_SHIFT")->asInt() ) { case 1: // 3 parameters PROJ4_ADD_STR("towgs84", CSG_String::Format(SG_T("%s,%s,%s"), SG_Get_String(P("DS_DX")->asDouble(), -32).c_str(), SG_Get_String(P("DS_DY")->asDouble(), -32).c_str(), SG_Get_String(P("DS_DZ")->asDouble(), -32).c_str()) ); break; case 2: // 7 parameters PROJ4_ADD_STR("towgs84", CSG_String::Format(SG_T("%s,%s,%s,%s,%s,%s,%s"), SG_Get_String(P("DS_DX")->asDouble(), -32).c_str(), SG_Get_String(P("DS_DY")->asDouble(), -32).c_str(), SG_Get_String(P("DS_DZ")->asDouble(), -32).c_str(), SG_Get_String(P("DS_RX")->asDouble(), -32).c_str(), SG_Get_String(P("DS_RY")->asDouble(), -32).c_str(), SG_Get_String(P("DS_RZ")->asDouble(), -32).c_str(), SG_Get_String(P("DS_SC")->asDouble(), -32).c_str()) ); break; case 3: // datum shift grid... if( SG_File_Exists(P("DATUM_GRID")->asString()) ) { PROJ4_ADD_STR("nadgrids", P("DATUM_GRID")->asString()); } break; } break; } //----------------------------------------------------- for(int i=0; iasParameters()->Get_Count(); i++) { CSG_Parameter *p = P("OPTIONS")->asParameters()->Get_Parameter(i); switch( p->Get_Type() ) { case PARAMETER_TYPE_Choice: case PARAMETER_TYPE_String: PROJ4_ADD_STR(p->Get_Identifier(), p->asString()); break; case PARAMETER_TYPE_Bool: PROJ4_ADD_BOL(p->Get_Identifier(), p->asBool ()); break; case PARAMETER_TYPE_Int: PROJ4_ADD_INT(p->Get_Identifier(), p->asInt ()); break; case PARAMETER_TYPE_Double: PROJ4_ADD_FLT(p->Get_Identifier(), p->asDouble()); break; } } //----------------------------------------------------- PROJ4_ADD_BOL("no_defs", P("NO_DEFS")->asBool()); PROJ4_ADD_BOL("over" , P("OVER" )->asBool()); return( Proj4 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define _K(key) (CSG_String("+") + key) #define PROJ4_HAS_KEY(key) (Proj4.Find(_K(key)) >= 0) #define PROJ4_HAS_VAL(key) (Proj4.Find(_K(key)) >= 0 && !Proj4.Right(Proj4.Length() - Proj4.Find(_K(key))).BeforeFirst('=').Cmp(_K(key))) #define PROJ4_GET_VAL(key) (Proj4.Right(PROJ4_HAS_VAL(key) ? Proj4.Length() - Proj4.Find(_K(key)) : 0).AfterFirst('=').BeforeFirst(' ')) #define PROJ4_SET_BOL(key, id) { if( P(id) ) P(id)->Set_Value(PROJ4_HAS_KEY(key) ? 1 : 0); } #define PROJ4_SET_INT(key, id) { int val; if( P(id) && PROJ4_GET_VAL(key).asInt (val) ) P(id)->Set_Value(val); } #define PROJ4_SET_FLT(key, id) { double val; if( P(id) && PROJ4_GET_VAL(key).asDouble(val) ) P(id)->Set_Value(val); } #define PROJ4_SET_STR(key, id) { if( P(id) && PROJ4_HAS_VAL(key) ) P(id)->Set_Value(PROJ4_GET_VAL(key)); } #define PROJ4_SET_CHC(key, id) if( P(id) ) { CSG_Parameter_Choice *pList = P(id)->asChoice(); CSG_String s(PROJ4_GET_VAL(key));\ for(int i=0; iGet_Count(); i++)\ {\ if( !pList->Get_Item_Data(i).Cmp(s) )\ {\ P(id)->Set_Value(i); break;\ }\ }\ } //--------------------------------------------------------- bool CCRS_Base::Set_User_Definition(CSG_Parameters &P, const CSG_String &Proj4) { P.Restore_Defaults(); PROJ4_SET_CHC("proj" , "PROJ_TYPE"); PROJ4_SET_CHC("datum", "DATUM" ); PROJ4_SET_CHC("ellps", "ELLPS_DEF"); PROJ4_SET_CHC("units", "UNIT" ); PROJ4_SET_FLT("lon_0", "LON_0" ); PROJ4_SET_FLT("lat_0", "LAT_0" ); PROJ4_SET_FLT("x_0" , "X_0" ); PROJ4_SET_FLT("y_0" , "Y_0" ); PROJ4_SET_FLT("k_0" , "K_0" ); PROJ4_SET_FLT("a" , "ELLPS_A" ); PROJ4_SET_FLT("b" , "ELLPS_B" ); PROJ4_SET_FLT("f" , "ELLPS_F" ); PROJ4_SET_FLT("rf" , "ELLPS_RF" ); PROJ4_SET_FLT("e" , "ELLPS_E" ); PROJ4_SET_FLT("es" , "ELLPS_ES" ); PROJ4_SET_BOL("no_defs", "NO_DEFS"); PROJ4_SET_BOL("over" , "OVER" ); //----------------------------------------------------- // switch( P("DATUM_DEF")->asInt() ) if( PROJ4_HAS_VAL("datum") ) P("DATUM_DEF")->Set_Value(0); // case 0: // predefined datum else P("DATUM_DEF")->Set_Value(1); // case 1: // user defined datum // switch( P("ELLIPSOID")->asInt() ) if( PROJ4_HAS_VAL("ellps") ) P("ELLIPSOID")->Set_Value(0); // case 0: // Predefined Ellipsoid if( PROJ4_HAS_VAL("b" ) ) P("ELLIPSOID")->Set_Value(1); // case 1: // Semiminor axis if( PROJ4_HAS_VAL("f" ) ) P("ELLIPSOID")->Set_Value(2); // case 2: // Flattening if( PROJ4_HAS_VAL("rf" ) ) P("ELLIPSOID")->Set_Value(3); // case 3: // Reciprocal Flattening if( PROJ4_HAS_VAL("e" ) ) P("ELLIPSOID")->Set_Value(4); // case 4: // Eccentricity if( PROJ4_HAS_VAL("es" ) ) P("ELLIPSOID")->Set_Value(5); // case 5: // Eccentricity Squared // switch( P("DATUM_SHIFT")->asInt() ) CSG_String_Tokenizer params(PROJ4_GET_VAL("towgs84"), ", "); if( params.Get_Tokens_Count() == 3 || params.Get_Tokens_Count() == 7 ) { P("DATUM_SHIFT")->Set_Value(1); // case 1: // 3 parameters P("DS_DX")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_DY")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_DZ")->Set_Value(params.Get_Next_Token().asDouble()); } else if( params.Get_Tokens_Count() == 7 ) { P("DATUM_SHIFT")->Set_Value(2); // case 2: // 7 parameters P("DS_DX")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_DY")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_DZ")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_RX")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_RY")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_RZ")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_SC")->Set_Value(params.Get_Next_Token().asDouble()); } else if( PROJ4_HAS_VAL("nadgrids") && SG_File_Exists(PROJ4_GET_VAL("nadgrids")) ) { P("DATUM_SHIFT")->Set_Value(3); // case 3: // datum shift grid... PROJ4_SET_STR("nadgrids", "DATUM_GRID"); } else { P("DATUM_SHIFT")->Set_Value(0); // case 0: // none } //----------------------------------------------------- P("OPTIONS")->asParameters()->Assign(Get_Parameters(SG_STR_MBTOSG(pj_list[P("PROJ_TYPE")->asInt()].id))); for(int i=0; iasParameters()->Get_Count(); i++) { CSG_Parameter *p = P("OPTIONS")->asParameters()->Get_Parameter(i); switch( p->Get_Type() ) { case PARAMETER_TYPE_Choice: case PARAMETER_TYPE_String: p->Set_Value(PROJ4_GET_VAL(p->Get_Identifier()) ); break; case PARAMETER_TYPE_Bool: p->Set_Value(PROJ4_HAS_KEY(p->Get_Identifier()) ? 1 : 0 ); break; case PARAMETER_TYPE_Int: p->Set_Value(PROJ4_GET_VAL(p->Get_Identifier()).asInt ()); break; case PARAMETER_TYPE_Double: p->Set_Value(PROJ4_GET_VAL(p->Get_Identifier()).asDouble()); break; } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Picker::CCRS_Picker(void) { //----------------------------------------------------- Set_Name (_TL("Coordinate Reference System Picker")); Set_Author (SG_T("O.Conrad (c) 2014")); Set_Description (_TW( "Define or pick a Coordinate Reference System (CRS). " "It is intended to call this tool only from other tools." )); } //--------------------------------------------------------- bool CCRS_Picker::On_Execute(void) { CSG_Projection Target; if( !Get_Projection(Target) ) { return( false ); } Message_Add(CSG_String::Format(SG_T("\n%s: %s"), _TL("target"), Target.Get_Proj4().c_str()), false); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform::On_Execute(void) { //----------------------------------------------------- CSG_Projection Target; if( !Get_Projection(Target) || !m_Projector.Set_Target(Target) ) { return( false ); } Message_Add(CSG_String::Format(SG_T("\n%s: %s"), _TL("target"), Target.Get_Proj4().c_str()), false); //----------------------------------------------------- m_Projector.Set_Precise_Mode(Parameters("PRECISE") && Parameters("PRECISE")->asBool()); bool bResult = On_Execute_Transformation(); m_Projector.Destroy(); return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_proj4/PROJ4_Base.h0000664000175000017500000001241412565125415023702 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: PROJ4_Base.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Base.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PROJ4_Base_H #define HEADER_INCLUDED__PROJ4_Base_H //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { PROJ4_INTERFACE_SIMPLE = 0, PROJ4_INTERFACE_DIALOG }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CPROJ4_Base : public CSG_Module { public: CPROJ4_Base(int Interface, bool bInputList); virtual bool do_Sync_Projections (void) { return( false ); } 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 (bool bDestination = true); bool Get_Converted (double &x, double &y); bool Get_Converted (TSG_Point &Point); private: bool m_bInverse; int m_Interface; PJ *m_pPrjSrc, *m_pPrjDst; bool _Get_Projections (CSG_String &sPrjSrc, CSG_String &sPrjDst); bool _Get_Projection (CSG_String &sPrj, CSG_Parameters &P); bool _Init_Projection (CSG_Parameters &P); bool _Init_Projection (const CSG_String &sID, const CSG_String &sName, const CSG_String &sArgs); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PROJ4_Base_H saga-2.2.3/src/modules/projection/pj_georeference/0000775000175000017500000000000012634325745023337 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/projection/pj_georeference/Collect_Points.cpp0000664000175000017500000002257612565125415026773 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Collect_Points.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Collect_Points.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Collect_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCollect_Points::CCollect_Points(void) { //----------------------------------------------------- Set_Name (_TL("Create Reference Points")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Digitize reference points for georeferencing grids, images and shapes. " "Click with the mouse on known locations in the map window " "and add the reference coordinates. " "After choosing 4 or more points, stop the interactive module execution " "by unchecking it in the in the modules menu." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "REF_SOURCE" , _TL("Reference Points (Origin)"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "REF_TARGET" , _TL("Reference Points (Projection)"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), GEOREF_METHODS_CHOICE, 0 ); Parameters.Add_Value( NULL , "ORDER" ,_TL("Polynomial Order"), _TL(""), PARAMETER_TYPE_Int, 3, 1, true ); Parameters.Add_Value( NULL , "REFRESH" , _TL("Clear Reference Points"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- CSG_Parameters *pParameters = Add_Parameters("REFERENCE", _TL("Point Position"), _TL("")); pParameters->Add_Value( NULL , "X" , _TL("x Position"), _TL(""), PARAMETER_TYPE_Double ); pParameters->Add_Value( NULL , "Y" , _TL("y Position"), _TL(""), PARAMETER_TYPE_Double ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCollect_Points::is_Compatible(CSG_Shapes *pPoints) { return( pPoints != DATAOBJECT_NOTSET && pPoints != DATAOBJECT_CREATE && pPoints->Get_Count() > 0 && pPoints->Get_Field_Count() >= 5 ); } //--------------------------------------------------------- int CCollect_Points::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("ORDER", pParameter->asInt() == GEOREF_Polynomial); // only show for polynomial, user defined order } if( !SG_STR_CMP(pParameter->Get_Identifier(), "REF_SOURCE") ) { pParameters->Get_Parameter("REFRESH")->Set_Enabled(is_Compatible(pParameter->asShapes())); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCollect_Points::On_Execute(void) { m_Engine.Destroy(); m_pPoints = Parameters("REF_SOURCE")->asShapes(); Get_Parameters("REFERENCE")->Restore_Defaults(); if( !is_Compatible(m_pPoints) || Parameters("REFRESH")->asBool() ) { m_pPoints->Create(SHAPE_TYPE_Point, _TL("Reference Points (Origin)")); m_pPoints->Add_Field("X_SRC", SG_DATATYPE_Double); m_pPoints->Add_Field("Y_SRC", SG_DATATYPE_Double); m_pPoints->Add_Field("X_MAP", SG_DATATYPE_Double); m_pPoints->Add_Field("Y_MAP", SG_DATATYPE_Double); m_pPoints->Add_Field("RESID", SG_DATATYPE_Double); } else { for(int i=0; iGet_Count(); i++) { CSG_Shape *pPoint = m_pPoints->Get_Shape(i); m_Engine.Add_Reference(pPoint->Get_Point(0), CSG_Point( pPoint->asDouble(2), pPoint->asDouble(3) )); } int Method = Parameters("METHOD")->asInt(); int Order = Parameters("ORDER" )->asInt(); m_Engine.Evaluate(Method, Order); } return( true ); } //--------------------------------------------------------- bool CCollect_Points::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { if( Mode == MODULE_INTERACTIVE_LUP ) { TSG_Point ptTarget; if( m_Engine.Get_Converted(ptTarget = ptWorld) ) { Get_Parameters("REFERENCE")->Get_Parameter("X")->Set_Value(ptTarget.x); Get_Parameters("REFERENCE")->Get_Parameter("Y")->Set_Value(ptTarget.y); } if( Dlg_Parameters("REFERENCE") ) { int Method = Parameters("METHOD")->asInt(); int Order = Parameters("ORDER" )->asInt(); CSG_Shape *pPoint = m_pPoints->Add_Shape(); pPoint->Add_Point(ptWorld); pPoint->Set_Value(0, ptWorld.Get_X()); pPoint->Set_Value(1, ptWorld.Get_Y()); pPoint->Set_Value(2, ptTarget.x = Get_Parameters("REFERENCE")->Get_Parameter("X")->asDouble()); pPoint->Set_Value(3, ptTarget.y = Get_Parameters("REFERENCE")->Get_Parameter("Y")->asDouble()); if( m_Engine.Add_Reference(ptWorld, ptTarget) && m_Engine.Evaluate(Method, Order) && m_pPoints->Get_Count() == m_Engine.Get_Reference_Count() ) { for(int i=0; iGet_Count(); i++) { m_pPoints->Get_Shape(i)->Set_Value(4, m_Engine.Get_Reference_Residual(i)); } } DataObject_Update(m_pPoints); } } return( true ); } //--------------------------------------------------------- bool CCollect_Points::On_Execute_Finish(void) { CSG_Shapes *pTarget = Parameters("REF_TARGET")->asShapes(); if( pTarget != NULL ) { pTarget->Create(SHAPE_TYPE_Point, _TL("Reference Points (Projection)")); pTarget->Add_Field("X_SRC", SG_DATATYPE_Double); pTarget->Add_Field("Y_SRC", SG_DATATYPE_Double); pTarget->Add_Field("X_MAP", SG_DATATYPE_Double); pTarget->Add_Field("Y_MAP", SG_DATATYPE_Double); pTarget->Add_Field("RESID", SG_DATATYPE_Double); for(int iPoint=0; iPointGet_Count(); iPoint++) { CSG_Shape *pPoint = pTarget->Add_Shape(m_pPoints->Get_Shape(iPoint), SHAPE_COPY_ATTR); pPoint->Add_Point( pPoint->asDouble(2), pPoint->asDouble(3) ); } } m_Engine.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_georeference/direct_georeferencing.cpp0000664000175000017500000005026212565125415030357 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: direct_georeferencing.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // georeferencing // // // //-------------------------------------------------------// // // // direct_georeferencing.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "direct_georeferencing.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Direct_Georeferencer::CSG_Direct_Georeferencer(void) {} /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Direct_Georeferencer::Add_Parameters(CSG_Parameters &Parameters) { CSG_Parameter *pNode; //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "NODE_POS" , _TL("Position"), _TL("") ); Parameters.Add_Value( pNode , "X" , _TL("X"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "Y" , _TL("Y"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "Z" , _TL("Flying Height"), _TL(""), PARAMETER_TYPE_Double , 1000.0 ); //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "NODE_DIR" , _TL("Orientation"), _TL("") ); Parameters.Add_Choice( pNode , "ORIENTATION" , _TL("Orientation"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("BLUH"), _TL("PATB") ), 0 ); Parameters.Add_Value( pNode , "OMEGA" , _TL("Omega [degree]"), _TL("rotation around the X axis (roll)"), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "PHI" , _TL("Phi [degree]"), _TL("rotation around the Y axis (pitch)"), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "KAPPA" , _TL("Kappa [degree]"), _TL("rotation around the Z axis (heading)"), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "KAPPA_OFF" , _TL("Kappa Offset [degree]"), _TL("origin adjustment for Z axis (heading)"), PARAMETER_TYPE_Double , 90.0 ); //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "NODE_CAMERA" , _TL("Camera"), _TL("") ); Parameters.Add_Value( pNode , "CFL" , _TL("Focal Length [mm]"), _TL(""), PARAMETER_TYPE_Double , 80, 0.0, true ); Parameters.Add_Value( pNode , "PXSIZE" , _TL("CCD Physical Pixel Size [micron]"), _TL(""), PARAMETER_TYPE_Double , 5.2, 0.0, true ); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Direct_Georeferencer::Set_Transformation(CSG_Parameters &Parameters, int nCols, int nRows) { //----------------------------------------------------- m_O.Create(2); m_O[0] = nCols / 2.0; m_O[1] = nRows / 2.0; m_f = Parameters("CFL" )->asDouble() / 1000; // [mm] -> [m] m_s = Parameters("PXSIZE")->asDouble() / 1000000; // [micron] -> [m] //----------------------------------------------------- m_T.Create(3); m_T[0] = Parameters("X")->asDouble(); m_T[1] = Parameters("Y")->asDouble(); m_T[2] = Parameters("Z")->asDouble(); //----------------------------------------------------- double a; CSG_Matrix Rx(3, 3), Ry(3, 3), Rz(3, 3); a = Parameters("OMEGA")->asDouble() * M_DEG_TO_RAD; Rx[0][0] = 1; Rx[0][1] = 0; Rx[0][2] = 0; Rx[1][0] = 0; Rx[1][1] = cos(a); Rx[1][2] = -sin(a); Rx[2][0] = 0; Rx[2][1] = sin(a); Rx[2][2] = cos(a); a = Parameters("PHI" )->asDouble() * M_DEG_TO_RAD; Ry[0][0] = cos(a); Ry[0][1] = 0; Ry[0][2] = sin(a); Ry[1][0] = 0; Ry[1][1] = 1; Ry[1][2] = 0; Ry[2][0] = -sin(a); Ry[2][1] = 0; Ry[2][2] = cos(a); a = Parameters("KAPPA")->asDouble() * M_DEG_TO_RAD + Parameters("KAPPA_OFF")->asDouble() * M_DEG_TO_RAD; Rz[0][0] = cos(a); Rz[0][1] = -sin(a); Rz[0][2] = 0; Rz[1][0] = sin(a); Rz[1][1] = cos(a); Rz[1][2] = 0; Rz[2][0] = 0; Rz[2][1] = 0; Rz[2][2] = 1; switch( Parameters("ORIENTATION")->asInt() ) { case 0: default: m_R = Rz * Rx * Ry; break; // BLUH case 1: m_R = Rx * Ry * Rz; break; // PATB } m_Rinv = m_R.Get_Inverse(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline TSG_Point CSG_Direct_Georeferencer::World_to_Image(double x_w, double y_w, double z_w) { TSG_Point p; CSG_Vector Pw(3), Pc; Pw[0] = x_w; Pw[1] = y_w; Pw[2] = z_w; Pc = m_Rinv * (Pw - m_T); p.x = m_O[0] - (m_f / m_s) * (Pc[0] / Pc[2]); p.y = m_O[1] - (m_f / m_s) * (Pc[1] / Pc[2]); return( p ); } //--------------------------------------------------------- inline TSG_Point CSG_Direct_Georeferencer::Image_to_World(double x_i, double y_i, double z_w) { double k; TSG_Point p; CSG_Vector Pc(3), Pw; Pc[0] = (m_O[0] - x_i) * m_s; Pc[1] = (m_O[1] - y_i) * m_s; Pc[2] = m_f; Pw = m_R * Pc; k = (z_w - m_T[2]) / Pw[2]; p.x = m_T[0] + k * Pw[0]; p.y = m_T[1] + k * Pw[1]; return( p ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDirect_Georeferencing::CDirect_Georeferencing(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Direct Georeferencing of Airborne Photographs")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Direct georeferencing of aerial photographs uses extrinsic " "(position, attitude) and intrinsic (focal length, physical " "pixel size) camera parameters. Orthorectification routine supports " "additional data from a Digital Elevation Model (DEM).\n" "\nReferences:\n" "Baumker, M. / Heimes, F.J. (2001): " "New Calibration and Computing Method for Direct Georeferencing of Image and Scanner Data Using the Position and Angular Data of an Hybrid Inertial Navigation System. " "OEEPE Workshop, Integrated Sensor Orientation, Hannover 2001. " "online.\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "INPUT" , _TL("Unreferenced Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "OUTPUT" , _TL("Referenced Grids"), _TL(""), PARAMETER_OUTPUT, false ); Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); //----------------------------------------------------- pNode = Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT_OPTIONAL, false ); Parameters.Add_Value( pNode , "ZREF" , _TL("Default Reference Height"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); //----------------------------------------------------- m_Georeferencer.Add_Parameters(Parameters); //----------------------------------------------------- Parameters.Add_Choice( NULL , "INTERPOLATION" , _TL("Interpolation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("Nearest Neigbhor"), _TL("Bilinear Interpolation"), _TL("Inverse Distance Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 4 ); Parameters.Add_Choice( NULL , "DATA_TYPE" , _TL("Data Storage Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("1 byte unsigned integer"), _TL("1 byte signed integer"), _TL("2 byte unsigned integer"), _TL("2 byte signed integer"), _TL("4 byte unsigned integer"), _TL("4 byte signed integer"), _TL("4 byte floating point"), _TL("8 byte floating point"), _TL("same as original") ), 8 ); Parameters.Add_Choice( NULL , "ROW_ORDER" , _TL("Row Order"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("top down"), _TL("bottom up") ), 0 ); //----------------------------------------------------- m_Grid_Target.Create(Add_Parameters("TARGET", _TL("Target Grid System"), _TL("")), false); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CDirect_Georeferencing::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CDirect_Georeferencing::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( m_Grid_Target.On_Parameters_Enable(pParameters, pParameter) ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDirect_Georeferencing::On_Execute(void) { //----------------------------------------------------- if( !m_Georeferencer.Set_Transformation(Parameters, Get_NX(), Get_NY()) ) { return( false ); } //----------------------------------------------------- CSG_Grid *pDEM = Parameters("DEM" )->asGrid(); double zRef = Parameters("ZREF" )->asDouble(); int Interpolation = Parameters("INTERPOLATION")->asInt(); bool bFlip = Parameters("ROW_ORDER" )->asInt() == 1; //----------------------------------------------------- TSG_Point p[4]; p[0] = m_Georeferencer.Image_to_World( 0, 0, zRef); p[1] = m_Georeferencer.Image_to_World(Get_NX(), 0, zRef); p[2] = m_Georeferencer.Image_to_World(Get_NX(), Get_NY(), zRef); p[3] = m_Georeferencer.Image_to_World( 0, Get_NY(), zRef); CSG_Rect r(p[0], p[1]); r.Union(p[2]); r.Union(p[3]); //----------------------------------------------------- CSG_Shapes *pShapes = Parameters("EXTENT")->asShapes(); if( pShapes ) { pShapes->Create(SHAPE_TYPE_Polygon, _TL("Extent")); pShapes->Add_Field(_TL("OID"), SG_DATATYPE_Int); CSG_Shape *pExtent = pShapes->Add_Shape(); pExtent->Add_Point(p[0]); pExtent->Add_Point(p[1]); pExtent->Add_Point(p[2]); pExtent->Add_Point(p[3]); } //----------------------------------------------------- double Cellsize = SG_Get_Distance(p[0], p[1]) / Get_NX(); CSG_Grid_System System(Cellsize, r); m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), r, Get_NX()); if( !Dlg_Parameters("TARGET") ) { return( false ); } System = m_Grid_Target.Get_System(); if( !System.is_Valid() ) { return( false ); } //----------------------------------------------------- CSG_Parameter_Grid_List *pInput = Parameters("INPUT" )->asGridList(); CSG_Parameter_Grid_List *pOutput = Parameters("OUTPUT")->asGridList(); pOutput->Del_Items(); if( pInput->Get_Count() <= 0 ) { return( false ); } else { TSG_Data_Type Type; switch( Parameters("DATA_TYPE")->asInt() ) { case 0: Type = SG_DATATYPE_Byte; break; case 1: Type = SG_DATATYPE_Char; break; case 2: Type = SG_DATATYPE_Word; break; case 3: Type = SG_DATATYPE_Short; break; case 4: Type = SG_DATATYPE_DWord; break; case 5: Type = SG_DATATYPE_Int; break; case 6: Type = SG_DATATYPE_Float; break; case 7: Type = SG_DATATYPE_Double; break; default: Type = SG_DATATYPE_Undefined; break; } for(int i=0; iGet_Count(); i++) { CSG_Grid *pGrid = SG_Create_Grid(System, Type != SG_DATATYPE_Undefined ? Type : pInput->asGrid(i)->Get_Type()); if( !pGrid || !pGrid->is_Valid() ) { if( pGrid ) { delete(pGrid); } return( false ); } pOutput->Add_Item(pGrid); pGrid->Set_Name(pInput->asGrid(i)->Get_Name()); } } //----------------------------------------------------- for(int y=0; yGet_Value(px, py, pz) ) { pz = zRef; } TSG_Point p = m_Georeferencer.World_to_Image(px, py, pz); if( bFlip ) { p.y = (Get_NY() - 1) - p.y; } for(int i=0; iGet_Count(); i++) { if( pInput->asGrid(i)->Get_Value(p.x, p.y, pz, Interpolation) ) { pOutput->asGrid(i)->Set_Value(x, y, pz); } else { pOutput->asGrid(i)->Set_NoData(x, y); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDirect_Georeferencing_WorldFile::CDirect_Georeferencing_WorldFile(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("World File from Flight and Camera Settings")); Set_Author (SG_T("O.Conrad (c) 2014")); Set_Description (_TW( "Creates a world file (RST = rotation, scaling, translation) " "for georeferencing images by direct georeferencing. " "Direct georeferencing uses extrinsic " "(position, attitude) and intrinsic (focal length, physical " "pixel size) camera parameters.\n" "\nReferences:\n" "Baumker, M. / Heimes, F.J. (2001): " "New Calibration and Computing Method for Direct Georeferencing of Image and Scanner Data Using the Position and Angular Data of an Hybrid Inertial Navigation System. " "OEEPE Workshop, Integrated Sensor Orientation, Hannover 2001. " "online.\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_FilePath( NULL , "FILE" , _TL("World File"), _TL(""), CSG_String::Format(SG_T("%s|*.*"), _TL("All Files")), NULL, true ); pNode = Parameters.Add_Node( NULL , "NODE_IMAGE" , _TL("Image Properties"), _TL("") ); Parameters.Add_Value( pNode , "NX" , _TL("Number of Columns"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Value( pNode , "NY" , _TL("Number of Columns"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); //----------------------------------------------------- m_Georeferencer.Add_Parameters(Parameters); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDirect_Georeferencing_WorldFile::On_Execute(void) { //----------------------------------------------------- int nx = Parameters("NX")->asInt(); int ny = Parameters("NY")->asInt(); if( !m_Georeferencer.Set_Transformation(Parameters, nx, ny) ) { return( false ); } //----------------------------------------------------- CSG_String File = Parameters("FILE")->asString(); if( File.is_Empty() ) { return( false ); } //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(File, SG_FILE_W, false) ) { return( false ); } //----------------------------------------------------- CSG_Matrix R(m_Georeferencer.Get_Transformation()); R *= 0.001 * Parameters("Z")->asDouble() / Parameters("CFL")->asDouble() * Parameters("PXSIZE")->asDouble(); TSG_Point p = m_Georeferencer.Image_to_World(0, ny); Stream.Printf(SG_T("%.10f\n%.10f\n%.10f\n%.10f\n%.10f\n%.10f\n"), R[0][0], // A: pixel size in the x-direction in map units/pixel R[1][0], // D: rotation about y-axis -R[0][1], // B: rotation about x-axis -R[1][1], // E: pixel size in the y-direction in map units, almost always negative p.x, // X: top left pixel center p.y // Y: top left pixel center ); //----------------------------------------------------- CSG_Shapes *pExtents = Parameters("EXTENT")->asShapes(); if( pExtents ) { pExtents->Create(SHAPE_TYPE_Polygon, SG_File_Get_Name(File, false)); pExtents->Add_Field(_TL("NAME"), SG_DATATYPE_String); CSG_Shape *pExtent = pExtents->Add_Shape(); p = m_Georeferencer.Image_to_World( 0, 0); pExtent->Add_Point(p.x, p.y); p = m_Georeferencer.Image_to_World( 0, ny); pExtent->Add_Point(p.x, p.y); p = m_Georeferencer.Image_to_World(nx, ny); pExtent->Add_Point(p.x, p.y); p = m_Georeferencer.Image_to_World(nx, 0); pExtent->Add_Point(p.x, p.y); pExtent->Set_Value(0, SG_File_Get_Name(File, false)); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_georeference/Georef_Shapes.h0000664000175000017500000001047412565125415026223 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Shapes.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Georef_Shapes.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Georef_Shapes_H #define HEADER_INCLUDED__Georef_Shapes_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGeoref_Shapes : public CSG_Module { public: CGeoref_Shapes(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Georef_Shapes_H saga-2.2.3/src/modules/projection/pj_georeference/Georef_Grid.h0000664000175000017500000001145312565125415025663 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Grid.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Georef_Grid.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Georef_Grid_H #define HEADER_INCLUDED__Georef_Grid_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Georef_Engine.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGeoref_Grid : public CSG_Module { public: CGeoref_Grid(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Parameters_Grid_Target m_Grid_Target; CGeoref_Engine m_Engine; bool Get_Conversion (void); bool Get_Target_Extent (CSG_Rect &Extent, bool bEdge); void Add_Target_Extent (CSG_Rect &Extent, double x, double y); bool Set_Grid (CSG_Grid *pGrid, CSG_Grid *pReferenced, int Interpolation); bool Set_Points (CSG_Grid *pGrid, CSG_Shapes *pReferenced); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Georef_Grid_H saga-2.2.3/src/modules/projection/pj_georeference/Georef_Shapes.cpp0000664000175000017500000001731412565125415026556 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Shapes.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Georef_Shapes.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Georef_Shapes.h" #include "Georef_Engine.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGeoref_Shapes::CGeoref_Shapes(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Warping Shapes")); Set_Author (SG_T("O.Conrad (c) 2006")); Set_Description (_TW( "Georeferencing of shapes layers. Either choose the attribute fields (x/y) " "with the projected coordinates for the reference points (origin) or supply a " "additional points layer with correspondend points in the target projection. " )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "REF_SOURCE" , _TL("Reference Points (Origin)"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "REF_TARGET" , _TL("Reference Points (Projection)"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Table_Field( pNode , "XFIELD" , _TL("x Position"), _TL("") ); Parameters.Add_Table_Field( pNode , "YFIELD" , _TL("y Position"), _TL("") ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), GEOREF_METHODS_CHOICE, 0 ); Parameters.Add_Value( NULL , "ORDER" ,_TL("Polynomial Order"), _TL(""), PARAMETER_TYPE_Int, 3, 1, true ); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGeoref_Shapes::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "REF_TARGET") ) { pParameters->Get_Parameter("XFIELD")->Set_Enabled(pParameter->asShapes() == NULL); pParameters->Get_Parameter("YFIELD")->Set_Enabled(pParameter->asShapes() == NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Get_Parameter("ORDER")->Set_Enabled(pParameter->asInt() == GEOREF_Polynomial); // only show for polynomial, user defined order } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Shapes::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pShapes_A = Parameters("REF_SOURCE")->asShapes(); CSG_Shapes *pShapes_B = Parameters("REF_TARGET")->asShapes(); int xField = Parameters("XFIELD")->asInt(); int yField = Parameters("YFIELD")->asInt(); int Method = Parameters("METHOD")->asInt(); int Order = Parameters("ORDER" )->asInt(); //----------------------------------------------------- CGeoref_Engine Engine; if( (pShapes_B != NULL && Engine.Set_Reference(pShapes_A, pShapes_B ) == false) ) { return( false ); } if( (pShapes_B == NULL && Engine.Set_Reference(pShapes_A, xField, yField) == false) ) { return( false ); } if( !Engine.Evaluate(Method, Order) ) { return( false ); } //--------------------------------------------------------- pShapes_A = Parameters("INPUT" )->asShapes(); pShapes_B = Parameters("OUTPUT")->asShapes(); pShapes_B ->Create(pShapes_A->Get_Type(), pShapes_A->Get_Name(), pShapes_A); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes_A->Get_Count()); iShape++) { CSG_Shape *pShape_A = pShapes_A->Get_Shape(iShape); CSG_Shape *pShape_B = pShapes_B->Add_Shape(pShape_A, SHAPE_COPY_ATTR); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point Point = pShape_A->Get_Point(iPoint, iPart); if( Engine.Get_Converted(Point) ) { pShape_B->Add_Point(Point); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_georeference/Collect_Points.h0000664000175000017500000001062312565125415026426 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Collect_Points.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Collect_Points.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Collect_Points_H #define HEADER_INCLUDED__Collect_Points_H //--------------------------------------------------------- #include "Georef_Engine.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCollect_Points : public CSG_Module_Interactive { public: CCollect_Points(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); virtual bool On_Execute_Finish (void); private: CSG_Shapes *m_pPoints; CGeoref_Engine m_Engine; bool is_Compatible (CSG_Shapes *pPoints); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Collect_Points_H saga-2.2.3/src/modules/projection/pj_georeference/georef_grid_move.h0000664000175000017500000001120612565125415027005 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: georef_grid_move.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Georeference // // // //-------------------------------------------------------// // // // Georef_Grid_Move.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Georef_Grid_Move_H #define HEADER_INCLUDED__Georef_Grid_Move_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGeoref_Grid_Move : public CSG_Module_Interactive { public: CGeoref_Grid_Move(void); virtual ~CGeoref_Grid_Move(void); protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); virtual bool On_Execute_Finish (void); private: bool m_bModified; CSG_Point m_Down, m_Move; CSG_Grid *m_pGrid, *m_pSource; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Georef_Grid_Move_H saga-2.2.3/src/modules/projection/pj_georeference/Georef_Grid.cpp0000664000175000017500000003363412565125415026223 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Grid.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Georef_Grid.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Georef_Grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGeoref_Grid::CGeoref_Grid(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Rectify Grid")); Set_Author (SG_T("O.Conrad (c) 2006")); Set_Description (_TW( "Georeferencing and rectification for grids. Either choose the attribute fields (x/y) " "with the projected coordinates for the reference points (origin) or supply a " "additional points layer with correspondend points in the target projection. " )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "REF_SOURCE" , _TL("Reference Points (Origin)"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "REF_TARGET" , _TL("Reference Points (Projection)"), _TL(""), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "XFIELD" , _TL("x Position"), _TL("") ); Parameters.Add_Table_Field( pNode , "YFIELD" , _TL("y Position"), _TL("") ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), GEOREF_METHODS_CHOICE, 0 ); Parameters.Add_Value( NULL , "ORDER" ,_TL("Polynomial Order"), _TL(""), PARAMETER_TYPE_Int, 3, 1, true ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Choice( NULL , "INTERPOLATION" , _TL("Interpolation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("nearest neigbhour"), _TL("bilinear"), _TL("inverse distance"), _TL("bicubic spline"), _TL("B-spline") ), 4 ); Parameters.Add_Value( NULL , "BYTEWISE" , _TL("Bytewise Interpolation"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- m_Grid_Target.Create(Add_Parameters("TARGET", _TL("Target Grid System"), _TL("")), true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGeoref_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "REF_SOURCE") && pParameter->asShapes() ) { pParameters->Get_Parameter("XFIELD")->Set_Value(pParameter->asShapes()->Get_Field("X_MAP")); pParameters->Get_Parameter("YFIELD")->Set_Value(pParameter->asShapes()->Get_Field("Y_MAP")); } return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CGeoref_Grid::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "REF_TARGET") ) { pParameters->Set_Enabled("XFIELD", pParameter->asShapes() == NULL); pParameters->Set_Enabled("YFIELD", pParameter->asShapes() == NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("ORDER", pParameter->asInt() == GEOREF_Polynomial); // only show for polynomial, user defined order } if( !SG_STR_CMP(pParameter->Get_Identifier(), "INTERPOLATION") ) { pParameters->Set_Enabled("BYTEWISE", pParameter->asInt() > 0); } return( m_Grid_Target.On_Parameters_Enable(pParameters, pParameter) ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pShapes_A = Parameters("REF_SOURCE")->asShapes(); CSG_Shapes *pShapes_B = Parameters("REF_TARGET")->asShapes(); int xField = Parameters("XFIELD")->asInt(); int yField = Parameters("YFIELD")->asInt(); //----------------------------------------------------- if( ( pShapes_B && m_Engine.Set_Reference(pShapes_A, pShapes_B)) || (!pShapes_B && m_Engine.Set_Reference(pShapes_A, xField, yField)) ) { int Method = Parameters("METHOD")->asInt(); int Order = Parameters("ORDER" )->asInt(); if( m_Engine.Evaluate(Method, Order) && Get_Conversion() ) { m_Engine.Destroy(); return( true ); } } //----------------------------------------------------- if( !m_Engine.Get_Error().is_Empty() ) { Error_Set(m_Engine.Get_Error()); } m_Engine.Destroy(); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid::Get_Conversion(void) { //----------------------------------------------------- CSG_Rect Extent; CSG_Grid *pSource = Parameters("GRID")->asGrid(); //----------------------------------------------------- if( !Get_Target_Extent(Extent, true) || !m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), Extent, pSource->Get_NY()) ) { Error_Set(_TL("failed to estimate target extent")); return( false ); } if( !Dlg_Parameters("TARGET") ) { return( false ); } //----------------------------------------------------- int Interpolation = Parameters("INTERPOLATION")->asInt(); CSG_Grid *pReferenced = m_Grid_Target.Get_Grid(Interpolation == 0 ? pSource->Get_Type() : SG_DATATYPE_Float); if( !pReferenced ) { Error_Set(_TL("failed to initialize target grid")); return( false ); } //----------------------------------------------------- if( !Set_Grid(pSource, pReferenced, Interpolation) ) { Error_Set(_TL("failed to project target grid")); return( false ); } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pSource, P) ) { DataObject_Add(pReferenced); DataObject_Set_Parameters(pReferenced, P); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid::Get_Target_Extent(CSG_Rect &Extent, bool bEdge) { if( Parameters("METHOD")->asInt() == GEOREF_Triangulation ) // triangulation { return( m_Engine.Get_Reference_Extent(Extent) ); } //----------------------------------------------------- CSG_Grid *pGrid = Parameters("GRID")->asGrid(); Extent.m_rect.xMin = Extent.m_rect.yMin = 1.0; Extent.m_rect.xMax = Extent.m_rect.yMax = 0.0; //----------------------------------------------------- if( bEdge ) { for(int y=0; yGet_NY(); y++) { Add_Target_Extent(Extent, pGrid->Get_XMin(), pGrid->Get_System().Get_yGrid_to_World(y)); Add_Target_Extent(Extent, pGrid->Get_XMax(), pGrid->Get_System().Get_yGrid_to_World(y)); } for(int x=0; xGet_NX(); x++) { Add_Target_Extent(Extent, pGrid->Get_System().Get_xGrid_to_World(x), pGrid->Get_YMin()); Add_Target_Extent(Extent, pGrid->Get_System().Get_xGrid_to_World(x), pGrid->Get_YMax()); } } //----------------------------------------------------- else { for(int y=0; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { if( !pGrid->is_NoData(x, y) ) { TSG_Point p = pGrid->Get_System().Get_Grid_to_World(x, y); Add_Target_Extent(Extent, p.x, p.y); } } } } return( is_Progress() && Extent.Get_XRange() > 0.0 && Extent.Get_YRange() > 0.0 ); } //--------------------------------------------------------- inline void CGeoref_Grid::Add_Target_Extent(CSG_Rect &Extent, double x, double y) { if( m_Engine.Get_Converted(x, y) ) { if( Extent.Get_XRange() >= 0.0 && Extent.Get_YRange() >= 0.0 ) { Extent.Union(CSG_Point(x, y)); } else { Extent.Assign(x, y, x, y); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid::Set_Grid(CSG_Grid *pGrid, CSG_Grid *pReferenced, int Interpolation) { if( !pGrid || !pReferenced || !m_Engine.is_Okay() ) { return( false ); } //----------------------------------------------------- bool bBytewise = Parameters("BYTEWISE")->asBool(); //----------------------------------------------------- pReferenced->Set_Name (pGrid->Get_Name()); pReferenced->Set_Unit (pGrid->Get_Unit()); pReferenced->Set_Scaling(pGrid->Get_Scaling(), pGrid->Get_Offset()); pReferenced->Set_NoData_Value_Range(pGrid->Get_NoData_Value(), pGrid->Get_NoData_hiValue()); pReferenced->Assign_NoData(); //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, pReferenced->Get_NY()); y++) { #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double z; TSG_Point p = pReferenced->Get_System().Get_Grid_to_World(x, y); if( m_Engine.Get_Converted(p, true) && pGrid->Get_Value(p, z, Interpolation, bBytewise) ) { pReferenced->Set_Value(x, y, z); } else { pReferenced->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGeoref_Grid::Set_Points(CSG_Grid *pGrid, CSG_Shapes *pReferenced) { if( !pGrid || !pReferenced || pReferenced->Get_Type() != SHAPE_TYPE_Point || !m_Engine.is_Okay() ) { return( false ); } //----------------------------------------------------- pReferenced->Create(SHAPE_TYPE_Point, pGrid->Get_Name()); pReferenced->Add_Field("Z", SG_DATATYPE_Double); //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { if( !pGrid->is_NoData(x, y) ) { TSG_Point Point = pGrid->Get_System().Get_Grid_to_World(x, y); if( m_Engine.Get_Converted(Point) ) { CSG_Shape *pPoint = pReferenced->Add_Shape(); pPoint->Add_Point(Point); pPoint->Set_Value(0, pGrid->asDouble(x, y)); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_georeference/Makefile.in0000664000175000017500000005612012622651170025377 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/projection/pj_georeference DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libpj_georeference_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libpj_georeference_la_OBJECTS = Collect_Points.lo \ direct_georeferencing.lo Georef_Engine.lo Georef_Grid.lo \ georef_grid_move.lo Georef_Shapes.lo MLB_Interface.lo \ set_grid_georeference.lo libpj_georeference_la_OBJECTS = $(am_libpj_georeference_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libpj_georeference_la_SOURCES) DIST_SOURCES = $(libpj_georeference_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1843 2013-09-18 10:49:15Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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 = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libpj_georeference.la libpj_georeference_la_SOURCES = \ Collect_Points.cpp\ direct_georeferencing.cpp\ Georef_Engine.cpp\ Georef_Grid.cpp\ georef_grid_move.cpp\ Georef_Shapes.cpp\ MLB_Interface.cpp\ set_grid_georeference.cpp\ Collect_Points.h\ direct_georeferencing.h\ Georef_Engine.h\ Georef_Grid.h\ georef_grid_move.h\ Georef_Shapes.h\ MLB_Interface.h\ set_grid_georeference.h libpj_georeference_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) --foreign src/modules/projection/pj_georeference/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/projection/pj_georeference/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libpj_georeference.la: $(libpj_georeference_la_OBJECTS) $(libpj_georeference_la_DEPENDENCIES) $(EXTRA_libpj_georeference_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libpj_georeference_la_OBJECTS) $(libpj_georeference_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Collect_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Georef_Engine.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Georef_Grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Georef_Shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/direct_georeferencing.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/georef_grid_move.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_grid_georeference.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/projection/pj_georeference/Georef_Engine.h0000664000175000017500000001511712565125415026204 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Engine.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Georef_Engine.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Georef_Engine_H #define HEADER_INCLUDED__Georef_Engine_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { GEOREF_NotSet, GEOREF_Triangulation, GEOREF_Spline, GEOREF_Affine, GEOREF_Polynomial_1st_Order, GEOREF_Polynomial_2nd_Order, GEOREF_Polynomial_3rd_Order, GEOREF_Polynomial }; //--------------------------------------------------------- #define GEOREF_METHODS_CHOICE CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|"),\ _TL("Automatic"),\ _TL("Triangulation"),\ _TL("Spline"),\ _TL("Affine"),\ _TL("1st Order Polynomial"),\ _TL("2nd Order Polynomial"),\ _TL("3rd Order Polynomial"),\ _TL("Polynomial, Order")\ ) /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGeoref_Engine { public: CGeoref_Engine(void); bool Destroy (void); bool Add_Reference (TSG_Point From, TSG_Point To); bool Add_Reference (double xFrom, double yFrom, double xTo, double yTo); bool Set_Reference (CSG_Shapes *pFrom, CSG_Shapes *pTo); bool Set_Reference (CSG_Shapes *pFrom, int xTo_Field, int yTo_Field); int Get_Reference_Count (void) { return( m_From.Get_Count() ); } bool Get_Reference_Extent (CSG_Rect &Extent, bool bInverse = false); double Get_Reference_Residual (int i); bool Set_Scaling (double Scaling); double Get_Scaling (void) { return( m_Scaling ); } bool Evaluate (int Method = GEOREF_NotSet, int Order = 1); bool is_Okay (void) { return( m_Method != GEOREF_NotSet ); } bool Get_Converted (TSG_Point &Point , bool bInverse = false); bool Get_Converted (double &x, double &y, bool bInverse = false); CSG_String Get_Error (void) { return( m_Error ); } private: int m_Method, m_Order; double m_Scaling; CSG_String m_Error; CSG_Rect m_rFrom, m_rTo; CSG_Points m_From, m_To; CSG_Vector m_Polynom_Fwd[2], m_Polynom_Inv[2]; CSG_Thin_Plate_Spline m_Spline_Fwd[2], m_Spline_Inv[2]; CSG_TIN m_TIN_Fwd, m_TIN_Inv; int _Get_Reference_Minimum (int Method, int Order); bool _Set_Triangulation (void); bool _Get_Triangulation (double &x, double &y, CSG_TIN *pTIN); bool _Set_Spline (void); bool _Get_Spline (double &x, double &y, CSG_Thin_Plate_Spline Spline[2]); bool _Set_Polynomial (CSG_Points &From, CSG_Points &To, CSG_Vector Polynom[2]); bool _Get_Polynomial (double &x, double &y, CSG_Vector Polynom[2]); void _Get_Polynomial (double x, double y, double *z); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Georef_Engine_H saga-2.2.3/src/modules/projection/pj_georeference/set_grid_georeference.h0000664000175000017500000001055312565125415030020 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: set_grid_georeference.h 1834 2013-09-11 18:33:29Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // set_grid_georeference.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__set_grid_georeference_H #define HEADER_INCLUDED__set_grid_georeference_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSet_Grid_Georeference : public CSG_Module_Grid { public: CSet_Grid_Georeference(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__set_grid_georeference_H saga-2.2.3/src/modules/projection/pj_georeference/MLB_Interface.cpp0000664000175000017500000001107612565125415026435 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003-13 by // // SAGA User Group Association // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Georeferencing") ); case MLB_INFO_Category: return( _TL("Projection") ); case MLB_INFO_Author: return( SG_T("SAGA User Group Association (c) 2003-13") ); case MLB_INFO_Description: return( _TL("Tools for the georeferencing of spatial data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Projection|Georeferencing") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Collect_Points.h" #include "Georef_Grid.h" #include "Georef_Shapes.h" #include "georef_grid_move.h" #include "direct_georeferencing.h" #include "set_grid_georeference.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CCollect_Points ); case 1: return( new CGeoref_Grid ); case 2: return( new CGeoref_Shapes ); case 3: return( new CGeoref_Grid_Move ); case 4: return( new CDirect_Georeferencing ); case 6: return( new CDirect_Georeferencing_WorldFile ); case 5: return( new CSet_Grid_Georeference ); case 10: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/projection/pj_georeference/Georef_Engine.cpp0000664000175000017500000004700612565125415026541 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Engine.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_Georeference // // // //-------------------------------------------------------// // // // Georef_Engine.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Georef_Engine.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGeoref_Engine::CGeoref_Engine(void) { m_Method = GEOREF_NotSet; m_Order = 0; m_Scaling = 0.0; m_TIN_Fwd.Add_Field("X", SG_DATATYPE_Double); m_TIN_Fwd.Add_Field("Y", SG_DATATYPE_Double); m_TIN_Inv.Add_Field("X", SG_DATATYPE_Double); m_TIN_Inv.Add_Field("Y", SG_DATATYPE_Double); } //--------------------------------------------------------- bool CGeoref_Engine::Destroy(void) { m_Method = GEOREF_NotSet; m_Error.Clear(); m_From.Clear(); m_To .Clear(); m_TIN_Fwd.Del_Records(); m_TIN_Inv.Del_Records(); m_Spline_Fwd[0].Destroy(); m_Spline_Fwd[1].Destroy(); m_Spline_Inv[0].Destroy(); m_Spline_Inv[1].Destroy(); m_Polynom_Fwd[0].Destroy(); m_Polynom_Fwd[1].Destroy(); m_Polynom_Inv[0].Destroy(); m_Polynom_Inv[1].Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Engine::Add_Reference(TSG_Point From, TSG_Point To) { if( m_From.Add(From) && m_To.Add(To) ) { m_Method = GEOREF_NotSet; if( Get_Reference_Count() == 1 ) { m_rFrom.Assign(From, From); m_rTo .Assign(To , To ); } else { m_rFrom.Union(From); m_rTo .Union(To ); } return( true ); } if( m_From.Get_Count() > m_To.Get_Count() ) { m_From.Del(m_From.Get_Count() - 1); } return( false ); } //--------------------------------------------------------- bool CGeoref_Engine::Add_Reference(double xFrom, double yFrom, double xTo, double yTo) { return( Add_Reference(CSG_Point(xFrom, yFrom), CSG_Point(xTo, yTo)) ); } //--------------------------------------------------------- bool CGeoref_Engine::Set_Reference(CSG_Shapes *pFrom, CSG_Shapes *pTo) { if( !pFrom || pFrom->Get_Count() <= 0 || !pTo || pTo ->Get_Count() <= 0 ) { return( false ); } Destroy(); for(int iShape=0; iShapeGet_Count() && iShapeGet_Count(); iShape++) { CSG_Shape *_pFrom = pFrom->Get_Shape(iShape); CSG_Shape *_pTo = pTo ->Get_Shape(iShape); for(int iPart=0; iPart<_pFrom->Get_Part_Count() && iPart<_pTo->Get_Part_Count(); iPart++) { for(int iPoint=0; iPoint<_pFrom->Get_Point_Count(iPart) && iPoint<_pTo->Get_Point_Count(iPart); iPoint++) { Add_Reference(_pFrom->Get_Point(iPoint, iPart), _pTo->Get_Point(iPoint, iPart)); } } } return( true ); } //--------------------------------------------------------- bool CGeoref_Engine::Set_Reference(CSG_Shapes *pFrom, int xTo_Field, int yTo_Field) { if( !pFrom || pFrom->Get_Count() <= 0 || pFrom->Get_Type() != SHAPE_TYPE_Point || xTo_Field < 0 || xTo_Field >= pFrom->Get_Field_Count() || yTo_Field < 0 || yTo_Field >= pFrom->Get_Field_Count() ) { return( false ); } Destroy(); for(int iPoint=0; iPointGet_Count(); iPoint++) { CSG_Shape *pPoint = pFrom->Get_Shape(iPoint); Add_Reference( pPoint->Get_Point(0).x, pPoint->Get_Point(0).y, pPoint->asDouble(xTo_Field), pPoint->asDouble(yTo_Field) ); } return( true ); } //--------------------------------------------------------- bool CGeoref_Engine::Get_Reference_Extent(CSG_Rect &Extent, bool bInverse) { CSG_Points &Points = bInverse ? m_From : m_To; if( Points.Get_Count() >= 3 ) { Extent.Assign(Points[0], Points[1]); for(int i=2; i= 0 && i < Get_Reference_Count() ) { TSG_Point p = m_From[i]; if( Get_Converted(p) ) { return( SG_Get_Distance(p, m_To[i]) ); } } return( -1.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Engine::Set_Scaling(double Scaling) { m_Scaling = Scaling > 0.0 ? Scaling : 0.0; return( m_Scaling > 0.0 ); } //--------------------------------------------------------- bool CGeoref_Engine::Get_Converted(TSG_Point &Point, bool bInverse) { return( Get_Converted(Point.x, Point.y, bInverse) ); } //--------------------------------------------------------- bool CGeoref_Engine::Get_Converted(double &x, double &y, bool bInverse) { bool bResult; if( m_Scaling > 0.0 ) { x = bInverse ? (x - m_rTo .Get_XMin()) * m_Scaling / m_rTo .Get_XRange() : (x - m_rFrom.Get_XMin()) * m_Scaling / m_rFrom.Get_XRange(); y = bInverse ? (y - m_rTo .Get_YMin()) * m_Scaling / m_rTo .Get_YRange() : (y - m_rFrom.Get_YMin()) * m_Scaling / m_rFrom.Get_YRange(); } switch( m_Method ) { case GEOREF_Triangulation: bResult = _Get_Triangulation(x, y, bInverse ? &m_TIN_Inv : &m_TIN_Fwd ); break; case GEOREF_Spline: bResult = _Get_Spline (x, y, bInverse ? m_Spline_Inv : m_Spline_Fwd ); break; case GEOREF_Affine: case GEOREF_Polynomial_1st_Order: case GEOREF_Polynomial_2nd_Order: case GEOREF_Polynomial_3rd_Order: case GEOREF_Polynomial: bResult = _Get_Polynomial (x, y, bInverse ? m_Polynom_Inv : m_Polynom_Fwd); break; default: bResult = false; break; } if( bResult && m_Scaling > 0.0 ) { x = bInverse ? m_rFrom.Get_XMin() + x * m_rFrom.Get_XRange() / m_Scaling : m_rTo .Get_XMin() + x * m_rTo .Get_XRange() / m_Scaling; y = bInverse ? m_rFrom.Get_YMin() + y * m_rFrom.Get_YRange() / m_Scaling : m_rTo .Get_YMin() + y * m_rTo .Get_YRange() / m_Scaling; } return( bResult ); } //--------------------------------------------------------- bool CGeoref_Engine::Evaluate(int Method, int Order) { //----------------------------------------------------- if( Method == GEOREF_NotSet ) // Automatic { if( Get_Reference_Count() >= 4 ) return( Evaluate(GEOREF_Spline) ); // if( Get_Reference_Count() >= 4 ) return( Evaluate(GEOREF_Polynomial_1st_Order) ); return( Evaluate(GEOREF_Affine) ); } //----------------------------------------------------- int n = _Get_Reference_Minimum(Method, Order); if( n < 0 || Get_Reference_Count() < n ) { m_Error.Printf(SG_T("%s\n%s: %d"), _TL("not enough reference points"), _TL("minimum requirement"), n); return( false ); } //----------------------------------------------------- CSG_Points From, To; if( m_Scaling > 0.0 ) { From = m_From; To = m_To; for(int i=0; i 0.0 ) { m_From = From; m_To = To; } if( !bResult ) { m_Method = GEOREF_NotSet; } return( bResult ); } //--------------------------------------------------------- int CGeoref_Engine::_Get_Reference_Minimum(int Method, int Order) { switch( Method ) { default: return( 0 ); case GEOREF_Triangulation: return( 3 ); case GEOREF_Spline: return( 3 ); case GEOREF_Affine: return( 3 ); // 3: a + bx + cy aka RST=rotation/scaling/translation case GEOREF_Polynomial_1st_Order: return( 4 ); // 4: a + bx + cy + dxy case GEOREF_Polynomial_2nd_Order: return( 6 ); // 6: a + bx + cy + dxy + ex^2 + fy^2 case GEOREF_Polynomial_3rd_Order: return( 10 ); // 10: a + bx + cy + dxy + ex^2 + fy^2 + gx^3 + hy^3 + ix^2y + jxy^2 case GEOREF_Polynomial: return( Order > 0 ? (int)SG_Get_Square(Order + 1) : -1 ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Engine::_Set_Triangulation(void) { m_TIN_Fwd.Del_Records(); m_TIN_Inv.Del_Records(); for(int i=0; iSet_Value(0, m_To [i].x); pNode->Set_Value(1, m_To [i].y); pNode = m_TIN_Inv.Add_Node(m_To [i], NULL, false); pNode->Set_Value(0, m_From[i].x); pNode->Set_Value(1, m_From[i].y); } return( m_TIN_Fwd.Update() && m_TIN_Inv.Update() ); } //--------------------------------------------------------- bool CGeoref_Engine::_Get_Triangulation(double &x, double &y, CSG_TIN *pTIN) { CSG_Point p(x, y); for(int i=0; iGet_Triangle_Count(); i++) { CSG_TIN_Triangle *pTriangle = pTIN->Get_Triangle(i); if( pTriangle->is_Containing(p) ) { return( pTriangle->Get_Value(0, p, x) && pTriangle->Get_Value(1, p, y) ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Engine::_Set_Spline(void) { m_Spline_Fwd[0].Destroy(); m_Spline_Fwd[1].Destroy(); m_Spline_Inv[0].Destroy(); m_Spline_Inv[1].Destroy(); for(int i=0; i //--------------------------------------------------------- #ifdef pj_georeference_EXPORTS #define pj_georeference_EXPORT _SAGA_DLL_EXPORT #else #define pj_georeference_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pj_georeference_H saga-2.2.3/src/modules/projection/pj_georeference/direct_georeferencing.h0000664000175000017500000001374412565125415030030 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: direct_georeferencing.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // georeferencing // // // //-------------------------------------------------------// // // // direct_georeferencing.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__direct_georeferencing_H #define HEADER_INCLUDED__direct_georeferencing_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSG_Direct_Georeferencer { public: CSG_Direct_Georeferencer(void); bool Add_Parameters (CSG_Parameters &Parameters); bool Set_Transformation (CSG_Parameters &Parameters, int nCols, int nRows); const CSG_Matrix & Get_Transformation (void) const { return( m_R ); } TSG_Point World_to_Image (double x_w, double y_w, double z_w = 0.0); TSG_Point Image_to_World (double x_i, double y_i, double z_w = 0.0); private: double m_f, m_s; CSG_Vector m_T, m_O; CSG_Matrix m_R, m_Rinv; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDirect_Georeferencing : public CSG_Module_Grid { public: CDirect_Georeferencing(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Parameters_Grid_Target m_Grid_Target; CSG_Direct_Georeferencer m_Georeferencer; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDirect_Georeferencing_WorldFile : public CSG_Module { public: CDirect_Georeferencing_WorldFile(void); protected: virtual bool On_Execute (void); private: CSG_Direct_Georeferencer m_Georeferencer; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__direct_georeferencing_H saga-2.2.3/src/modules/projection/pj_georeference/set_grid_georeference.cpp0000664000175000017500000002233612565125415030355 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: set_grid_georeference.cpp 1834 2013-09-11 18:33:29Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // set_grid_georeference.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "set_grid_georeference.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSet_Grid_Georeference::CSet_Grid_Georeference(void) { //----------------------------------------------------- Set_Name (_TL("Define Georeference for Grids")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "This tool simply allows definition of grid's cellsize and position. " "It does not perform any kind of warping but might be helpful, if the " "grid has lost this information or is already aligned with the " "coordinate system. " )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "REFERENCED" , _TL("Referenced Grids"), _TL(""), PARAMETER_OUTPUT, false ); //----------------------------------------------------- Parameters.Add_Choice( NULL , "DEFINITION" ,_TL("Definition"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("cellsize and lower left center coordinates"), _TL("cellsize and lower left corner coordinates"), _TL("cellsize and upper left center coordinates"), _TL("cellsize and upper left corner coordinates"), _TL("lower left and upper right center coordinates"), _TL("lower left and upper right corner coordinates") ), 0 ); Parameters.Add_Value( NULL , "SIZE" , _TL("Cellsize"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL , "XMIN" , _TL("Left"), _TL(""), PARAMETER_TYPE_Double ); Parameters.Add_Value( NULL , "YMIN" , _TL("Lower"), _TL(""), PARAMETER_TYPE_Double ); Parameters.Add_Value( NULL , "XMAX" , _TL("Right"), _TL(""), PARAMETER_TYPE_Double ); Parameters.Add_Value( NULL , "YMAX" , _TL("Upper"), _TL(""), PARAMETER_TYPE_Double ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSet_Grid_Georeference::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "DEFINITION") ) { pParameters->Get_Parameter("SIZE")->Set_Enabled(pParameter->asInt() < 4); pParameters->Get_Parameter("XMAX")->Set_Enabled(pParameter->asInt() >= 4); pParameters->Get_Parameter("YMAX")->Set_Enabled(pParameter->asInt() >= 2); pParameters->Get_Parameter("YMIN")->Set_Enabled(pParameter->asInt() >= 4 || pParameter->asInt() < 2); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSet_Grid_Georeference::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); if( pGrids->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- double xMin, yMin, size; switch( Parameters("DEFINITION")->asInt() ) { case 0: // cellsize and lower left center coordinates size = Parameters("SIZE")->asDouble(); xMin = Parameters("XMIN")->asDouble(); yMin = Parameters("YMIN")->asDouble(); break; case 1: // cellsize and lower left corner coordinates size = Parameters("SIZE")->asDouble(); xMin = Parameters("XMIN")->asDouble() + size * 0.5; yMin = Parameters("YMIN")->asDouble() + size * 0.5; break; case 2: // cellsize and upper left center coordinates size = Parameters("SIZE")->asDouble(); xMin = Parameters("XMIN")->asDouble(); yMin = Parameters("YMAX")->asDouble() - size * Get_NY(); break; case 3: // cellsize and upper left corner coordinates size = Parameters("SIZE")->asDouble(); xMin = Parameters("XMIN")->asDouble() + size * 0.5; yMin = Parameters("YMAX")->asDouble() - size * (0.5 + Get_NY()); break; case 4: // lower left and upper right center coordinates size = (Parameters("XMAX")->asDouble() - Parameters("XMIN")->asDouble()) / Get_NX(); xMin = Parameters("XMIN")->asDouble(); yMin = Parameters("YMIN")->asDouble(); break; case 5: // lower left and upper right corner coordinates size = (Parameters("XMAX")->asDouble() - Parameters("XMIN")->asDouble()) / (Get_NX() + 1); xMin = Parameters("XMIN")->asDouble() + size * 0.5; yMin = Parameters("YMIN")->asDouble() + size * 0.5; break; } //----------------------------------------------------- CSG_Grid_System System; if( !System.Assign(size, xMin, yMin, Get_NX(), Get_NY()) ) { return( false ); } //----------------------------------------------------- Parameters("REFERENCED")->asGridList()->Del_Items(); for(int i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Grid *pGrid = pGrids->asGrid(i); CSG_Grid *pReferenced = SG_Create_Grid(System, pGrid->Get_Type()); pReferenced->Set_Name(pGrid->Get_Name()); pReferenced->Set_Unit(pGrid->Get_Unit()); pReferenced->Set_Scaling(pGrid->Get_Scaling(), pGrid->Get_Offset()); pReferenced->Set_NoData_Value_Range(pGrid->Get_NoData_Value(), pGrid->Get_NoData_hiValue()); pReferenced->Get_MetaData () = pGrid->Get_MetaData (); pReferenced->Get_Projection() = pGrid->Get_Projection(); for(int y=0; ySet_Value(x, y, pGrid->asDouble(x, y)); } } Parameters("REFERENCED")->asGridList()->Add_Item(pReferenced); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/pj_georeference/georef_grid_move.cpp0000664000175000017500000001660212565125415027345 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: georef_grid_move.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Georeference // // // //-------------------------------------------------------// // // // Georef_Grid_Move.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "georef_grid_move.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGeoref_Grid_Move::CGeoref_Grid_Move(void) { //----------------------------------------------------- Set_Name (_TL("Move Grid")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_Grid( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); //----------------------------------------------------- Set_Drag_Mode(MODULE_INTERACTIVE_DRAG_LINE); } //--------------------------------------------------------- CGeoref_Grid_Move::~CGeoref_Grid_Move(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid_Move::On_Execute(void) { m_pGrid = Parameters("SOURCE")->asGrid(); m_pSource = NULL; m_bModified = m_pGrid->is_Modified(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid_Move::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { if( Mode == MODULE_INTERACTIVE_LDOWN ) { m_Down = ptWorld; } else if( Mode == MODULE_INTERACTIVE_LUP ) { if( m_Down != ptWorld ) { if( m_pSource == NULL ) { m_pSource = new CSG_Grid(*m_pGrid); m_pSource ->Set_Name(m_pGrid->Get_Name()); m_Move = m_Down - ptWorld; } else { m_Move += m_Down - ptWorld; } //--------------------------------------------- int x, y, ix, iy, dx, dy; dx = (int)(0.5 + m_Move.Get_X() / m_pSource->Get_Cellsize()); dy = (int)(0.5 + m_Move.Get_Y() / m_pSource->Get_Cellsize()); for(y=0, iy=dy; yGet_NY() && Set_Progress(y, m_pGrid->Get_NY()); y++, iy++) { if( iy >= 0 && iy < m_pSource->Get_NY() ) { for(x=0, ix=dx; xGet_NX(); x++, ix++) { if( ix >= 0 && ix < m_pSource->Get_NX() ) { m_pGrid->Set_Value(x, y, m_pSource->asDouble(ix, iy)); } else { m_pGrid->Set_NoData(x, y); } } } else { for(x=0; xGet_NX(); x++) { m_pGrid->Set_NoData(x, y); } } } DataObject_Update(m_pGrid); } } return( true ); } //--------------------------------------------------------- bool CGeoref_Grid_Move::On_Execute_Finish(void) { if( m_pSource ) { m_pGrid->Assign(m_pSource); m_pGrid->Set_Modified(m_bModified); DataObject_Update(m_pGrid); if( m_Move.Get_X() == 0.0 && m_Move.Get_Y() == 0.0 ) { Message_Add(_TL("No translation set by user")); } else if( Message_Dlg_Confirm(_TL("Apply Move"), _TL("Move Grid")) ) { m_pGrid = new CSG_Grid(m_pSource->Get_Type(), m_pSource->Get_NX(), m_pSource->Get_NY(), m_pSource->Get_Cellsize(), m_pSource->Get_XMin() - m_Move.Get_X(), m_pSource->Get_YMin() - m_Move.Get_Y() ); m_pGrid->Set_Name (m_pSource->Get_Name()); m_pGrid->Set_Unit (m_pSource->Get_Unit()); m_pGrid->Set_Scaling(m_pSource->Get_Scaling(), m_pSource->Get_Offset()); for(int y=0; yGet_NY() && Set_Progress(y, m_pGrid->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { m_pGrid->Set_Value(x, y, m_pSource->asDouble(x, y)); } } Parameters("GRID")->Set_Value(m_pGrid); return( true ); } delete(m_pSource); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/projection/Makefile.am0000664000175000017500000000004412565125416022243 0ustar00oconradoconrad00000000000000SUBDIRS = pj_georeference pj_proj4 saga-2.2.3/src/modules/terrain_analysis/0000775000175000017500000000000012634325752021406 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/terrain_analysis/ta_lighting/0000775000175000017500000000000012634325752023677 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/terrain_analysis/ta_lighting/HillShade.h0000664000175000017500000001161612565125415025707 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: HillShade.h 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // HillShade.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__HillShade_H #define HEADER_INCLUDED__HillShade_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_lighting_EXPORT CHillShade : public CSG_Module_Grid { public: CHillShade(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int RT_Dir_Top, RT_Dir_Right; double m_zScale, RT_Tan, RT_Cot, RT_Dz; CSG_Grid *m_pDEM, *m_pShade, m_Shade; void Get_Shading (double Azimuth, double Declination, bool bDelimit, bool bCombine); void Shadow (double Azimuth, double Declination); void Shadow_Trace (double x, double y, double z, double dx, double dy, double dz); void AmbientOcclusion (int iDirs, double dRadius); bool AmbientOcclusion_Trace (int x, int y, CSG_Point_Z Direction, double dRadius); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__HillShade_H saga-2.2.3/src/modules/terrain_analysis/ta_lighting/Visibility_BASE.h0000664000175000017500000001116112565125415026766 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Visibility_BASE.h 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // Visibility_BASE.h // // // // Copyright (C) 2003, 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Visibility_BASE_H #define HEADER_INCLUDED__Visibility_BASE_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "saga_api/saga_api.h" #include "saga_api/api_core.h" #include "saga_api/module.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CVisibility_BASE { public: protected: void Initialize (CSG_Grid *pVisibility, int iMethod); void Set_Visibility (CSG_Grid *pDTM, CSG_Grid *pVisibility, int x_Pos, int y_Pos, double z_Pos, double dHeight, int iMethod); bool Trace_Point (CSG_Grid *pDTM, int x, int y, double dx, double dy, double dz); void Finalize (CSG_Grid *pVisibility, int iMethod); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Visibility_BASE_H saga-2.2.3/src/modules/terrain_analysis/ta_lighting/HillShade.cpp0000664000175000017500000003407512565125415026246 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: HillShade.cpp 2322 2014-11-03 21:29:57Z johanvdw $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // HillShade.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "HillShade.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CHillShade::CHillShade(void) { //----------------------------------------------------- Set_Name (_TL("Analytical Hillshading")); Set_Author ("O.Conrad, V.Wichmann (c) 2003-2013"); Set_Description(_TW( "Analytical hillshading calculation.\n" "Method 'Ambient Occlusion' is based on concepts of Tarini et al. (2006), but only " "the northern half-space is considered.\n" "\n" "References:\n" "Tarini, M. / Cignoni, P. / Montani, C. (2006): Ambient Occlusion and Edge Cueing " "to Enhance Real Time Molecular Visualization. " "IEEE Transactions on Visualization and Computer Graphics, Vol. 12, No. 5, pp. 1237-1244.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SHADE" , _TL("Analytical Hillshading"), _TL("The angle between the surface and the incoming light beams, measured in radians."), PARAMETER_OUTPUT ); //----------------------------------------------------- Parameters.Add_Choice( NULL , "METHOD" , _TL("Shading Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("Standard"), _TL("Standard (max. 90Degree)"), _TL("Combined Shading"), _TL("Ray Tracing"), _TL("Ambient Occlusion") ), 0 ); Parameters.Add_Value( NULL , "AZIMUTH" , _TL("Azimuth [Degree]"), _TL("Direction of the light source, measured in degree clockwise from the north direction."), PARAMETER_TYPE_Double , 315 ); Parameters.Add_Value( NULL , "DECLINATION" , _TL("Height [Degree]"), _TL("Height of the light source, measured in degree above the horizon."), PARAMETER_TYPE_Double , 45 ); Parameters.Add_Value( NULL , "EXAGGERATION" , _TL("Exaggeration"), _TL("The terrain exaggeration factor allows to increase the shading contrasts in flat areas."), PARAMETER_TYPE_Double , 4 ); Parameters.Add_Choice( NULL , "SHADOW" , _TL("Shadow"), _TL("Choose 'slim' to trace grid node's shadow, 'fat' to trace the whole cell's shadow. The first is slightly faster but might show some artifacts."), CSG_String::Format(SG_T("%s|%s|"), _TL("slim"), _TL("fat") ), 1 ); Parameters.Add_Value( NULL , "NDIRS" , _TL("Number of Directions"), _TW("Number of sample directions for ambient occlusion. Divides azimuth range (270 to 0 to 90 degree) into sectors. " "Declination (0 to 90 degree) is divided in (Number of Directions / 4) sectors."), PARAMETER_TYPE_Int, 8.0, 2, true ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Search Radius"), _TL("Radius used to trace for shadows (ambient occlusion) [map units]."), PARAMETER_TYPE_Double, 10.0, 0.001, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CHillShade::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("METHOD")) ) { pParameters->Get_Parameter("AZIMUTH" )->Set_Enabled(pParameter->asInt() < 4); pParameters->Get_Parameter("DECLINATION" )->Set_Enabled(pParameter->asInt() < 4); pParameters->Get_Parameter("EXAGGERATION")->Set_Enabled(pParameter->asInt() < 4); pParameters->Get_Parameter("SHADOW" )->Set_Enabled(pParameter->asInt() == 3); pParameters->Get_Parameter("NDIRS" )->Set_Enabled(pParameter->asInt() == 4); pParameters->Get_Parameter("RADIUS" )->Set_Enabled(pParameter->asInt() == 4); } return( 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CHillShade::On_Execute(void) { //----------------------------------------------------- m_pDEM = Parameters("ELEVATION" )->asGrid(); m_pShade = Parameters("SHADE" )->asGrid(); m_zScale = Parameters("EXAGGERATION")->asDouble(); double Azimuth = Parameters("AZIMUTH" )->asDouble() * M_DEG_TO_RAD; double Height = Parameters("DECLINATION" )->asDouble() * M_DEG_TO_RAD; double dRadius = Parameters("RADIUS" )->asDouble(); int iDirs = Parameters("NDIRS" )->asInt(); //----------------------------------------------------- switch( Parameters("METHOD")->asInt() ) { case 0: Get_Shading (Azimuth, Height, false, false); break; case 1: Get_Shading (Azimuth, Height, true , false); break; case 2: Get_Shading (Azimuth, Height, false, true ); break; case 3: Shadow (Azimuth, Height); break; case 4: AmbientOcclusion(iDirs, dRadius); break; } //----------------------------------------------------- m_pShade->Set_Unit(_TL("radians")); DataObject_Set_Colors(m_pShade, 100, SG_COLORS_BLACK_WHITE, true); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CHillShade::Get_Shading(double Azimuth, double Height, bool bDelimit, bool bCombine) { //----------------------------------------------------- double sinHgt = sin(Height); double cosHgt = cos(Height); //----------------------------------------------------- for(int y=0; yGet_Gradient(x, y, s, a) ) { m_pShade->Set_NoData(x, y); } else { s = tan(s); d = M_PI_090 - atan(m_zScale * s); d = acos(sin(d) * sinHgt + cos(d) * cosHgt * cos(a - Azimuth)); if( bDelimit && d > M_PI_090 ) { d = M_PI_090; } if( bCombine ) { d *= s / M_PI_090; } m_pShade->Set_Value(x, y, d); } } } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CHillShade::Shadow(double Azimuth, double Height) { //----------------------------------------------------- Get_Shading(Azimuth, Height, true, false); //----------------------------------------------------- double dx = sin(Azimuth + M_PI_180); double dy = cos(Azimuth + M_PI_180); 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; } double dz = tan(Height) * sqrt(dx*dx + dy*dy) * Get_Cellsize(); //----------------------------------------------------- const double dShadow = 0.49; int Shadowing = Parameters("SHADOW")->asInt(); m_Shade.Create(*Get_System(), SG_DATATYPE_Float); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { switch( Shadowing ) { default: // slim Shadow_Trace(x, y, m_pDEM->asDouble(x, y), dx, dy, dz); break; case 1: // fat Shadow_Trace(x - dShadow, y - dShadow, m_pDEM->asDouble(x, y), dx, dy, dz); Shadow_Trace(x + dShadow, y - dShadow, m_pDEM->asDouble(x, y), dx, dy, dz); Shadow_Trace(x - dShadow, y + dShadow, m_pDEM->asDouble(x, y), dx, dy, dz); Shadow_Trace(x + dShadow, y + dShadow, m_pDEM->asDouble(x, y), dx, dy, dz); break; } } } } //----------------------------------------------------- m_Shade.Destroy(); } //--------------------------------------------------------- void CHillShade::Shadow_Trace(double x, double y, double z, double dx, double dy, double dz) { for(x+=dx+0.5, y+=dy+0.5, z-=dz; ; x+=dx, y+=dy, z-=dz) { int ix = (int)x, iy = (int)y; if( !is_InGrid(ix, iy) ) { return; } if( !m_pDEM->is_NoData(ix, iy) ) { double zDiff = z - m_pDEM->asDouble(ix, iy); if( zDiff <= 0.0 ) { return; } m_Shade.Set_Value(ix, iy, zDiff); } } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CHillShade::AmbientOcclusion(int iDirs, double dRadius) { CSG_Points_Z Directions; Directions.Set_Count(iDirs); for(int i=0; iAssign(0.0); for(int y=0; yGet_Gradient(x, y, s, a) ) { m_pShade->Set_NoData(x, y); continue; } CSG_Point_Z Normal(sin(s) * sin(a), sin(s) * cos(a), cos(s)); //----------------------------------------------------- for(int i=0; iAdd_Value(x, y, dAngle); } } } if( !m_pShade->is_NoData(x, y) ) m_pShade->Set_Value(x, y, M_PI - m_pShade->asDouble(x, y) / (iDirs * (iDirs / 4.0))); } } } //--------------------------------------------------------- bool CHillShade::AmbientOcclusion_Trace(int x, int y, CSG_Point_Z Direction, double dRadius) { double dDistance, iDistance, dx, dy, dz, ix, iy, iz, z; z = m_pDEM->asDouble(x, y); dx = Direction.Get_X(); dy = Direction.Get_Y(); dz = tan( asin(Direction.Get_Z()) ) * sqrt(dx*dx + dy*dy) * Get_Cellsize(); ix = x; iy = y; iz = m_pDEM->asDouble(x, y); dDistance = 0.0; iDistance = Get_Cellsize() * M_GET_LENGTH(dx, dy); while( is_InGrid(x, y) && dDistance <= dRadius ) { ix += dx; x = (int)(0.5 + ix); iy += dy; y = (int)(0.5 + iy); iz += dz; if( m_pDEM->is_InGrid(x, y) && m_pDEM->asDouble(x, y) > iz ) return( false ); dDistance += iDistance; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_lighting/Visibility_Point.cpp0000664000175000017500000001421312565125415027701 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Visibility_Point.cpp 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // Visibility_Point.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Visibility_Point.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CVisibility_Point::CVisibility_Point(void) { Set_Name(_TL("Visibility (single point)")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description( _TL("") ); Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "VISIBILITY" , _TL("Visibility"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "HEIGHT" , _TL("Height"), _TL("Height of the light source above ground."), PARAMETER_TYPE_Double, 100.0 ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Unit"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Visibility"), _TL("Shade"), _TL("Distance"), _TL("Size") ), 1 ); Parameters.Add_Value( NULL , "MULTIPLE_OBS" , _TL("Multiple Observer"), _TL("Allow multiple observer positions."), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------- CVisibility_Point::~CVisibility_Point(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CVisibility_Point::On_Execute(void) { m_pDTM = Parameters("ELEVATION") ->asGrid(); m_pVisibility = Parameters("VISIBILITY") ->asGrid(); m_Height = Parameters("HEIGHT") ->asDouble(); m_Method = Parameters("METHOD") ->asInt(); m_bMultiple = Parameters("MULTIPLE_OBS")->asBool(); if( m_bMultiple ) Initialize(m_pVisibility, m_Method); return( true ); } //--------------------------------------------------------- bool CVisibility_Point::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { int x_Pos, y_Pos; double z_Pos; //----------------------------------------------------- if( Mode != MODULE_INTERACTIVE_LDOWN || !m_pDTM->is_InGrid_byPos(Get_xPosition(), Get_yPosition()) ) { return( false ); } //----------------------------------------------------- x_Pos = Get_xGrid(); y_Pos = Get_yGrid();; z_Pos = m_pDTM->asDouble(x_Pos, y_Pos) + m_Height; if( !m_bMultiple ) Initialize(m_pVisibility, m_Method); Set_Visibility(m_pDTM, m_pVisibility, x_Pos, y_Pos, z_Pos, m_Height, m_Method); //----------------------------------------------------- Finalize(m_pVisibility, m_Method); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_lighting/Makefile.in0000664000175000017500000005625112622651176025754 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/ta_lighting DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libta_lighting_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libta_lighting_la_OBJECTS = HillShade.lo MLB_Interface.lo \ SolarRadiation.lo topographic_correction.lo \ topographic_openness.lo view_shed.lo Visibility_BASE.lo \ Visibility_Point.lo Visibility_Points.lo libta_lighting_la_OBJECTS = $(am_libta_lighting_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libta_lighting_la_SOURCES) DIST_SOURCES = $(libta_lighting_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1613 2013-02-22 11:20:39Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_lighting.la libta_lighting_la_SOURCES = \ HillShade.cpp\ MLB_Interface.cpp\ SolarRadiation.cpp\ topographic_correction.cpp\ topographic_openness.cpp\ view_shed.cpp\ Visibility_BASE.cpp\ Visibility_Point.cpp\ Visibility_Points.cpp\ HillShade.h\ MLB_Interface.h\ SolarRadiation.h\ topographic_correction.h\ topographic_openness.h\ view_shed.h\ Visibility_BASE.h\ Visibility_Point.h\ Visibility_Points.h libta_lighting_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) --foreign src/modules/terrain_analysis/ta_lighting/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/terrain_analysis/ta_lighting/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libta_lighting.la: $(libta_lighting_la_OBJECTS) $(libta_lighting_la_DEPENDENCIES) $(EXTRA_libta_lighting_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libta_lighting_la_OBJECTS) $(libta_lighting_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HillShade.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SolarRadiation.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Visibility_BASE.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Visibility_Point.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Visibility_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/topographic_correction.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/topographic_openness.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/view_shed.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/terrain_analysis/ta_lighting/SolarRadiation.h0000664000175000017500000001332312605406442026757 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SolarRadiation.h 2636 2015-10-06 16:10:24Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // SolarRadiation.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__SolarRadiation_H #define HEADER_INCLUDED__SolarRadiation_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_lighting_EXPORT CSolarRadiation : public CSG_Module_Grid { public: CSolarRadiation(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool m_bLocalSVF; int m_Method, m_Location, m_Shadowing; double m_Solar_Const, m_Latitude, m_Linke, m_Vapour, m_Atmosphere, m_Transmittance, m_Pressure, m_Water, m_Dust; CSG_Grid *m_pDEM, *m_pSVF, *m_pLinke, *m_pVapour, *m_pDirect, *m_pDiffus, *m_pTotal, *m_pRatio, *m_pDuration, *m_pSunrise, *m_pSunset, m_Slope, m_Aspect, m_Shade, m_Lat, m_Lon, m_Sun_Height, m_Sun_Azimuth; bool Finalize (void); bool Get_Insolation (void); bool Get_Insolation (CSG_DateTime Date); bool Get_Insolation (CSG_DateTime Date, double Hour); bool Get_Insolation (double Sun_Height, double Sun_Azimuth, double Hour); double Get_Air_Mass (double Sun_Height); bool Get_Irradiance (int x, int y, double Sun_Height, double Sun_Azimuth, double &Direct, double &Diffus); bool is_Shadowed (int x, int y); bool Get_Shade_Params (double Sun_Height, double Sun_Azimuth, double &dx, double &dy, double &dz); bool Get_Shade (double Sun_Height, double Sun_Azimuth); void Set_Shade (double x, double y, double z, double dx, double dy, double dz); void Set_Shade_Bended (double x, double y, double z); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__SolarRadiation_H saga-2.2.3/src/modules/terrain_analysis/ta_lighting/topographic_openness.h0000664000175000017500000001123212565125415030275 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topographic_openness.h 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // topographic_openness.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__topographic_openness_H #define HEADER_INCLUDED__topographic_openness_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTopographic_Openness : public CSG_Module_Grid { public: CTopographic_Openness(void); protected: virtual bool On_Execute (void); private: int m_Method, m_nLevels; double m_Radius; CSG_Points_Z m_Direction; CSG_Grid_Pyramid m_Pyramid; CSG_Grid *m_pDEM; bool Initialise (int nDirections); bool Get_Angles_Multi_Scale (int x, int y, CSG_Vector &Max, CSG_Vector &Min); bool Get_Angles_Sectoral (int x, int y, CSG_Vector &Max, CSG_Vector &Min); bool Get_Angle_Sectoral (int x, int y, int i, double &Max, double &Min); bool Get_Openness (int x, int y, double &Pos, double &Neg); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__topographic_openness_H saga-2.2.3/src/modules/terrain_analysis/ta_lighting/view_shed.cpp0000664000175000017500000003154012565125415026360 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: view_shed.cpp 1972 2014-02-06 16:19:50Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // View_Shed.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "view_shed.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CView_Shed::CView_Shed(void) { //----------------------------------------------------- Set_Name (_TL("Sky View Factor")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "Calculation of visible sky, sky view factor (SVF) and related parameters.\n" "\n" "References:\n" "Boehner, J., Antonic, O. (2009): " "'Land-surface parameters specific to topo-climatology'. " "in: Hengl, T., Reuter, H. (Eds.): 'Geomorphometry - Concepts, Software, Applications'. " "Developments in Soil Science, Volume 33, p.195-226, Elsevier\n" "\n" "Hantzschel, J., Goldberg, V., Bernhofer, C. (2005): " "'GIS-based regionalisation of radiation, temperature and coupling measures in complex terrain for low mountain ranges'. " "Meteorological Applications, V.12:01, p.33-42, doi:10.1017/S1350482705001489\n" "\n" "Oke, T.R. (2000): " "'Boundary Layer Climates'. " "Taylor & Francis, New York. 435pp.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "VISIBLE" , _TL("Visible Sky"), _TL("The unobstructed hemisphere given as percentage."), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "SVF" , _TL("Sky View Factor"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "SIMPLE" , _TL("Sky View Factor (Simplified)"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "TERRAIN" , _TL("Terrain View Factor"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "DISTANCE" , _TL("View Distance"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Maximum Search Radius"), _TL("This value is ignored if set to zero."), PARAMETER_TYPE_Double , 10000.0, 0.0, true ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("multi scale"), _TL("sectors") ), 1 ); Parameters.Add_Value( NULL , "DLEVEL" , _TL("Multi Scale Factor"), _TL(""), PARAMETER_TYPE_Double , 3.0, 1.25, true ); Parameters.Add_Value( NULL , "NDIRS" , _TL("Number of Sectors"), _TL(""), PARAMETER_TYPE_Int , 8.0, 3, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CView_Shed::On_Execute(void) { CSG_Grid *pVisible, *pSVF, *pSimple, *pTerrain, *pDistance; m_pDEM = Parameters("DEM" )->asGrid(); pVisible = Parameters("VISIBLE" )->asGrid(); pSVF = Parameters("SVF" )->asGrid(); pSimple = Parameters("SIMPLE" )->asGrid(); pTerrain = Parameters("TERRAIN" )->asGrid(); pDistance = Parameters("DISTANCE")->asGrid(); m_Radius = Parameters("RADIUS" )->asDouble(); m_Method = Parameters("METHOD" )->asInt(); DataObject_Set_Colors(pVisible , 100, SG_COLORS_BLACK_WHITE); DataObject_Set_Colors(pSVF , 100, SG_COLORS_BLACK_WHITE); DataObject_Set_Colors(pSimple , 100, SG_COLORS_BLACK_WHITE); DataObject_Set_Colors(pTerrain , 100, SG_COLORS_BLACK_WHITE, true); DataObject_Set_Colors(pDistance , 100, SG_COLORS_RED_GREY_GREEN, true); //----------------------------------------------------- if( m_Method == 0 ) // multi scale { if( !m_Pyramid.Create(m_pDEM, Parameters("DLEVEL")->asDouble(), GRID_PYRAMID_Mean) ) { return( false ); } m_nLevels = m_Pyramid.Get_Count(); if( m_Radius > 0.0 ) { while( m_nLevels > 0 && m_Pyramid.Get_Grid(m_nLevels - 1)->Get_Cellsize() > m_Radius ) { m_nLevels--; } } } //----------------------------------------------------- bool bResult = Initialise(Parameters("NDIRS")->asInt()); if( bResult ) { if( m_Method != 0 && m_Radius <= 0.0 ) { m_Radius = Get_Cellsize() * M_GET_LENGTH(Get_NX(), Get_NY()); } for(int y=0; ySet_Value (x, y, Visible); if( pSVF ) pSVF ->Set_Value (x, y, SVF); if( pSimple ) pSimple ->Set_Value (x, y, Simple); if( pTerrain ) pTerrain ->Set_Value (x, y, Terrain); if( pDistance ) pDistance->Set_Value (x, y, Distance); } else { if( pVisible ) pVisible ->Set_NoData(x, y); if( pSVF ) pSVF ->Set_NoData(x, y); if( pSimple ) pSimple ->Set_NoData(x, y); if( pTerrain ) pTerrain ->Set_NoData(x, y); if( pDistance ) pDistance->Set_NoData(x, y); } } } } //----------------------------------------------------- m_Pyramid .Destroy(); m_Direction .Clear(); return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CView_Shed::Initialise(int nDirections) { m_Direction.Set_Count(nDirections); for(int i=0; iis_NoData(x, y) ) { return( false ); } //----------------------------------------------------- CSG_Vector Angles(m_Direction.Get_Count()), Distances(m_Direction.Get_Count()); switch( m_Method ) { case 0: if( !Get_Angles_Multi_Scale(x, y, Angles, Distances) ) return( false ); break; case 1: if( !Get_Angles_Sectoral (x, y, Angles, Distances) ) return( false ); break; } //----------------------------------------------------- double Slope, Aspect, sinSlope, cosSlope, Phi, sinPhi, cosPhi; if( !m_pDEM->Get_Gradient(x, y, Slope, Aspect) ) { Slope = Aspect = 0.0; } sinSlope = sin(Slope); cosSlope = cos(Slope); Sky_Visible = 0.0; Sky_Factor = 0.0; Distance = 0.0; //----------------------------------------------------- for(int i=0; iis_NoData(x, y) ) { double z, d; TSG_Point p, q; z = m_pDEM->asDouble(x, y); p = Get_System()->Get_Grid_to_World(x, y); //------------------------------------------------- for(int iGrid=-1; iGridGet_Cellsize() * m_Direction[i].x; q.y = p.y + pGrid->Get_Cellsize() * m_Direction[i].y; if( pGrid->Get_Value(q, d) && (d = (d - z) / pGrid->Get_Cellsize()) > Angles[i] ) { Angles [i] = d; Distances[i] = pGrid->Get_Cellsize(); } } } return( true ); } return( false ); } //--------------------------------------------------------- bool CView_Shed::Get_Angles_Sectoral(int x, int y, CSG_Vector &Angles, CSG_Vector &Distances) { if( !m_pDEM->is_NoData(x, y) ) { //------------------------------------------------- for(int i=0; iasDouble(x, y); dx = m_Direction[i].x; dy = m_Direction[i].y; ix = x; iy = y; Angle = 0.0; Distance = 0.0; iDistance = 0.0; dDistance = Get_Cellsize() * M_GET_LENGTH(dx, dy); while( is_InGrid(x, y) && Distance <= m_Radius ) { ix += dx; x = (int)(0.5 + ix); iy += dy; y = (int)(0.5 + iy); iDistance += dDistance; if( m_pDEM->is_InGrid(x, y) && (d = (m_pDEM->asDouble(x, y) - z) / iDistance) > Angle ) { Angle = d; Distance = iDistance; } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_lighting/Visibility_Point.h0000664000175000017500000001115512565125415027350 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Visibility_Point.h 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // Visibility_Point.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Visibility_Point_H #define HEADER_INCLUDED__Visibility_Point_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include "Visibility_BASE.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CVisibility_Point : public CSG_Module_Grid_Interactive, CVisibility_BASE { public: CVisibility_Point(void); virtual ~CVisibility_Point(void); protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: int m_Method; double m_Height; bool m_bMultiple; CSG_Grid *m_pDTM, *m_pVisibility; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Visibility_Point_H saga-2.2.3/src/modules/terrain_analysis/ta_lighting/topographic_openness.cpp0000664000175000017500000002766512565125415030651 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topographic_openness.cpp 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // topographic_openness.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "topographic_openness.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTopographic_Openness::CTopographic_Openness(void) { //----------------------------------------------------- Set_Name (_TL("Topographic Openness")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Topographic openness expresses the dominance (positive) or enclosure (negative) " "of a landscape location. See Yokoyama et al. (2002) for a precise definition. " "Openness has been related to how wide a landscape can be viewed from any position. " "It has been proven to be a meaningful input for computer aided geomorphological mapping.\n" "\n" "References:\n" "Anders, N. S. / Seijmonsbergen, A. C. / Bouten, W. (2009): " "Multi-Scale and Object-Oriented Image Analysis of High-Res LiDAR Data for Geomorphological Mapping in Alpine Mountains. " "Proceedings of Geomorphometry 2009. " "online at geomorphometry.org.\n\n" "Prima, O.D.A / Echigo, A. / Yokoyama, R. / Yoshida, T. (2006): " "Supervised landform classification of Northeast Honshu from DEM-derived thematic maps. " "Geomorphology, vol.78, pp.373-386.\n\n" "Yokoyama, R. / Shirasawa, M. / Pike, R.J. (2002): " "Visualizing topography by openness: A new application of image processing to digital elevation models. " "Photogrammetric Engineering and Remote Sensing, Vol.68, pp.251-266. " "online at ASPRS.\n\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "POS" , _TL("Positive Openness"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "NEG" , _TL("Negative Openness"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Radial Limit"), _TL(""), PARAMETER_TYPE_Double , 10000.0, 0.0, true ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("multi scale"), _TL("sectors") ), 1 ); Parameters.Add_Value( NULL , "DLEVEL" , _TL("Multi Scale Factor"), _TL(""), PARAMETER_TYPE_Double , 3.0, 1.25, true ); Parameters.Add_Value( NULL , "NDIRS" , _TL("Number of Sectors"), _TL(""), PARAMETER_TYPE_Int , 8.0, 2, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTopographic_Openness::On_Execute(void) { CSG_Grid *pPos, *pNeg; m_pDEM = Parameters("DEM" )->asGrid(); pPos = Parameters("POS" )->asGrid(); pNeg = Parameters("NEG" )->asGrid(); m_Radius = Parameters("RADIUS")->asDouble(); m_Method = Parameters("METHOD")->asInt(); DataObject_Set_Colors(pPos, 100, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(pNeg, 100, SG_COLORS_RED_GREY_BLUE, false); //----------------------------------------------------- if( m_Method == 0 ) // multi scale { if( !m_Pyramid.Create(m_pDEM, Parameters("DLEVEL")->asDouble(), GRID_PYRAMID_Mean) ) { return( false ); } m_nLevels = m_Pyramid.Get_Count(); if( m_Radius > 0.0 ) { while( m_nLevels > 0 && m_Pyramid.Get_Grid(m_nLevels - 1)->Get_Cellsize() > m_Radius ) { m_nLevels--; } } } //----------------------------------------------------- bool bResult = Initialise(Parameters("NDIRS")->asInt()); if( bResult ) { if( m_Method != 0 && m_Radius <= 0.0 ) { m_Radius = Get_Cellsize() * M_GET_LENGTH(Get_NX(), Get_NY()); } for(int y=0; ySet_Value(x, y, Pos); if( pNeg ) pNeg->Set_Value(x, y, Neg); } else { if( pPos ) pPos->Set_NoData(x, y); if( pNeg ) pNeg->Set_NoData(x, y); } } } } //----------------------------------------------------- m_Pyramid .Destroy(); m_Direction .Clear(); return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTopographic_Openness::Initialise(int nDirections) { m_Direction.Set_Count(nDirections); for(int i=0; iis_NoData(x, y) ) { return( false ); } //----------------------------------------------------- CSG_Vector Max(m_Direction.Get_Count()), Min(m_Direction.Get_Count()); switch( m_Method ) { case 0: if( !Get_Angles_Multi_Scale(x, y, Max, Min) ) return( false ); break; case 1: if( !Get_Angles_Sectoral (x, y, Max, Min) ) return( false ); break; } //----------------------------------------------------- Pos = 0.0; Neg = 0.0; for(int i=0; iis_NoData(x, y) ) { return( false ); } double z, d; TSG_Point p, q; z = m_pDEM->asDouble(x, y); p = Get_System()->Get_Grid_to_World(x, y); //----------------------------------------------------- for(int iGrid=-1; iGridGet_Cellsize() * m_Direction[i].x; q.y = p.y + pGrid->Get_Cellsize() * m_Direction[i].y; if( pGrid->Get_Value(q, d) ) { d = (d - z) / pGrid->Get_Cellsize(); if( bOkay == false ) { bOkay = true; Max[i] = Min[i] = d; } else if( Max[i] < d ) { Max[i] = d; } else if( Min[i] > d ) { Min[i] = d; } } } if(0|| bOkay == false ) { return( false ); } } return( true ); } //--------------------------------------------------------- bool CTopographic_Openness::Get_Angles_Sectoral(int x, int y, CSG_Vector &Max, CSG_Vector &Min) { if( m_pDEM->is_NoData(x, y) ) { return( false ); } //----------------------------------------------------- for(int i=0; iasDouble(x, y); dx = m_Direction[i].x; dy = m_Direction[i].y; ix = x; iy = y; iDistance = 0.0; dDistance = Get_Cellsize() * M_GET_LENGTH(dx, dy); Max = 0.0; Min = 0.0; bool bOkay = false; while( is_InGrid(x, y) && iDistance <= m_Radius ) { ix += dx; x = (int)(0.5 + ix); iy += dy; y = (int)(0.5 + iy); iDistance += dDistance; if( m_pDEM->is_InGrid(x, y) ) { d = (m_pDEM->asDouble(x, y) - z) / iDistance; if( bOkay == false ) { bOkay = true; Max = Min = d; } else if( Max < d ) { Max = d; } else if( Min > d ) { Min = d; } } } return( bOkay ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_lighting/SolarRadiation.cpp0000664000175000017500000011646212605406442027322 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SolarRadiation.cpp 2636 2015-10-06 16:10:24Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SolarRadiation.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSolarRadiation::CSolarRadiation(void) { CSG_Parameter *pNode, *pNode_2; //----------------------------------------------------- Set_Name (_TL("Potential Incoming Solar Radiation")); Set_Author ("O.Conrad (c) 2010"); Set_Description (_TW( "Calculation of potential incoming solar radiation (insolation).\n" "Times of sunrise/sunset will only be calculated if time span is set to single day.\n" "\n" "References:\n
    " "
  • Boehner, J., Antonic, O. (2009): Land Surface Parameters Specific to Topo-Climatology. in Hengl, T. & Reuter, H.I. [Eds.]: Geomorphometry - Concepts, Software, Applications.
  • " "
  • Oke, T.R. (1988): Boundary Layer Climates. London, Taylor & Francis.
  • " "
  • Wilson, J.P., Gallant, J.C. [Eds.] (2000): Terrain Analysis - Principles and Applications. New York, John Wiley & Sons, Inc.
  • " "
  • Joint Research Centre: GIS solar radiation database for Europe and Solar radiation and GIS.
  • " "
  • Hofierka, J., Suri, M. (2002): The solar radiation model for Open source GIS: implementation and applications. International GRASS users conference in Trento, Italy, September 2002. pdf.
  • " "
\n" "\n*) Most options should do well, but TAPES-G based diffuse irradiance calculation ('Atmospheric Effects' methods 2 and 3) needs further revision!" )); //----------------------------------------------------- Parameters.Add_Grid (NULL, "GRD_DEM" , _TL("Elevation" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid (NULL, "GRD_SVF" , _TL("Sky View Factor" ), _TL(""), PARAMETER_INPUT_OPTIONAL); Parameters.Add_Grid_or_Const(NULL, "GRD_VAPOUR" , _TL("Water Vapour Pressure [mbar]"), _TL(""), 10.0, 0.0, true); Parameters.Add_Grid_or_Const(NULL, "GRD_LINKE" , _TL("Linke Turbidity Coefficient" ), _TL(""), 3.0, 0.0, true); Parameters.Add_Grid (NULL, "GRD_DIRECT" , _TL("Direct Insolation" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid (NULL, "GRD_DIFFUS" , _TL("Diffuse Insolation" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid (NULL, "GRD_TOTAL" , _TL("Total Insolation" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid (NULL, "GRD_RATIO" , _TL("Direct to Diffuse Ratio" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid (NULL, "GRD_DURATION", _TL("Duration of Insolation" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid (NULL, "GRD_SUNRISE" , _TL("Sunrise" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid (NULL, "GRD_SUNSET" , _TL("Sunset" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); //----------------------------------------------------- Parameters.Add_Value( NULL , "SOLARCONST" , _TL("Solar Constant [W / m\xb2]"), _TL(""), PARAMETER_TYPE_Double , 1367.0, 0.0, true ); Parameters.Add_Value( NULL , "LOCALSVF" , _TL("Local Sky View Factor"), _TL("Use sky view factor based on local slope (after Oke 1988), if no sky viev factor grid is given."), PARAMETER_TYPE_Bool , true ); Parameters.Add_Choice( NULL , "UNITS" , _TL("Units"), _TL("Units for output radiation values."), CSG_String::Format(SG_T("%s|%s|%s|"), SG_T("kWh / m2"), SG_T("kJ / m2"), SG_T("J / cm2") ), 0 ); Parameters.Add_Choice( NULL , "SHADOW" , _TL("Shadow"), _TL("Choose 'slim' to trace grid node's shadow, 'fat' to trace the whole cell's shadow, or ignore shadowing effects. The first is slightly faster but might show some artifacts."), CSG_String::Format("%s|%s|%s|", _TL("slim"), _TL("fat"), _TL("none") ), 1 ); pNode = Parameters.Add_Choice( NULL , "UPDATE" , _TL("Update"), _TL("show direct insolation for each time step."), CSG_String::Format("%s|%s|%s|", _TL("do not update"), _TL("fit histogram stretch for each time step"), _TL("constant histogram stretch for all time steps") ), 0 ); Parameters.Add_Value( pNode , "UPDATE_STRETCH" , _TL("Constant Histogram Stretch"), _TL(""), PARAMETER_TYPE_Double , 1.0, 0.0, true ); //----------------------------------------------------- pNode = Parameters.Add_Choice( NULL , "LOCATION" , _TL("Location"), _TL(""), CSG_String::Format("%s|%s|", _TL("constant latitude"), _TL("calculate from grid system") ), 0 ); Parameters.Add_Value( pNode , "LATITUDE" , _TL("Latitude"), _TL(""), PARAMETER_TYPE_Degree , 53.0, -90.0, true, 90.0, true ); //----------------------------------------------------- pNode = Parameters.Add_Choice( NULL , "PERIOD" , _TL("Time Period"), _TL(""), CSG_String::Format("%s|%s|%s|", _TL("moment"), _TL("day"), _TL("range of days") ), 1 ); Parameters.Add_Value( pNode , "MOMENT" , _TL("Moment [h]"), _TL(""), PARAMETER_TYPE_Double , 12.0, 0.0, true, 24.0, true ); Parameters.Add_Range( pNode , "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 ); Parameters.Add_Value( pNode , "HOUR_STEP" , _TL("Time Resolution [h]: Day"), _TL("Time step size for a day's calculation given in hours."), PARAMETER_TYPE_Double , 0.5, 0.0, true, 24.0, true ); Parameters.Add_Value( pNode , "DAYS_STEP" , _TL("Time Resolution [d]: Range of Days"), _TL("Time step size for a range of days calculation given in days."), PARAMETER_TYPE_Int , 5, 1, true ); //----------------------------------------------------- pNode_2 = Parameters.Add_Node(pNode, "DATE_A", _TL("Date"), _TL("")); Parameters.Add_Value (pNode_2, "DAY_A", _TL("Day" ), _TL(""), PARAMETER_TYPE_Int, CSG_DateTime::Get_Current_Day(), 1, true, 31, true); Parameters.Add_Choice(pNode_2, "MON_A", _TL("Month"), _TL(""), CSG_DateTime::Get_Month_Choices(), CSG_DateTime::Get_Current_Month()); Parameters.Add_Value (pNode_2, "YEAR_A", _TL("Year" ), _TL(""), PARAMETER_TYPE_Int, CSG_DateTime::Get_Current_Year()); pNode_2 = Parameters.Add_Node(pNode, "DATE_B", _TL("2nd Date (End of Range)"), _TL("")); Parameters.Add_Value (pNode_2, "DAY_B", _TL("Day" ), _TL(""), PARAMETER_TYPE_Int, CSG_DateTime::Get_Current_Day(), 1, true, 31, true); Parameters.Add_Choice(pNode_2, "MON_B", _TL("Month"), _TL(""), CSG_DateTime::Get_Month_Choices(), CSG_DateTime::Get_Current_Month()); Parameters.Add_Value (pNode_2, "YEAR_B", _TL("Year" ), _TL(""), PARAMETER_TYPE_Int, CSG_DateTime::Get_Current_Year()); //----------------------------------------------------- pNode = Parameters.Add_Choice( NULL , "METHOD" , _TL("Atmospheric Effects"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("Height of Atmosphere and Vapour Pressure"), _TL("Air Pressure, Water and Dust Content"), _TL("Lumped Atmospheric Transmittance"), _TL("Hofierka and Suri") ), 2 ); Parameters.Add_Value( pNode , "ATMOSPHERE" , _TL("Height of Atmosphere [m]"), _TL(""), PARAMETER_TYPE_Double , 12000.0, 0.0, true ); Parameters.Add_Value( pNode , "PRESSURE" , _TL("Barometric Pressure [mbar]"), _TL(""), PARAMETER_TYPE_Double, 1013, 0.0, true ); Parameters.Add_Value( pNode , "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 ); Parameters.Add_Value( pNode , "DUST" , _TL("Dust [ppm]"), _TL("Dust factor: 100 ppm (standard)"), PARAMETER_TYPE_Double, 100, 0.0, true ); Parameters.Add_Value( pNode , "LUMPED" , _TL("Lumped Atmospheric Transmittance [Percent]"), _TL("The transmittance of the atmosphere, usually between 60 and 80 percent."), PARAMETER_TYPE_Double, 70, 0.0, true, 100.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSolarRadiation::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "GRD_DEM") && pParameter->asGrid() && pParameter->asGrid()->Get_Projection().is_Okay() ) { CSG_Shapes srcCenter(SHAPE_TYPE_Point), dstCenter(SHAPE_TYPE_Point); srcCenter.Get_Projection() = pParameter->asGrid()->Get_Projection(); srcCenter.Add_Shape()->Add_Point(pParameter->asGrid()->Get_System().Get_Extent().Get_Center()); bool bResult; SG_RUN_MODULE(bResult, "pj_proj4", 2, // Coordinate Transformation (Shapes) SG_MODULE_PARAMETER_SET("SOURCE" , &srcCenter) && SG_MODULE_PARAMETER_SET("TARGET" , &dstCenter) && SG_MODULE_PARAMETER_SET("CRS_PROJ4", SG_T("+proj=longlat +ellps=WGS84 +datum=WGS84")) ) if( bResult ) { pParameters->Get_Parameter("LATITUDE")->Set_Value(dstCenter.Get_Shape(0)->Get_Point(0).y); } } return( CSG_Module_Grid::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CSolarRadiation::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "UPDATE") ) { pParameters->Set_Enabled("UPDATE_STRETCH", pParameter->asInt() == 2); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "LOCATION") ) { pParameters->Set_Enabled("LATITUDE" , pParameter->asInt() == 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "PERIOD") ) { pParameters->Set_Enabled("MOMENT" , pParameter->asInt() == 0); pParameters->Set_Enabled("GRD_DURATION" , pParameter->asInt() == 1); pParameters->Set_Enabled("GRD_SUNRISE" , pParameter->asInt() == 1); pParameters->Set_Enabled("GRD_SUNSET" , pParameter->asInt() == 1); pParameters->Set_Enabled("UPDATE" , pParameter->asInt() >= 1); pParameters->Set_Enabled("HOUR_RANGE" , pParameter->asInt() >= 1); pParameters->Set_Enabled("HOUR_STEP" , pParameter->asInt() >= 1); pParameters->Set_Enabled("DATE_B" , pParameter->asInt() == 2); pParameters->Set_Enabled("DAYS_STEP" , pParameter->asInt() == 2); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("GRD_VAPOUR" , pParameter->asInt() == 0); pParameters->Set_Enabled("ATMOSPHERE" , pParameter->asInt() == 0); pParameters->Set_Enabled("PRESSURE" , pParameter->asInt() == 1); pParameters->Set_Enabled("WATER" , pParameter->asInt() == 1); pParameters->Set_Enabled("DUST" , pParameter->asInt() == 1); pParameters->Set_Enabled("LUMPED" , pParameter->asInt() == 2); pParameters->Set_Enabled("GRD_LINKE" , pParameter->asInt() == 3); pParameters->Set_Enabled("LOCALSVF" , pParameter->asInt() != 3); } return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSolarRadiation::On_Execute(void) { //----------------------------------------------------- m_pDEM = Parameters("GRD_DEM" )->asGrid(); m_pSVF = Parameters("GRD_SVF" )->asGrid(); m_pVapour = Parameters("GRD_VAPOUR")->asGrid(); m_Vapour = Parameters("GRD_VAPOUR")->asDouble(); m_pLinke = Parameters("GRD_LINKE" )->asGrid(); m_Linke = Parameters("GRD_LINKE" )->asDouble(); m_pDirect = Parameters("GRD_DIRECT")->asGrid(); m_pDiffus = Parameters("GRD_DIFFUS")->asGrid(); m_pTotal = Parameters("GRD_TOTAL" )->asGrid(); m_pRatio = Parameters("GRD_RATIO" )->asGrid(); m_pDuration = NULL; m_pSunrise = NULL; m_pSunset = NULL; m_bLocalSVF = Parameters("LOCALSVF" )->asBool (); m_Shadowing = Parameters("SHADOW" )->asInt (); m_Method = Parameters("METHOD" )->asInt (); m_Atmosphere = Parameters("ATMOSPHERE")->asDouble(); m_Transmittance = Parameters("LUMPED" )->asDouble() / 100.0; // percent to ratio m_Pressure = Parameters("PRESSURE" )->asDouble(); m_Water = Parameters("WATER" )->asDouble(); m_Dust = Parameters("DUST" )->asDouble(); //----------------------------------------------------- CSG_Colors Colors(11, SG_COLORS_YELLOW_RED, true); Colors.Set_Ramp(SG_GET_RGB( 0, 0, 64), SG_GET_RGB(255, 159, 0), 0, 5); Colors.Set_Ramp(SG_GET_RGB(255, 159, 0), SG_GET_RGB(255, 255, 255), 5, 10); DataObject_Set_Colors(m_pDirect, Colors); DataObject_Set_Colors(m_pDiffus, Colors); DataObject_Set_Colors(m_pTotal , Colors); DataObject_Set_Colors(m_pRatio , 11, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- m_Latitude = Parameters("LATITUDE")->asDouble() * M_DEG_TO_RAD; if( (m_Location = Parameters("LOCATION")->asInt()) != 0 ) { m_Sun_Height .Create(*Get_System()); m_Sun_Azimuth.Create(*Get_System()); m_Lat .Create(*Get_System()); m_Lon .Create(*Get_System()); SG_RUN_MODULE_ExitOnError("pj_proj4", 17, // geographic coordinate grids SG_MODULE_PARAMETER_SET("GRID", m_pDEM) && SG_MODULE_PARAMETER_SET("LON" , &m_Lon) && SG_MODULE_PARAMETER_SET("LAT" , &m_Lat) ) m_Lat.Set_Scaling(M_DEG_TO_RAD); m_Lon.Set_Scaling(M_DEG_TO_RAD, -M_DEG_TO_RAD * m_Lon.asDouble(Get_NX() / 2, Get_NY() / 2)); Message_Add(CSG_String::Format("\n%s: %f <-> %f", _TL("Longitude"), M_RAD_TO_DEG * m_Lon.Get_ZMin(), M_RAD_TO_DEG * m_Lon.Get_ZMax()), false); Message_Add(CSG_String::Format("\n%s: %f <-> %f", _TL("Latitude" ), M_RAD_TO_DEG * m_Lat.Get_ZMin(), M_RAD_TO_DEG * m_Lat.Get_ZMax()), false); } //----------------------------------------------------- Process_Set_Text(_TL("Slopes")); m_Shade .Create(*Get_System()); m_Slope .Create(*Get_System()); m_Aspect.Create(*Get_System()); for(int y=0; yGet_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( Get_Insolation() ) { Finalize(); return( true ); } Finalize(); return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSolarRadiation::Finalize(void) { double dUnit; CSG_String Unit; //----------------------------------------------------- if( Parameters("PERIOD")->asInt() == 0 ) // moment { Unit = SG_T("W / m\xb2"); dUnit = 1000.0; } else switch( Parameters("UNITS")->asInt() ) { case 0: default: // [kWh / m2] Unit = SG_T("kWh / m\xb2"); dUnit = 1.0; break; case 1: // [kJ / m2] Unit = SG_T("kJ / m\xb2"); dUnit = 3600.0; break; case 2: // [Ws / cm2] = [J / cm2] Unit = SG_T("J / cm\xb2"); dUnit = 360.0; break; } //----------------------------------------------------- m_pDirect->Set_Unit(Unit); m_pDirect->Multiply(dUnit); m_pDiffus->Set_Unit(Unit); m_pDiffus->Multiply(dUnit); if( m_pTotal ) { m_pTotal->Assign(m_pDirect); m_pTotal->Add (*m_pDiffus); m_pTotal->Set_Unit(Unit); } if( m_pRatio ) { for(sLong i=0; iis_NoData(i) ) { m_pRatio->Set_NoData(i); } else { if( m_pDiffus->asDouble(i) > 0.0 ) { m_pRatio->Set_Value(i, m_pDirect->asDouble(i) / m_pDiffus->asDouble(i)); } } } } //----------------------------------------------------- m_Shade .Destroy(); m_Slope .Destroy(); m_Aspect .Destroy(); m_Lat .Destroy(); m_Lon .Destroy(); m_Sun_Height .Destroy(); m_Sun_Azimuth.Destroy(); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSolarRadiation::Get_Insolation(void) { //----------------------------------------------------- switch( Parameters("PERIOD")->asInt() ? Parameters("UPDATE")->asInt() : 0 ) { case 1: DataObject_Update(m_pDirect , SG_UI_DATAOBJECT_SHOW); break; case 2: DataObject_Update(m_pDirect, 0.0, Parameters("UPDATE_STRETCH")->asDouble(), SG_UI_DATAOBJECT_SHOW); break; } //----------------------------------------------------- CSG_DateTime Date((CSG_DateTime::TSG_DateTime)Parameters("DAY_A")->asInt(), (CSG_DateTime::Month)Parameters("MON_A")->asInt(), Parameters("YEAR_A")->asInt()); switch( Parameters("PERIOD")->asInt() ) { //----------------------------------------------------- case 0: // Moment m_pDirect->Assign(0.0); m_pDiffus->Assign(0.0); return( Get_Insolation(Date, Parameters("MOMENT")->asDouble()) ); //----------------------------------------------------- case 1: // One Day if( !!(m_pDuration = Parameters("GRD_DURATION")->asGrid()) ) { DataObject_Set_Colors(m_pDuration, 11, SG_COLORS_YELLOW_RED, true); m_pDuration->Assign_NoData(); m_pDuration->Set_Unit(_TL("h")); } if( !!(m_pSunrise = Parameters("GRD_SUNRISE" )->asGrid()) ) { DataObject_Set_Colors(m_pSunrise , 11, SG_COLORS_YELLOW_RED, false); m_pSunrise ->Assign_NoData(); m_pSunrise ->Set_Unit(_TL("h")); } if( !!(m_pSunset = Parameters("GRD_SUNSET" )->asGrid()) ) { DataObject_Set_Colors(m_pSunset , 11, SG_COLORS_YELLOW_RED, true); m_pSunset ->Assign_NoData(); m_pSunset ->Set_Unit(_TL("h")); } return( Get_Insolation(Date) ); //----------------------------------------------------- case 2: // Range of Days { CSG_DateTime Stop((CSG_DateTime::TSG_DateTime)Parameters("DAY_B")->asInt(), (CSG_DateTime::Month)Parameters("MON_B")->asInt(), Parameters("YEAR_B")->asInt()); int dDays = Parameters("DAYS_STEP")->asInt(); //--------------------------------------------- // one representative calculation if( Stop.Get_JDN() - Date.Get_JDN() <= dDays ) { Date.Set(Date.Get_JDN() + 0.5 * (dDays = (int)(Stop.Get_JDN() - Date.Get_JDN()))); Get_Insolation(Date); m_pDirect->Multiply(1 + dDays); m_pDiffus->Multiply(1 + dDays); } //--------------------------------------------- // more than one time step of days else { CSG_Grid Direct, Diffus; Direct.Create(*Get_System(), SG_DATATYPE_Float); Diffus.Create(*Get_System(), SG_DATATYPE_Float); Direct.Assign(0.0); Diffus.Assign(0.0); CSG_TimeSpan dStep(24.0 * dDays); for( ; Date<=Stop && Process_Get_Okay(false); Date+=dStep) { Get_Insolation(Date); SG_UI_Progress_Lock(true); Direct.Add(*m_pDirect); Diffus.Add(*m_pDiffus); SG_UI_Progress_Lock(false); } SG_UI_Progress_Lock(true); m_pDirect->Assign(&Direct); m_pDirect->Multiply(dDays); m_pDiffus->Assign(&Diffus); m_pDiffus->Multiply(dDays); SG_UI_Progress_Lock(false); } } return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSolarRadiation::Get_Insolation(CSG_DateTime Date) { SG_UI_Progress_Lock(true); //----------------------------------------------------- int Update = Parameters("UPDATE")->asInt(); double dUpdate = Parameters("UPDATE_STRETCH")->asDouble(); CSG_Grid Direct; //----------------------------------------------------- bool bWasDay = false; double Hour_A = Parameters("HOUR_RANGE")->asRange()->Get_LoVal(); double Hour_B = Parameters("HOUR_RANGE")->asRange()->Get_HiVal(); double dHour = Parameters("HOUR_STEP" )->asDouble(); m_pDirect->Assign(0.0); m_pDiffus->Assign(0.0); for(double Hour=Hour_A; Hour<=Hour_B && Set_Progress(Hour - Hour_A, Hour_B - Hour_A); Hour+=dHour) { SG_UI_Progress_Lock(false); bool bDay = Get_Insolation(Date, Hour); SG_UI_Progress_Lock(true); if( Update && (bDay || bWasDay) ) { bWasDay = bDay; switch( Update ) { case 1: DataObject_Update(m_pDirect , SG_UI_DATAOBJECT_SHOW); break; case 2: DataObject_Update(m_pDirect, 0.0, dUpdate, SG_UI_DATAOBJECT_SHOW); break; } if( bDay ) { if( !Direct.is_Valid() ) { Direct.Create(*m_pDirect); } else { Direct.Add (*m_pDirect); } m_pDirect->Assign(0.0); } } } //----------------------------------------------------- if( Update ) { m_pDirect->Assign(&Direct); } m_pDirect->Multiply(dHour); m_pDiffus->Multiply(dHour); SG_UI_Progress_Lock(false); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSolarRadiation::Get_Insolation(CSG_DateTime Date, double Hour) { Date.Set_Hour(Hour); Process_Set_Text(Date.Format("%A, %d. %B %Y, %X")); double JDN = floor(Date.Get_JDN()) - 0.5 + Hour / 24.0; // relate to UTC, avoid problems with daylight saving time //----------------------------------------------------- m_Solar_Const = Parameters("SOLARCONST")->asDouble() / 1000.0; // >> [kW / m²] m_Solar_Const *= 1.0 + 0.03344 * cos(Date.Get_DayOfYear() * 2.0 * M_PI / 365.25 - 0.048869); // corrected for Earth's orbit eccentricity //----------------------------------------------------- if( m_Location ) { bool bDayLight = false; for(int y=0; yasDouble(); for(int y=0; yis_NoData(x, y) ) { m_pDirect->Set_NoData(x, y); m_pDiffus->Set_NoData(x, y); } else { double Direct, Diffus; if( Get_Irradiance(x, y, m_Location ? m_Sun_Height .asDouble(x, y) : Sun_Height, m_Location ? m_Sun_Azimuth.asDouble(x, y) : Sun_Azimuth, Direct, Diffus) ) { m_pDirect->Add_Value(x, y, Direct); m_pDiffus->Add_Value(x, y, Diffus); if( Direct > 0.0 ) { if( m_pDuration ) { if( m_pDuration->is_NoData(x, y) ) { m_pDuration->Set_Value(x, y, dHour); } else { m_pDuration->Add_Value(x, y, dHour); } } if( m_pSunrise && (m_pSunrise->is_NoData(x, y) || m_pSunrise->asDouble(x, y) > Hour) ) { m_pSunrise->Set_Value(x, y, Hour); } if( m_pSunset ) { m_pSunset->Set_Value(x, y, Hour); } } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CSolarRadiation::Get_Air_Mass(double Sun_Height) { static const double Air_Mass[32] = // 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 }; //------------------------------------------------- if( Sun_Height > 30.0 * M_DEG_TO_RAD ) { return( 1.0 / cos(M_PI_090 - Sun_Height) ); } double z = 30.0 - M_RAD_TO_DEG * Sun_Height; int i = (int)z; return( Air_Mass[i] + (z - i) * (Air_Mass[i + 1] - Air_Mass[i]) ); } //--------------------------------------------------------- inline bool CSolarRadiation::Get_Irradiance(int x, int y, double Sun_Height, double Sun_Azimuth, double &Direct, double &Diffus) { //----------------------------------------------------- if( Sun_Height <= 0.0 ) { return( false ); } double Elevation = m_pDEM->asDouble(x, y); double Slope = m_Slope.asDouble(x, y); double Solar_Angle = m_Shade.asDouble(x, y) > 0.0 ? 0.0 : // solar incidence angle measured between the Sun and the inclined surface cos(Slope) * cos(Sun_Height - M_PI_090) + sin(Slope) * sin(M_PI_090 - Sun_Height) * cos(Sun_Azimuth - m_Aspect.asDouble(x, y)); //----------------------------------------------------- if( m_Method == 3 ) // Hofierka & Suri 2002 { double h_0 = Sun_Height; // * M_RAD_TO_DEG; // ???!! double sin_h_0 = sin(Sun_Height); double d_exp = Solar_Angle; double T_LK = m_pLinke && !m_pLinke->is_NoData(x, y) ? m_pLinke->asDouble(x, y) : m_Linke; //------------------------------------------------- double h_0ref = h_0 + 0.061359 * (0.1594 + 1.123 * h_0 + 0.065656 * h_0*h_0) / (1. + 28.9344 * h_0 + 277.3971 * h_0*h_0); double m = exp(-Elevation / 8434.5) / (sin_h_0 + 0.50572 * pow(h_0ref + 6.07995, -1.6364)); double d_R = m <= 20.0 ? 1. / ( 6.6296 + 1.7513 * m - 0.1202 * m*m + 0.0065 * m*m*m - 0.00013 * m*m*m*m) : 1. / (10.4 + 0.718 * m); double B_0c = m_Solar_Const * exp(-0.8662 * T_LK * m * d_R); double B_hc = B_0c * sin_h_0; Direct = B_0c * sin(d_exp); // B_ic //------------------------------------------------- double Tn = -0.015843 + 0.030543 * T_LK + 0.0003797 * T_LK*T_LK; double A1 = 0.26463 - 0.061581 * T_LK + 0.0031408 * T_LK*T_LK; if( A1 * Tn < 0.0022 ) A1 = 0.0022 / Tn; double A2 = 2.04020 + 0.018945 * T_LK - 0.011161 * T_LK*T_LK; double A3 = -1.3025 + 0.039231 * T_LK + 0.0085079 * T_LK*T_LK; double F_d = A1 + A2 * sin_h_0 + A3 * sin_h_0*sin_h_0; double D_hc = m_Solar_Const * Tn * F_d; double K_b = B_hc / (m_Solar_Const * sin_h_0); double F = 0.5 * (1. + cos(Slope)) + (sin(Slope) - Slope * cos(Slope) - M_PI * SG_Get_Square(sin(Slope / 2.0))); if( m_Shade.asDouble(x, y) > 0.0 ) // shadowed surface { Diffus = D_hc * F * 0.25227; } else if( Sun_Height >= 0.1 ) // sunlit surface, height of Sun above 5.7° { F *= 0.00263 - 0.712 * K_b - 0.6883 * K_b*K_b; // * N Diffus = D_hc * F * (1. - K_b) + K_b * sin(d_exp) / sin_h_0; } else { double A_LN = Sun_Azimuth - m_Aspect.asDouble(x, y); // if( A_LN < -M_PI_180 ) A_LN += M_PI_360; else if( A_LN > M_PI_180 ) A_LN -= M_PI_360; // quatsch!!! F *= 0.00263 - 0.712 * K_b - 0.6883 * K_b*K_b; // * N Diffus = D_hc * F * (1. - K_b) + K_b * sin(Slope) * cos(A_LN) / (0.1 - 0.008 * h_0); } if( m_pSVF && !m_pSVF->is_NoData(x, y) ) { Diffus *= m_pSVF->asDouble(x, y); } } //----------------------------------------------------- else { if( m_Method == 0 ) // Boehner { double A, E, Vapour; Vapour = m_pVapour && !m_pVapour->is_NoData(x, y) ? m_pVapour->asDouble(x, y) : m_Vapour; Vapour = Vapour > 0.0 ? sqrt(Vapour) : 0.0; E = 0.9160 - 0.05125 * Vapour; A = 0.4158 + 0.03990 * Vapour; Direct = pow(E, (1.0 - Elevation / m_Atmosphere) / sin(Sun_Height)); Diffus = m_Atmosphere / (m_Atmosphere - Elevation) * (0.0001165 * SG_Get_Square(M_RAD_TO_DEG * Sun_Height) - 0.0152 * M_RAD_TO_DEG * Sun_Height + A); Diffus = Direct * sin(Sun_Height) * (1.0 / (1.0 - Diffus) - 1.0); } //------------------------------------------------- else // TAPES { double Air_Mass = Get_Air_Mass(Sun_Height) * (m_Pressure / pow(10.0, Elevation * 5.4667E-05)) / 1013.0; //--------------------------------------------- if( m_Method == 1 ) // Air Pressure, Water and Dust Content { double AW, TW, TD, TDC; AW = 1.0 - 0.077 * pow(m_Water * Air_Mass, 0.3); // absorption by water vapour TW = pow(0.975, m_Water * Air_Mass); // scattering by water vapour | problem (?!): fortran source differs from paper TD = pow(0.950, m_Water * m_Dust / 100.0); // scattering by dust | problem (?!): 100ppm := 1, 300ppm := 2 TDC = pow(0.900, Air_Mass) + 0.026 * (Air_Mass - 1.0); // scattering by a dust free atmosphere Direct = AW * TW * TD * TDC; Diffus = 0.5 * (AW - Direct); } //--------------------------------------------- else // Lumped Atmospheric Transmittance { Direct = pow(m_Transmittance, Air_Mass); Diffus = 0.271 - 0.294 * Direct; } if( Sun_Height < M_RAD_TO_DEG ) { Diffus *= Sun_Height; } } //------------------------------------------------- Direct = Solar_Angle <= 0.0 ? 0.0 : Solar_Angle * Direct * m_Solar_Const; double SVF = m_pSVF && !m_pSVF->is_NoData(x, y) ? m_pSVF->asDouble(x, y) : m_bLocalSVF ? (1.0 + cos(Slope)) / 2.0 : 1.0; Diffus = m_Solar_Const * Diffus * SVF; } //----------------------------------------------------- if( Direct < 0.0 ) { Direct = 0.0; } else if( Direct > m_Solar_Const ) { Direct = m_Solar_Const; } if( Diffus < 0.0 ) { Diffus = 0.0; } else if( Diffus > m_Solar_Const ) { Diffus = m_Solar_Const; } return( true ); } //--------------------------------------------------------- /* 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 ====================================================================*/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CSolarRadiation::Get_Shade_Params(double Sun_Height, double Sun_Azimuth, double &dx, double &dy, double &dz) { if( Sun_Height <= 0.0 ) { return( false ); } dz = Sun_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(Sun_Height) * sqrt(dx*dx + dy*dy) * Get_Cellsize(); return( true ); } //--------------------------------------------------------- bool CSolarRadiation::Get_Shade(double Sun_Height, double Sun_Azimuth) { const double dShadow = 0.49; m_Shade.Assign(0.0); //----------------------------------------------------- if( m_Location == 0 ) { double dx, dy, dz; if( !Get_Shade_Params(Sun_Height, Sun_Azimuth, dx, dy, dz) ) { return( false ); } for(int y=0; yis_NoData(x, y) ) { switch( m_Shadowing ) { case 0: // slim Set_Shade(x, y, m_pDEM->asDouble(x, y), dx, dy, dz); break; case 1: // fat Set_Shade(x - dShadow, y - dShadow, m_pDEM->asDouble(x, y), dx, dy, dz); Set_Shade(x + dShadow, y - dShadow, m_pDEM->asDouble(x, y), dx, dy, dz); Set_Shade(x - dShadow, y + dShadow, m_pDEM->asDouble(x, y), dx, dy, dz); Set_Shade(x + dShadow, y + dShadow, m_pDEM->asDouble(x, y), dx, dy, dz); break; } } } } } //----------------------------------------------------- else { for(int y=0; yis_NoData(x, y) ) { switch( m_Shadowing ) { case 0: // slim Set_Shade_Bended(x, y, m_pDEM->asDouble(x, y)); break; case 1: // fat Set_Shade_Bended(x - dShadow, y - dShadow, m_pDEM->asDouble(x, y)); Set_Shade_Bended(x + dShadow, y - dShadow, m_pDEM->asDouble(x, y)); Set_Shade_Bended(x - dShadow, y + dShadow, m_pDEM->asDouble(x, y)); Set_Shade_Bended(x + dShadow, y + dShadow, m_pDEM->asDouble(x, y)); break; } } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- void CSolarRadiation::Set_Shade(double x, double y, double z, double dx, double dy, double dz) { for(x+=dx+0.5, y+=dy+0.5, z-=dz; ; x+=dx, y+=dy, z-=dz) { int ix = (int)x, iy = (int)y; if( !is_InGrid(ix, iy) ) { return; } if( !m_pDEM->is_NoData(ix, iy) ) { double zDiff = z - m_pDEM->asDouble(ix, iy); if( zDiff <= 0.0 ) { return; } m_Shade.Set_Value(ix, iy, zDiff); } } } //--------------------------------------------------------- void CSolarRadiation::Set_Shade_Bended(double x, double y, double z) { x += 0.5; y += 0.5; for(int ix=(int)x, iy=(int)y; ; ) { double dx, dy, dz; if( !Get_Shade_Params(m_Sun_Height.asDouble(ix, iy), m_Sun_Azimuth.asDouble(ix, iy), dx, dy, dz) ) { return; } x += dx; ix = (int)x; y += dy; iy = (int)y; z -= dz; if( !m_pDEM->is_InGrid(ix, iy) ) { return; } if( !m_pDEM->is_NoData(ix, iy) ) { double zDiff = z - m_pDEM->asDouble(ix, iy); if( zDiff <= 0.0 ) { return; } m_Shade.Set_Value(ix, iy, zDiff); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_lighting/view_shed.h0000664000175000017500000001127412565125415026027 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: view_shed.h 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // View_Shed.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__View_Shed_H #define HEADER_INCLUDED__View_Shed_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CView_Shed : public CSG_Module_Grid { public: CView_Shed(void); protected: virtual bool On_Execute (void); private: int m_Method, m_nLevels; double m_Radius; CSG_Points_Z m_Direction; CSG_Grid *m_pDEM; CSG_Grid_Pyramid m_Pyramid; bool Initialise (int nDirections); bool Get_Angles_Multi_Scale (int x, int y, CSG_Vector &Angles, CSG_Vector &Distances); bool Get_Angles_Sectoral (int x, int y, CSG_Vector &Angles, CSG_Vector &Distances); void Get_Angle_Sectoral (int x, int y, int i, double &Angle, double &Distance); bool Get_View_Shed (int x, int y, double &Sky_Visible, double &Sky_Factor, double &Sky_Simple, double &Sky_Terrain, double &Distance); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__View_Shed_H saga-2.2.3/src/modules/terrain_analysis/ta_lighting/topographic_correction.cpp0000664000175000017500000003130512565125415031150 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topographic_correction.cpp 2208 2014-08-27 16:00:51Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // topographic_correction.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "topographic_correction.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTopographic_Correction::CTopographic_Correction(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Topographic Correction")); Set_Author (_TL("Copyrights (c) 2008 by Olaf Conrad")); Set_Description (_TW( "\n" "References:\n" "Civco, D. L. (1989): " "'Topographic Normalization of Landsat Thematic Mapper Digital Imagery', " "Photogrammetric Engineering and Remote Sensing, 55(9), pp.1303-1309.\n" "\n" "Law, K.H., Nichol, J. (2004): " "'Topographic Correction for Differential Illumination Effects on Ikonos Satellite Imagery', " "ISPRS 2004 International Society for Photogrammetry and Remote Sensing, " "pdf.\n" "\n" "Phua, M.-H., Saito, H. (2003): " "'Estimation of biomass of a mountainous tropical forest using Landsat TM data', " "Canadian Journal of Remote Sensing, 29(4), pp.429-440.\n" "\n" "Riano, D., Chuvieco, E. Salas, J., Aguado, I. (2003): " "'Assessment of Different Topographic Corrections in Landsat-TM Data for Mapping Vegetation Types', " "IEEE Transactions on Geoscience and Remote Sensing, 41(5), pp.1056-1061, " "pdf.\n" "\n" "Teillet, P.M., Guindon, B., Goodenough, D.G. (1982): " "'On the slope-aspect correction of multispectral scanner data', " "Canadian Journal of Remote Sensing, 8(2), pp.1537-1540.\n" "\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT, false ); Parameters.Add_Grid( NULL , "ORIGINAL" , _TL("Original Image"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CORRECTED" , _TL("Corrected Image"), _TL(""), PARAMETER_OUTPUT ); pNode = Parameters.Add_Node(NULL, "NODE_SOLAR", _TL("Solar Position"), _TL("")); Parameters.Add_Value( pNode , "AZI" , _TL("Azimuth"), _TL("direction of sun (degree, clockwise from North)"), PARAMETER_TYPE_Double , 180.0, 0.0, true, 360.0, true ); Parameters.Add_Value( pNode , "HGT" , _TL("Height"), _TL("height of sun above horizon (degree)"), PARAMETER_TYPE_Double , 45.0, 0.0, true, 90.0, true ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|"), _TL("Cosine Correction (Teillet et al. 1982)"), _TL("Cosine Correction (Civco 1989)"), _TL("Minnaert Correction"), _TL("Minnaert Correction with Slope (Riano et al. 2003)"), _TL("Minnaert Correction with Slope (Law & Nichol 2004)"), _TL("C Correction"), _TL("Normalization (after Civco, modified by Law & Nichol)") ), 4 ); Parameters.Add_Value( NULL , "MINNAERT" , _TL("Minnaert Correction"), _TL(""), PARAMETER_TYPE_Double , 0.5, 0.0, true, 1.0, true ); Parameters.Add_Value( NULL , "MAXCELLS" , _TL("Maximum Cells (C Correction Analysis)"), _TL("Maximum number of grid cells used for trend analysis as required by C correction."), PARAMETER_TYPE_Int , 1000.0, 10.0, true ); Parameters.Add_Choice( NULL , "MAXVALUE" , _TL("Value Range"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("1 byte (0-255)"), _TL("2 byte (0-65535)") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTopographic_Correction::On_Execute(void) { //----------------------------------------------------- if( !Get_Illumination() ) { m_Slope .Destroy(); m_Illumination .Destroy(); return( false ); } if( !Get_Model() ) { m_Slope .Destroy(); m_Illumination .Destroy(); return( false ); } //----------------------------------------------------- Process_Set_Text(_TL("Topographic Correction")); for(int y=0; yis_NoData(x, y) ) { m_pCorrected->Set_NoData(x, y); } else { m_pCorrected->Set_Value(x, y, Get_Correction( m_Slope .asDouble(x, y), m_Illumination.asDouble(x, y), m_pOriginal ->asDouble(x, y) )); } } } //----------------------------------------------------- m_Slope .Destroy(); m_Illumination .Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CTopographic_Correction::Get_Correction(double Slope, double Illumination, double Value) { switch( m_Method ) { case 0: // Cosine Correction (Teillet et al. 1982) if( Illumination > 0.0 ) { Value = Value * m_cosTz / Illumination; } break; case 1: // Cosine Correction (Civco 1989) Value = Value + (Value * ((m_Illumination.Get_Mean() - Illumination) / m_Illumination.Get_Mean())); break; case 2: // Minnaert Correction if( Illumination > 0.0 ) { Value = Value * pow(m_cosTz / Illumination, m_Minnaert); } break; case 3: // Minnaert Correction with Slope (Riano et al. 2003) if( Illumination > 0.0 ) { Value = Value * cos(Slope) * pow(m_cosTz / (Illumination * cos(Slope)), m_Minnaert); } break; case 4: // Minnaert Correction with Slope (Law & Nichol 2004) if( Illumination > 0.0 ) { Value = Value * cos(Slope) / pow(Illumination * cos(Slope), m_Minnaert); } break; case 5: // C Correction Value = Value * (m_cosTz + m_C) / (Illumination + m_C); break; case 6: // Normalization Value = Value + ((Value * ((m_Illumination.Get_Mean() - Illumination) / m_Illumination.Get_Mean())) * m_C); break; } return( Value < 0 ? 0 : Value > m_maxValue ? m_maxValue : Value ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTopographic_Correction::Get_Model(void) { //----------------------------------------------------- m_pOriginal = Parameters("ORIGINAL") ->asGrid(); m_pCorrected = Parameters("CORRECTED") ->asGrid(); m_pCorrected ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pOriginal->Get_Name(), _TL("Topographic Correction"))); m_Method = Parameters("METHOD") ->asInt(); m_Minnaert = Parameters("MINNAERT") ->asDouble(); switch( Parameters("MAXVALUE")->asInt() ) { default: m_maxValue = 255; break; case 1: m_maxValue = 65535; break; } switch( m_Method ) { //----------------------------------------------------- case 5: // C Correction { Process_Set_Text(_TL("Regression Analysis")); CSG_Regression R; sLong n = Parameters("MAXCELLS")->asInt(); int nStep = Get_NCells() < n ? 1 : (int)(Get_NCells() / n); for(n=0; nasDouble(n), m_Illumination.asDouble(n)); } if( !R.Calculate() || !R.Get_Constant() ) { return( false ); } m_C = R.Get_Coefficient() / R.Get_Constant(); Message_Add(R.asString()); } break; //----------------------------------------------------- case 6: // Normalization (after Civco, modified by Law & Nichol) { m_C = 1.0; } break; } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTopographic_Correction::Get_Illumination(void) { Process_Set_Text(_TL("Illumination calculation")); //----------------------------------------------------- CSG_Grid DEM, *pDEM = Parameters("DEM")->asGrid(); if( !pDEM->Get_System().is_Equal(*Get_System()) ) { DEM.Create(*Get_System()); DEM.Assign(pDEM, pDEM->Get_Cellsize() > Get_Cellsize() ? GRID_INTERPOLATION_BSpline : GRID_INTERPOLATION_Mean_Cells); pDEM = &DEM; } //----------------------------------------------------- double Azi = Parameters("AZI")->asDouble() * M_DEG_TO_RAD; double Hgt = Parameters("HGT")->asDouble() * M_DEG_TO_RAD; m_cosTz = cos(M_PI_090 - Hgt); m_sinTz = sin(M_PI_090 - Hgt); m_Slope .Create(*Get_System()); m_Illumination .Create(*Get_System()); //----------------------------------------------------- for(int y=0; yGet_Gradient(x, y, Slope, Aspect) ) { m_Slope .Set_Value(x, y, Slope); m_Illumination .Set_Value(x, y, cos(Slope) * m_cosTz + sin(Slope) * m_sinTz * cos(Azi - Aspect)); } else { m_Slope .Set_Value(x, y, 0.0); m_Illumination .Set_Value(x, y, m_cosTz); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_lighting/MLB_Interface.cpp0000664000175000017500000001155512565125415027001 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2281 2014-10-09 15:49:41Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Lighting, Visibility" )); case MLB_INFO_Category: return( _TL("Terrain Analysis") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Wichmann (c) 2003-13") ); case MLB_INFO_Description: return( _TL("Lighting and visibility calculations for digital terrain models." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Terrain Analysis|Lighting" )); } } //--------------------------------------------------------- #include "HillShade.h" #include "Visibility_Point.h" #include "SolarRadiation.h" #include "view_shed.h" #include "topographic_correction.h" #include "topographic_openness.h" #include "Visibility_Points.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CHillShade ); case 1: return( new CVisibility_Point ); case 2: return( new CSolarRadiation ); case 3: return( new CView_Shed ); case 4: return( new CTopographic_Correction ); case 5: return( new CTopographic_Openness ); case 6: return( new CVisibility_Points ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/terrain_analysis/ta_lighting/Makefile.am0000664000175000017500000000163112565125415025731 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1613 2013-02-22 11:20:39Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_lighting.la libta_lighting_la_SOURCES =\ HillShade.cpp\ MLB_Interface.cpp\ SolarRadiation.cpp\ topographic_correction.cpp\ topographic_openness.cpp\ view_shed.cpp\ Visibility_BASE.cpp\ Visibility_Point.cpp\ Visibility_Points.cpp\ HillShade.h\ MLB_Interface.h\ SolarRadiation.h\ topographic_correction.h\ topographic_openness.h\ view_shed.h\ Visibility_BASE.h\ Visibility_Point.h\ Visibility_Points.h libta_lighting_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) saga-2.2.3/src/modules/terrain_analysis/ta_lighting/MLB_Interface.h0000664000175000017500000000771512565125415026451 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_lighting_H #define HEADER_INCLUDED__ta_lighting_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef ta_lighting_EXPORTS #define ta_lighting_EXPORT _SAGA_DLL_EXPORT #else #define ta_lighting_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ta_lighting_H saga-2.2.3/src/modules/terrain_analysis/ta_lighting/Visibility_Points.h0000664000175000017500000001054712565125415027537 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Visibility_Points.h 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // Visibility_Points.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Visibility_Points_H #define HEADER_INCLUDED__Visibility_Points_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include "Visibility_BASE.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CVisibility_Points : public CSG_Module_Grid, CVisibility_BASE { public: CVisibility_Points(void); virtual ~CVisibility_Points(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Visibility_Points_H saga-2.2.3/src/modules/terrain_analysis/ta_lighting/topographic_correction.h0000664000175000017500000001065112565125415030616 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topographic_correction.h 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // topographic_correction.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__topographic_correction_H #define HEADER_INCLUDED__topographic_correction_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTopographic_Correction : public CSG_Module_Grid { public: CTopographic_Correction(void); protected: virtual bool On_Execute (void); private: int m_Method, m_maxValue; double m_cosTz, m_sinTz, m_Minnaert, m_C; CSG_Grid *m_pOriginal, *m_pCorrected, m_Slope, m_Illumination; double Get_Correction (double Slope, double Incidence, double Value); bool Get_Illumination (void); bool Get_Model (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__topographic_correction_H saga-2.2.3/src/modules/terrain_analysis/ta_lighting/Visibility_Points.cpp0000664000175000017500000001411412565125415030064 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Visibility_Points.cpp 2137 2014-06-05 08:23:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // Visibility_Points.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Visibility_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CVisibility_Points::CVisibility_Points(void) { Set_Name(_TL("Visibility (points)")); Set_Author(SG_T("Volker Wichmann (c) 2013")); Set_Description(_TW( "This module computes a visibility analysis using observer points from a " "point shapefile.\n\n" )); Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "VISIBILITY" , _TL("Visibility"), _TL(""), PARAMETER_OUTPUT ); CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL("Observer points."), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "FIELD_HEIGHT", _TL("Height"), _TL("Height of the light source above ground."), false ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Unit"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Visibility"), _TL("Shade"), _TL("Distance"), _TL("Size") ), 1 ); } //--------------------------------------------------------- CVisibility_Points::~CVisibility_Points(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CVisibility_Points::On_Execute(void) { CSG_Grid *pDTM, *pVisibility; CSG_Shapes *pShapes; int iMethod, iField; pDTM = Parameters("ELEVATION") ->asGrid(); pVisibility = Parameters("VISIBILITY") ->asGrid(); pShapes = Parameters("POINTS") ->asShapes(); iField = Parameters("FIELD_HEIGHT")->asInt(); iMethod = Parameters("METHOD") ->asInt(); Initialize(pVisibility, iMethod); for(int iShape=0; iShapeGet_Count(); iShape++) { Process_Set_Text(CSG_String::Format(_TL("Processing observer %d ..."), iShape + 1)); int x, y; x = Get_System()->Get_xWorld_to_Grid(pShapes->Get_Shape(iShape)->Get_Point(0).x); y = Get_System()->Get_yWorld_to_Grid(pShapes->Get_Shape(iShape)->Get_Point(0).y); if( pDTM->is_InGrid(x, y, true) ) { double dHeight, z; dHeight = pShapes->Get_Record(iShape)->asDouble(iField); z = pDTM->asDouble(x, y) + dHeight; Set_Visibility(pDTM, pVisibility, x, y, z, dHeight, iMethod); } } //----------------------------------------------------- Finalize(pVisibility, iMethod); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_lighting/Visibility_BASE.cpp0000664000175000017500000002016312565125415027323 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Visibility_BASE.cpp 2208 2014-08-27 16:00:51Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_lighting // // // //-------------------------------------------------------// // // // Visibility_BASE.cpp // // // // Copyright (C) 2003, 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Visibility_BASE.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CVisibility_BASE::Initialize(CSG_Grid *pVisibility, int iMethod) { CSG_Colors Colors; switch( iMethod ) { case 0: // Visibility pVisibility->Assign(0.0); Colors.Set_Count(2); Colors.Set_Ramp(SG_GET_RGB(0, 0, 0), SG_GET_RGB(255, 255, 255)); break; case 1: // Shade pVisibility->Assign(M_PI_090); pVisibility->Set_Unit(_TL("radians")); Colors.Set_Ramp(SG_GET_RGB(255, 255, 255), SG_GET_RGB(0, 0, 0)); break; case 2: // Distance pVisibility->Assign_NoData(); Colors.Set_Ramp(SG_GET_RGB(255, 255, 191), SG_GET_RGB(0, 95, 0)); break; case 3: // Size pVisibility->Assign_NoData(); pVisibility->Set_Unit(_TL("radians")); Colors.Set_Ramp(SG_GET_RGB(0, 95, 0), SG_GET_RGB(255, 255, 191)); break; } SG_UI_DataObject_Colors_Set(pVisibility, &Colors); return; } //--------------------------------------------------------- void CVisibility_BASE::Set_Visibility(CSG_Grid *pDTM, CSG_Grid *pVisibility, int x_Pos, int y_Pos, double z_Pos, double dHeight, int iMethod) { double Exaggeration = 1.0; double aziDTM, decDTM, aziSrc, decSrc, d, dx, dy, dz; for(int y=0; yGet_NY() && SG_UI_Process_Set_Progress(y, pDTM->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { if( pDTM->is_NoData(x, y) ) { pVisibility->Set_NoData(x, y); } else { dx = x_Pos - x; dy = y_Pos - y; dz = z_Pos - pDTM->asDouble(x, y); //----------------------------------------- if( Trace_Point(pDTM, x, y, dx, dy, dz) ) { switch( iMethod ) { case 0: // Visibility pVisibility->Set_Value(x, y, 1); break; case 1: // Shade pDTM->Get_Gradient(x, y, decDTM, aziDTM); decDTM = M_PI_090 - atan(Exaggeration * tan(decDTM)); decSrc = atan2(dz, sqrt(dx*dx + dy*dy)); aziSrc = atan2(dx, dy); d = acos(sin(decDTM) * sin(decSrc) + cos(decDTM) * cos(decSrc) * cos(aziDTM - aziSrc)); if( d > M_PI_090 ) d = M_PI_090; if( pVisibility->asDouble(x, y) > d ) pVisibility->Set_Value(x, y, d); break; case 2: // Distance d = pDTM->Get_Cellsize() * sqrt(dx*dx + dy*dy); if( pVisibility->is_NoData(x, y) || pVisibility->asDouble(x, y) > d ) pVisibility->Set_Value(x, y, d); break; case 3: // Size if( (d = pDTM->Get_Cellsize() * sqrt(dx*dx + dy*dy)) > 0.0 ) { d = atan2(dHeight, d); if( pVisibility->is_NoData(x, y) || pVisibility->asDouble(x, y) < d ) pVisibility->Set_Value(x, y, d); } break; } } } } } return; } //--------------------------------------------------------- bool CVisibility_BASE::Trace_Point(CSG_Grid *pDTM, int x, int y, double dx, double dy, double dz) { double ix, iy, iz, id, d, dist; d = fabs(dx) > fabs(dy) ? fabs(dx) : fabs(dy); if( d > 0 ) { dist = sqrt(dx*dx + dy*dy); dx /= d; dy /= d; dz /= d; d = dist / d; id = 0.0; ix = x + 0.5; iy = y + 0.5; iz = pDTM->asDouble(x, y); while( id < dist ) { id += d; ix += dx; iy += dy; iz += dz; x = (int)ix; y = (int)iy; if( !pDTM->is_InGrid(x, y) ) { return( true ); } else if( iz < pDTM->asDouble(x, y) ) { return( false ); } else if( iz > pDTM->Get_ZMax() ) { return( true ); } } } return( true ); } //--------------------------------------------------------- void CVisibility_BASE::Finalize(CSG_Grid *pVisibility, int iMethod) { CSG_Parameters Parameters; switch( iMethod ) { case 0: // Visibility Parameters.Add_Range(NULL, SG_T("METRIC_ZRANGE"), SG_T(""), SG_T(""), 0.0, 1.0); SG_UI_DataObject_Update(pVisibility, true, &Parameters); break; case 1: // Shade Parameters.Add_Range(NULL, SG_T("METRIC_ZRANGE"), SG_T(""), SG_T(""), 0.0, M_PI_090); SG_UI_DataObject_Update(pVisibility, true, &Parameters); break; case 2: // Distance case 3: // Size SG_UI_DataObject_Show(pVisibility, true); break; } return; } //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/Makefile.in0000664000175000017500000004571712622651175023467 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 = ta_slope_stability ta_profiles ta_preprocessor ta_morphometry ta_lighting ta_hydrology ta_compound ta_channels 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) --foreign src/modules/terrain_analysis/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/terrain_analysis/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/terrain_analysis/ta_compound/0000775000175000017500000000000012634325752023716 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/terrain_analysis/ta_compound/TA_Standard.cpp0000664000175000017500000003057012565125415026550 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: TA_Standard.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "TA_Standard.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTA_Standard::CTA_Standard(void) { //----------------------------------------------------- Set_Name (_TL("Basic Terrain Analysis")); Set_Author ("O.Conrad (c) 2005"); Set_Description (_TW( "A selection of basic parameters and objects to be derived from a Digital Terrain Model using standard settings." )); //----------------------------------------------------- Parameters.Add_Grid (NULL, "ELEVATION" , _TL("Elevation" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid (NULL, "SHADE" , _TL("Analytical Hillshading" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid (NULL, "SLOPE" , _TL("Slope" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid (NULL, "ASPECT" , _TL("Aspect" ), _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, "SINKS" , _TL("Closed Depressions" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid (NULL, "CAREA" , _TL("Total Catchment Area" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid (NULL, "WETNESS" , _TL("Topographic Wetness Index" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid (NULL, "LSFACTOR" , _TL("LS-Factor" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Shapes(NULL, "CHANNELS" , _TL("Channel Network" ), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line); Parameters.Add_Shapes(NULL, "BASINS" , _TL("Drainage Basins" ), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon); Parameters.Add_Grid (NULL, "CHNL_BASE" , _TL("Channel Network Base Level"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid (NULL, "CHNL_DIST" , _TL("Channel Network Distance" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid (NULL, "VALL_DEPTH" , _TL("Valley Depth" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid (NULL, "RSP" , _TL("Relative Slope Position" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Value( NULL , "THRESHOLD" , _TL("Channel Density"), _TL("Strahler order to begin a channel."), PARAMETER_TYPE_Int, 5, 1, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTA_Standard::On_Execute(void) { CSG_Grid DEMP(*Get_System(), SG_DATATYPE_Float); CSG_Grid TMP1(*Get_System(), SG_DATATYPE_Float); CSG_Grid TMP2(*Get_System(), SG_DATATYPE_Float); //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("ta_preprocessor" , 2, SG_MODULE_PARAMETER_SET("DEM" , Parameters("ELEVATION")) && SG_MODULE_PARAMETER_SET("DEM_PREPROC" , &DEMP) // >> preprocessed DEM ) Parameters("SINKS")->asGrid()->Set_NoData_Value(0.0); // Parameters("SINKS")->asGrid()->Assign(&(TMP2 = DEMP - *Parameters("ELEVATION")->asGrid())); SG_RUN_MODULE_ExitOnError("grid_calculus" , 1, // grid calculator SG_MODULE_PARAMETER_SET("RESULT" , Parameters("SINKS")) && SG_MODULE_PARAMETER_SET("FORMULA" , SG_T("g1 - g2")) && SG_MODULE_PARAMETER_SET("NAME" , _TL("Closed Depressions")) && SG_MODULE_PARAMLIST_ADD("GRIDS" , &DEMP) && SG_MODULE_PARAMLIST_ADD("GRIDS" , Parameters("ELEVATION")->asGrid()) ) //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("ta_lighting" , 0, SG_MODULE_PARAMETER_SET("ELEVATION" , &DEMP) && SG_MODULE_PARAMETER_SET("SHADE" , Parameters("SHADE")) ) //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("ta_morphometry" , 0, SG_MODULE_PARAMETER_SET("ELEVATION" , &DEMP) && SG_MODULE_PARAMETER_SET("SLOPE" , Parameters("SLOPE")) && SG_MODULE_PARAMETER_SET("ASPECT" , Parameters("ASPECT")) && SG_MODULE_PARAMETER_SET("C_CROS" , (CSG_Grid *)NULL) && SG_MODULE_PARAMETER_SET("C_LONG" , (CSG_Grid *)NULL) ) SG_RUN_MODULE_ExitOnError("grid_filter" , 0, SG_MODULE_PARAMETER_SET("INPUT" , &DEMP) && SG_MODULE_PARAMETER_SET("RESULT" , &TMP1) && SG_MODULE_PARAMETER_SET("RADIUS" , 3) ) SG_RUN_MODULE_ExitOnError("ta_morphometry" , 0, SG_MODULE_PARAMETER_SET("ELEVATION" , &TMP1) && SG_MODULE_PARAMETER_SET("SLOPE" , &TMP2) && SG_MODULE_PARAMETER_SET("ASPECT" , &TMP2) && SG_MODULE_PARAMETER_SET("C_CROS" , Parameters("HCURV")) && SG_MODULE_PARAMETER_SET("C_LONG" , Parameters("VCURV")) ) //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("ta_morphometry" , 1, SG_MODULE_PARAMETER_SET("ELEVATION" , &TMP1) && SG_MODULE_PARAMETER_SET("RESULT" , Parameters("CONVERGENCE")) ) //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("ta_hydrology" , 0, SG_MODULE_PARAMETER_SET("ELEVATION" , &DEMP) // << preprocessed DEM && SG_MODULE_PARAMETER_SET("CAREA" , Parameters("CAREA")) && SG_MODULE_PARAMETER_SET("METHOD" , 4) // MFD ) //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("ta_hydrology" , 19, SG_MODULE_PARAMETER_SET("DEM" , &DEMP) && SG_MODULE_PARAMETER_SET("TCA" , Parameters("CAREA")) && SG_MODULE_PARAMETER_SET("WIDTH" , &TMP2) && SG_MODULE_PARAMETER_SET("SCA" , &TMP1) // >> specific catchment area && SG_MODULE_PARAMETER_SET("METHOD" , 1) ) //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("ta_hydrology" , 20, SG_MODULE_PARAMETER_SET("SLOPE" , Parameters("SLOPE")) && SG_MODULE_PARAMETER_SET("AREA" , &TMP1) // << specific catchment area && SG_MODULE_PARAMETER_SET("TWI" , Parameters("WETNESS")) && SG_MODULE_PARAMETER_SET("CONV" , 0) ) //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("ta_hydrology" , 22, SG_MODULE_PARAMETER_SET("SLOPE" , Parameters("SLOPE")) && SG_MODULE_PARAMETER_SET("AREA" , &TMP1) // << specific catchment area && SG_MODULE_PARAMETER_SET("LS" , Parameters("LSFACTOR")) && SG_MODULE_PARAMETER_SET("CONV" , 0) ) //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("ta_channels" , 5, SG_MODULE_PARAMETER_SET("DEM" , &DEMP) // << preprocessed DEM && SG_MODULE_PARAMETER_SET("SEGMENTS" , Parameters("CHANNELS")) && SG_MODULE_PARAMETER_SET("BASINS" , Parameters("BASINS")) && SG_MODULE_PARAMETER_SET("ORDER" , &TMP1) && SG_MODULE_PARAMETER_SET("THRESHOLD" , Parameters("THRESHOLD")) ) //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("ta_channels" , 3, SG_MODULE_PARAMETER_SET("ELEVATION" , &DEMP) && SG_MODULE_PARAMETER_SET("CHANNELS" , &TMP1) && SG_MODULE_PARAMETER_SET("DISTANCE" , Parameters("CHNL_DIST")) && SG_MODULE_PARAMETER_SET("BASELEVEL" , Parameters("CHNL_BASE")) ) //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("grid_tools" , 19, // grid orientation SG_MODULE_PARAMETER_SET("INPUT" , &DEMP) && SG_MODULE_PARAMETER_SET("RESULT" , &TMP1) && SG_MODULE_PARAMETER_SET("METHOD" , 3) // invert ) SG_RUN_MODULE_ExitOnError("ta_channels" , 6, // strahler order SG_MODULE_PARAMETER_SET("DEM" , &TMP1) && SG_MODULE_PARAMETER_SET("STRAHLER" , &TMP2) ) TMP2.Set_NoData_Value_Range(0, 4); SG_RUN_MODULE_ExitOnError("ta_channels" , 3, // vertical channel network distance SG_MODULE_PARAMETER_SET("ELEVATION" , &TMP1) && SG_MODULE_PARAMETER_SET("CHANNELS" , &TMP2) && SG_MODULE_PARAMETER_SET("DISTANCE" , Parameters("VALL_DEPTH")) ) Parameters("VALL_DEPTH")->asGrid()->Set_Name(_TL("Valley Depth")); SG_RUN_MODULE_ExitOnError("grid_calculus" , 1, // grid calculator SG_MODULE_PARAMETER_SET("RESULT" , Parameters("RSP")) && SG_MODULE_PARAMETER_SET("FORMULA" , SG_T("g1 / (g1 + g2)")) && SG_MODULE_PARAMETER_SET("NAME" , _TL("Relative Slope Position")) && SG_MODULE_PARAMLIST_ADD("GRIDS" , Parameters("CHNL_DIST" )->asGrid()) && SG_MODULE_PARAMLIST_ADD("GRIDS" , Parameters("VALL_DEPTH")->asGrid()) ) //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_compound/Makefile.in0000664000175000017500000005425712622651176025777 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/ta_compound DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libta_compound_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libta_compound_la_OBJECTS = MLB_Interface.lo TA_Standard.lo libta_compound_la_OBJECTS = $(am_libta_compound_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libta_compound_la_SOURCES) DIST_SOURCES = $(libta_compound_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) 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 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) --foreign src/modules/terrain_analysis/ta_compound/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libta_compound.la: $(libta_compound_la_OBJECTS) $(libta_compound_la_DEPENDENCIES) $(EXTRA_libta_compound_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libta_compound_la_OBJECTS) $(libta_compound_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TA_Standard.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/terrain_analysis/ta_compound/TA_Standard.h0000664000175000017500000001043712565125415026215 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: TA_Standard.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__TA_Standard_H saga-2.2.3/src/modules/terrain_analysis/ta_compound/MLB_Interface.cpp0000664000175000017500000001116412565125415027014 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Compound Analyses" )); case MLB_INFO_Category: return( _TL("Terrain Analysis") ); 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 saga-2.2.3/src/modules/terrain_analysis/ta_compound/Makefile.am0000664000175000017500000000115112565125415025745 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) 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 saga-2.2.3/src/modules/terrain_analysis/ta_compound/MLB_Interface.h0000664000175000017500000000741612565125415026466 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ta_compound_H saga-2.2.3/src/modules/terrain_analysis/ta_profiles/0000775000175000017500000000000012634325751023714 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_Cross_Profiles.cpp0000664000175000017500000002442312565125415030324 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Cross_Profiles.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // Grid_Cross_Profiles.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Cross_Profiles.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define OFFSET 3 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Cross_Profiles::CGrid_Cross_Profiles(void) { Set_Name (_TL("Cross Profiles")); Set_Author (SG_T("O.Conrad (c) 2006")); Set_Description (_TW( "Create cross profiles from a grid based DEM for given lines.\n" )); Parameters.Add_Grid( NULL, "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL, "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT , SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL, "PROFILES" , _TL("Cross Profiles"), _TL(""), PARAMETER_OUTPUT , SHAPE_TYPE_Line ); Parameters.Add_Value( NULL, "DIST_LINE" , _TL("Profile Distance"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Value( NULL, "DIST_PROFILE", _TL("Profile Length"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Value( NULL, "NUM_PROFILE" , _TL("Profile Samples"), _TL(""), PARAMETER_TYPE_Int , 10.0, 3.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Cross_Profiles::On_Execute(void) { int iLine, iPart, iPoint, nSamples; double Distance, Length, dLine, dist, dx, dy; TSG_Point iPt, jPt, dPt, aPt, bPt; CSG_Shapes *pLines, *pProfiles; CSG_Shape *pLine, *pProfile; //----------------------------------------------------- m_pDEM = Parameters("DEM") ->asGrid(); pProfiles = Parameters("PROFILES") ->asShapes(); pLines = Parameters("LINES") ->asShapes(); Distance = Parameters("DIST_LINE") ->asDouble(); Length = Parameters("DIST_PROFILE")->asDouble(); nSamples = Parameters("NUM_PROFILE") ->asInt(); //----------------------------------------------------- pProfiles->Create(SHAPE_TYPE_Line, _TL("Profiles")); pProfiles->Add_Field("ID" , SG_DATATYPE_Int); pProfiles->Add_Field("LINE" , SG_DATATYPE_Int); pProfiles->Add_Field("PART" , SG_DATATYPE_Int); for(iPoint=0; iPointAdd_Field(CSG_String::Format(SG_T("X%03d"), iPoint), SG_DATATYPE_Double); } //----------------------------------------------------- for(iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); for(iPart=0; iPartGet_Part_Count(); iPart++) { if( pLine->Get_Point_Count(iPart) > 1 ) { dist = 0.0; iPt = pLine->Get_Point(0, iPart); for(iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { jPt = iPt; iPt = pLine->Get_Point(iPoint, iPart); dx = iPt.x - jPt.x; dy = iPt.y - jPt.y; dLine = sqrt(dx*dx + dy*dy); dx /= dLine; dy /= dLine; while( dist < dLine ) { dPt.x = jPt.x + dist * dx; dPt.y = jPt.y + dist * dy; if( m_pDEM->is_InGrid_byPos(dPt) ) { aPt.x = dPt.x + dy * Length; aPt.y = dPt.y - dx * Length; bPt.x = dPt.x - dy * Length; bPt.y = dPt.y + dx * Length; pProfile = pProfiles->Add_Shape(); pProfile->Add_Point(aPt); pProfile->Add_Point(bPt); pProfile->Set_Value(0, pProfiles->Get_Count()); pProfile->Set_Value(1, iLine); pProfile->Set_Value(2, iPart); Get_Profile(pProfile, aPt, bPt, nSamples); } dist += Distance; } dist -= dLine; } } } } //----------------------------------------------------- return( pProfiles->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Cross_Profiles::Get_Profile(CSG_Shape *pProfile, TSG_Point A, TSG_Point B, int nSamples) { if( 1 ) { double d, dx, dy, z; dx = B.x - A.x; dy = B.y - A.y; // d = sqrt(dx*dx + dy*dy) / (nSamples - 1); d = (nSamples - 1); dx /= d; dy /= d; for(int i=0; iGet_Value(A, z) ) { pProfile->Set_Value (OFFSET + i, z); } else { pProfile->Set_NoData (OFFSET + i); } A.x += dx; A.y += dy; } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// /*/--------------------------------------------------------- #include //--------------------------------------------------------- #define NBOXES 4 //--------------------------------------------------------- void CGrid_Cross_Profiles::Make_Report(const SG_Char *FileName, CSG_Grid *pDEM, CSG_Shapes *pLines, CSG_Shapes *pProfiles, double Distance) { if( FileName ) { int iProfile, iPoint, nSamples, iBox; CSG_Rect r; CSG_Shape *pProfile, *pLine; CSG_Shapes Profile; CSG_Doc_PDF pdf; pdf.Open(PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_PORTRAIT, _TL("Cross Profiles")); pdf.Layout_Add_Box(5, 5, 95, 20); pdf.Layout_Add_Box(5, 25, 95, 45); pdf.Layout_Add_Box(5, 50, 95, 70); pdf.Layout_Add_Box(5, 75, 95, 90); nSamples = pProfiles->Get_Field_Count() - OFFSET; Distance = Distance / (nSamples - 1); iBox = 0; for(iProfile=0; iProfileGet_Count() && Set_Progress(iProfile, pProfiles->Get_Count()); iProfile++) { pProfile = pProfiles->Get_Shape(iProfile); Profile.Create(SHAPE_TYPE_Line); pLine = Profile.Add_Shape(); for(iPoint=0; iPointis_NoData(OFFSET + iPoint) ) { pLine->Add_Point( (iPoint - nSamples / 2) * Distance, pProfile->asDouble(OFFSET + iPoint) ); } } if( pLine->Get_Point_Count(0) > 1 ) { if( iBox >= NBOXES ) { pdf.Add_Page(); iBox = 0; } // pdf.Draw_Graticule (pdf.Layout_Get_Box(iBox), Profile.Get_Extent(), 20); // pdf.Draw_Shapes (pdf.Layout_Get_Box(iBox), &Profile); r = pLine->Get_Extent(); r.Inflate(10); pdf.Draw_Graticule (pdf.Layout_Get_Box(iBox), r, 15); pdf.Draw_Shape (pdf.Layout_Get_Box(iBox), pLine, PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_GREEN, SG_COLOR_BLACK, 1, &r); iBox++; } } pdf.Save(Parameters("DOCUMENT")->asString()); } }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_Flow_Profile.cpp0000664000175000017500000002150512565125415027755 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Flow_Profile.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // Grid_Flow_Profile.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Flow_Profile.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define VALUE_OFFSET 6 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Flow_Profile::CGrid_Flow_Profile(void) { Set_Name(_TL("Flow Path Profile")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description (_TW( "Create interactively flow path profiles from a grid based DEM\n" "Use a left mouse button click to create a flow profile starting from the clicked point.") ); Parameters.Add_Grid( NULL, "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL, "VALUES" , _TL("Values"), _TL("Additional values that shall be saved to the output table."), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Shapes( NULL, "POINTS" , _TL("Profile Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL, "LINE" , _TL("Profile Line"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Flow_Profile::On_Execute(void) { m_pDEM = Parameters("DEM" )->asGrid(); m_pValues = Parameters("VALUES")->asGridList(); m_pPoints = Parameters("POINTS")->asShapes(); m_pLines = Parameters("LINE" )->asShapes(); //----------------------------------------------------- m_pPoints->Create(SHAPE_TYPE_Point, CSG_String::Format("%s [%s]", m_pDEM->Get_Name(), _TL("Profile"))); m_pPoints->Add_Field("ID" , SG_DATATYPE_Int); m_pPoints->Add_Field(_TL("Distance"), SG_DATATYPE_Double); m_pPoints->Add_Field(_TL("Overland"), SG_DATATYPE_Double); m_pPoints->Add_Field("X" , SG_DATATYPE_Double); m_pPoints->Add_Field("Y" , SG_DATATYPE_Double); m_pPoints->Add_Field("Z" , SG_DATATYPE_Double); for(int i=0; iGet_Count(); i++) { m_pPoints->Add_Field(m_pValues->asGrid(i)->Get_Name(), SG_DATATYPE_Double); } //----------------------------------------------------- m_pLines->Create(SHAPE_TYPE_Line, CSG_String::Format("%s [%s]", m_pDEM->Get_Name(), _TL("Profile"))); m_pLines->Add_Field("ID" , SG_DATATYPE_Int); m_pLine = m_pLines->Add_Shape(); m_pLine->Set_Value(0, 1); //----------------------------------------------------- DataObject_Update(m_pDEM , SG_UI_DATAOBJECT_SHOW_NEW_MAP ); DataObject_Update(m_pLines, SG_UI_DATAOBJECT_SHOW_LAST_MAP); Set_Drag_Mode(MODULE_INTERACTIVE_DRAG_NONE); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Flow_Profile::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { switch( Mode ) { case MODULE_INTERACTIVE_LDOWN: case MODULE_INTERACTIVE_MOVE_LDOWN: return( Set_Profile(Get_System()->Fit_to_Grid_System(ptWorld)) ); default: return( false ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Flow_Profile::Set_Profile(TSG_Point ptWorld) { int x, y; if( !Get_System()->Get_World_to_Grid(x, y, ptWorld) || !m_pDEM->is_InGrid(x, y) ) { return( false ); } m_pPoints->Del_Shapes(); m_pLine ->Del_Parts (); //----------------------------------------------------- int Direction; while( Add_Point(x, y) && (Direction = m_pDEM->Get_Gradient_NeighborDir(x, y)) >= 0 ) { x += Get_System()->Get_xTo(Direction); y += Get_System()->Get_yTo(Direction); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGrid_Flow_Profile::Add_Point(int x, int y) { if( !m_pDEM->is_InGrid(x, y) ) { return( false ); } TSG_Point Point = Get_System()->Get_Grid_to_World(x, y); double d, dSurface; if( m_pPoints->Get_Count() == 0 ) { d = dSurface = 0.0; } else { CSG_Shape *pLast = m_pPoints->Get_Shape(m_pPoints->Get_Count() - 1); d = SG_Get_Distance(Point, pLast->Get_Point(0)); dSurface = pLast->asDouble(5) - m_pDEM->asDouble(x, y); dSurface = sqrt(d*d + dSurface*dSurface); d += pLast->asDouble(1); dSurface += pLast->asDouble(2); } CSG_Shape *pPoint = m_pPoints->Add_Shape(); pPoint->Add_Point(Point); pPoint->Set_Value(0, m_pPoints->Get_Count()); pPoint->Set_Value(1, d); pPoint->Set_Value(2, dSurface); pPoint->Set_Value(3, Point.x); pPoint->Set_Value(4, Point.y); pPoint->Set_Value(5, m_pDEM->asDouble(x, y)); for(int i=0; iGet_Count(); i++) { pPoint->Set_Value(VALUE_OFFSET + i, m_pValues->asGrid(i)->asDouble(x, y)); } m_pLine->Add_Point(Point); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_Cross_Profiles.h0000664000175000017500000001043012565125415027762 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Cross_Profiles.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // Grid_Cross_Profiles.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Cross_Profiles_H #define HEADER_INCLUDED__Grid_Cross_Profiles_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Cross_Profiles : public CSG_Module_Grid { public: CGrid_Cross_Profiles(void); protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM; bool Get_Profile (CSG_Shape *pProfile, TSG_Point A, TSG_Point B, int nSamples); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Cross_Profiles_H saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_Swath_Profile.h0000664000175000017500000001141312565125415027576 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Swath_Profile.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // Grid_Swath_Profile.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Swath_Profile_H #define HEADER_INCLUDED__Grid_Swath_Profile_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Swath_Profile : public CSG_Module_Grid_Interactive { public: CGrid_Swath_Profile(void); protected: virtual bool On_Execute (void); virtual bool On_Execute_Finish (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: bool m_bAdd; double m_Width; CSG_Shapes *m_pPoints, *m_pLine; CSG_Grid *m_pDEM; CSG_Parameter_Grid_List *m_pValues; bool Set_Profile (void); bool Set_Profile (CSG_Point A, CSG_Point B, CSG_Point Left, CSG_Point Right); bool Add_Point (CSG_Point Point, CSG_Point Left, CSG_Point Right, CSG_Point Step); bool Add_Swath (CSG_Shape *pPoint, int iEntry, CSG_Grid *pGrid, CSG_Point Left, CSG_Point Right, CSG_Point Step); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Swath_Profile_H saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_Flow_Profile.h0000664000175000017500000001073512565125415027425 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Flow_Profile.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // Grid_Flow_Profile.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Flow_Profile_H #define HEADER_INCLUDED__Grid_Flow_Profile_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Flow_Profile : public CSG_Module_Grid_Interactive { public: CGrid_Flow_Profile(void); protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CSG_Shapes *m_pPoints, *m_pLines; CSG_Shape *m_pLine; CSG_Grid *m_pDEM; CSG_Parameter_Grid_List *m_pValues; bool Set_Profile (TSG_Point ptWorld); bool Add_Point (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Flow_Profile_H saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Makefile.in0000664000175000017500000005573612622651177026002 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/ta_profiles DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libta_profiles_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libta_profiles_la_OBJECTS = Grid_Cross_Profiles.lo \ Grid_Flow_Profile.lo Grid_Profile.lo Grid_ProfileFromPoints.lo \ Grid_Profile_From_Lines.lo Grid_Swath_Profile.lo \ MLB_Interface.lo libta_profiles_la_OBJECTS = $(am_libta_profiles_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libta_profiles_la_SOURCES) DIST_SOURCES = $(libta_profiles_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_profiles.la libta_profiles_la_SOURCES = \ Grid_Cross_Profiles.cpp\ Grid_Flow_Profile.cpp\ Grid_Profile.cpp\ Grid_ProfileFromPoints.cpp\ Grid_Profile_From_Lines.cpp\ Grid_Swath_Profile.cpp\ MLB_Interface.cpp\ Grid_Cross_Profiles.h\ Grid_Flow_Profile.h\ Grid_Profile.h\ Grid_ProfileFromPoints.h\ Grid_Profile_From_Lines.h\ Grid_Swath_Profile.h\ MLB_Interface.h libta_profiles_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) --foreign src/modules/terrain_analysis/ta_profiles/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/terrain_analysis/ta_profiles/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libta_profiles.la: $(libta_profiles_la_OBJECTS) $(libta_profiles_la_DEPENDENCIES) $(EXTRA_libta_profiles_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libta_profiles_la_OBJECTS) $(libta_profiles_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Cross_Profiles.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Flow_Profile.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Profile.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_ProfileFromPoints.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Profile_From_Lines.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Swath_Profile.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_ProfileFromPoints.cpp0000664000175000017500000001173512565125415031013 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_ProfileFromPoints.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* ProfileFromPoints.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "Grid_ProfileFromPoints.h" CProfileFromPoints::CProfileFromPoints(void){ CSG_Parameter *pNode_0, *pNode_1; Parameters.Set_Name(_TL("Profile from points")); Parameters.Set_Description(_TW("(c) 2004 by Victor Olaya. Creates a profile from coordinates stored in a table")); Parameters.Add_Grid(NULL, "GRID", _TL("Grid"), _TL(""), PARAMETER_INPUT); pNode_0 = Parameters.Add_Table(NULL, "TABLE", _TL("Input"), _TL(""), PARAMETER_INPUT); pNode_1 = Parameters.Add_Table_Field(pNode_0, "X", _TL("X"), _TL("")); pNode_1 = Parameters.Add_Table_Field(pNode_0, "Y", _TL("Y"), _TL("")); Parameters.Add_Table(NULL, "RESULT", _TL("Result"), _TL(""), PARAMETER_OUTPUT); }//constructor CProfileFromPoints::~CProfileFromPoints(void) {} bool CProfileFromPoints::On_Execute(void){ CSG_Table* pTable; CSG_Table* pProfileTable; CSG_Table_Record* pRecord; CSG_Grid* pGrid; int iXField, iYField; int i; int x1,x2,y1,y2; float fPartialDist; float fDist = 0; pGrid = Parameters("GRID")->asGrid(); pTable = Parameters("TABLE")->asTable(); pProfileTable = Parameters("RESULT")->asTable(); iXField = Parameters("X")->asInt(); iYField = Parameters("Y")->asInt(); pProfileTable->Create((CSG_Table*)NULL); pProfileTable->Set_Name(_TL("Profile")); pProfileTable->Add_Field(_TL("Distance"), SG_DATATYPE_Double); pProfileTable->Add_Field("Z", SG_DATATYPE_Double); for (i = 0; i < pTable->Get_Record_Count()-1; i++){ x1=(int)(0.5 + (pTable->Get_Record(i )->asDouble(iXField) - pGrid->Get_XMin()) / pGrid->Get_Cellsize()); x2=(int)(0.5 + (pTable->Get_Record(i+1)->asDouble(iXField) - pGrid->Get_XMin()) / pGrid->Get_Cellsize()); y1=(int)(0.5 + (pTable->Get_Record(i )->asDouble(iYField) - pGrid->Get_YMin()) / pGrid->Get_Cellsize()); y2=(int)(0.5 + (pTable->Get_Record(i+1)->asDouble(iYField) - pGrid->Get_YMin()) / pGrid->Get_Cellsize()); int x = x1, y = y1, D = 0, HX = x2 - x1, HY = y2 - y1, c, M, xInc = 1, yInc = 1, iLastX = x1, iLastY = y1; if (HX < 0) { xInc = -1; HX = -HX; }//if if (HY < 0) { yInc = -1; HY = -HY; }//if if (HY <= HX) { c = 2 * HX; M = 2 * HY; for (;;) { fPartialDist = (float)(M_GET_LENGTH(x-iLastX, y-iLastY) * pGrid->Get_Cellsize()); if (pGrid->is_InGrid(x,y) && fPartialDist){ fDist+=fPartialDist; pRecord = pProfileTable->Add_Record(); pRecord->Set_Value(0, fDist); pRecord->Set_Value(1, pGrid->asFloat(x,y)); }//if iLastX = x; iLastY = y; if (x == x2) { break; }// if x += xInc; D += M; if (D > HX) { y += yInc; D -= c; }// if }// for }// if else { c = 2 * HY; M = 2 * HX; for (;;) { fPartialDist = (float)(M_GET_LENGTH(x-iLastX, y-iLastY) * pGrid->Get_Cellsize()); if (pGrid->is_InGrid(x,y) && fPartialDist){ fDist+=fPartialDist; pRecord = pProfileTable->Add_Record(); pRecord->Set_Value(0, fDist); pRecord->Set_Value(1, pGrid->asFloat(x,y)); }//if iLastX = x; iLastY = y; if (y == y2) { break; }// if y += yInc; D += M; if (D > HY) { x += xInc; D -= c; }// if }// for }// else }//for return true; }// method saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_Profile.h0000664000175000017500000001105312565125415026430 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Profile.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // Grid_Profile.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Profile_H #define HEADER_INCLUDED__Grid_Profile_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Profile : public CSG_Module_Grid_Interactive { public: CGrid_Profile(void); virtual ~CGrid_Profile(void); protected: virtual bool On_Execute (void); virtual bool On_Execute_Finish (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: bool m_bAdd; CSG_Shapes *m_pPoints, *m_pLine; CSG_Grid *m_pDEM; CSG_Parameter_Grid_List *m_pValues; bool Set_Profile (void); bool Set_Profile (TSG_Point A, TSG_Point B); bool Add_Point (CSG_Point Point); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Profile_H saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_Profile_From_Lines.h0000664000175000017500000001116312565125415030547 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Profile_From_Lines.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // Grid_Profile_From_Lines.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Profile_From_Lines_H #define HEADER_INCLUDED__Grid_Profile_From_Lines_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Profile_From_Lines : public CSG_Module_Grid { public: CGrid_Profile_From_Lines(void); virtual ~CGrid_Profile_From_Lines(void); protected: virtual bool On_Execute(void); private: CSG_Shapes *m_pProfile, *m_pLines; CSG_Grid *m_pDEM; CSG_Parameter_Grid_List *m_pValues; bool Init_Profile (CSG_Shapes *pPoints, const SG_Char *Name); bool Set_Profile (int Line_ID, CSG_Shape *pLine); bool Set_Profile (int Line_ID, bool bStart, const TSG_Point &A, const TSG_Point &B); bool Add_Point (int Line_ID, bool bStart, const TSG_Point &Point); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Profile_From_Lines_H saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_Swath_Profile.cpp0000664000175000017500000003324712565125415030142 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Swath_Profile.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // Grid_Swath_Profile.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Swath_Profile.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define VALUE_OFFSET 10 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Swath_Profile::CGrid_Swath_Profile(void) { Set_Name (_TL("Swath Profile")); Set_Author ("O.Conrad (c) 2005"); Set_Description (_TW( "Create interactively swath profiles from a grid based DEM\n" "Use left mouse button clicks into a map window to add profile points." "A right mouse button click will finish the profile.\n" "Generated outputs for the swath profile are arithmetic mean, " "minimum, maximum values and the standard deviation.\n" )); Parameters.Add_Grid( NULL , "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "VALUES" , _TL("Values"), _TL("Additional values that shall be saved to the output table."), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Profile Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "LINE" , _TL("Swath Profile"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "WIDTH" , _TL("Swath Width"), _TL("Swath width measured in map units."), PARAMETER_TYPE_Double, 100.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Swath_Profile::On_Execute(void) { m_pDEM = Parameters("DEM" )->asGrid(); m_pValues = Parameters("VALUES")->asGridList(); m_pPoints = Parameters("POINTS")->asShapes(); m_pLine = Parameters("LINE" )->asShapes(); m_Width = Parameters("WIDTH" )->asDouble() / 2.0; m_bAdd = false; DataObject_Update(m_pDEM , SG_UI_DATAOBJECT_SHOW_NEW_MAP); DataObject_Update(m_pLine, SG_UI_DATAOBJECT_SHOW_LAST_MAP); return( true ); } //--------------------------------------------------------- bool CGrid_Swath_Profile::On_Execute_Finish(void) { if( m_bAdd ) { Set_Profile(); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Swath_Profile::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { switch( Mode ) { default: break; case MODULE_INTERACTIVE_LDOWN: if( !m_bAdd ) { m_bAdd = true; m_pLine->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s]"), _TL("Profile"), m_pDEM->Get_Name())); m_pLine->Add_Field("ID" , SG_DATATYPE_Int); m_pLine->Add_Shape()->Set_Value(0, 1); } m_pLine->Get_Shape(0)->Add_Point(Get_System()->Fit_to_Grid_System(ptWorld)); DataObject_Update(m_pLine); break; case MODULE_INTERACTIVE_RDOWN: Set_Profile(); m_bAdd = false; break; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Swath_Profile::Set_Profile(void) { int i; //----------------------------------------------------- m_pPoints->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), _TL("Profile"), m_pDEM->Get_Name())); m_pPoints->Add_Field("ID" , SG_DATATYPE_Int ); m_pPoints->Add_Field("D" , SG_DATATYPE_Double); m_pPoints->Add_Field("X" , SG_DATATYPE_Double); m_pPoints->Add_Field("Y" , SG_DATATYPE_Double); m_pPoints->Add_Field("Z" , SG_DATATYPE_Double); m_pPoints->Add_Field("Z [mean]" , SG_DATATYPE_Double); m_pPoints->Add_Field("Z [min]" , SG_DATATYPE_Double); m_pPoints->Add_Field("Z [max]" , SG_DATATYPE_Double); m_pPoints->Add_Field("Z [min_sd]", SG_DATATYPE_Double); m_pPoints->Add_Field("Z [max_sd]", SG_DATATYPE_Double); for(i=0; iGet_Count(); i++) { m_pPoints->Add_Field(m_pValues->asGrid(i)->Get_Name(), SG_DATATYPE_Double); m_pPoints->Add_Field(CSG_String::Format(SG_T("%s [%s]"), _TL("mean" ), m_pValues->asGrid(i)->Get_Name()), SG_DATATYPE_Double); m_pPoints->Add_Field(CSG_String::Format(SG_T("%s [%s]"), _TL("min" ), m_pValues->asGrid(i)->Get_Name()), SG_DATATYPE_Double); m_pPoints->Add_Field(CSG_String::Format(SG_T("%s [%s]"), _TL("max" ), m_pValues->asGrid(i)->Get_Name()), SG_DATATYPE_Double); m_pPoints->Add_Field(CSG_String::Format(SG_T("%s [%s]"), _TL("min_sd"), m_pValues->asGrid(i)->Get_Name()), SG_DATATYPE_Double); m_pPoints->Add_Field(CSG_String::Format(SG_T("%s [%s]"), _TL("max_sd"), m_pValues->asGrid(i)->Get_Name()), SG_DATATYPE_Double); } //----------------------------------------------------- CSG_Shape *pLine = m_pLine->Get_Shape(0); if( pLine == NULL || pLine->Get_Point_Count(0) < 2 ) { return( false ); } //----------------------------------------------------- CSG_Shape *pLeft = m_pLine->Get_Shape(1); if( pLeft ) pLeft ->Del_Parts(); else pLeft = m_pLine->Add_Shape(); CSG_Shape *pRight = m_pLine->Get_Shape(2); if( pRight ) pRight->Del_Parts(); else pRight = m_pLine->Add_Shape(); CSG_Point A, B = pLine->Get_Point(0); for(i=1; iGet_Point_Count(0); i++) { A = B; B = pLine->Get_Point(i); if( !A.is_Equal(B) ) { CSG_Point P = B - A; double d = m_Width / SG_Get_Distance(A, B); P.Assign(-d * P.Get_Y(), d * P.Get_X()); CSG_Point Left = A - P; CSG_Point Right = A + P; Set_Profile(A, B, Left, Right); pLeft ->Add_Point(Left , i - 1); Left = B - P; pLeft ->Add_Point(Left , i - 1); pRight->Add_Point(Right, i - 1); Right = B + P; pRight->Add_Point(Right, i - 1); } } //----------------------------------------------------- DataObject_Update(m_pLine); DataObject_Update(m_pPoints); return( m_pPoints->Get_Count() > 0 ); } //--------------------------------------------------------- bool CGrid_Swath_Profile::Set_Profile(CSG_Point A, CSG_Point B, CSG_Point Left, CSG_Point Right) { //----------------------------------------------------- double dx = fabs(B.Get_X() - A.Get_X()); double dy = fabs(B.Get_Y() - A.Get_Y()); if( dx <= 0.0 && dy <= 0.0 ) { return( false ); } double n; if( dx > dy ) { dx /= Get_Cellsize(); n = dx; dy /= dx; dx = Get_Cellsize(); } else { dy /= Get_Cellsize(); n = dy; dx /= dy; dy = Get_Cellsize(); } dx = A.Get_X() < B.Get_X() ? dx : -dx; dy = A.Get_Y() < B.Get_Y() ? dy : -dy; //----------------------------------------------------- CSG_Point dStep( dx, dy); CSG_Point Step (-dy, dx); if( fabs(Step.Get_X()) > fabs(Step.Get_Y()) ) { if( Left.Get_X() > Right.Get_X() ) { CSG_Point p = Left; Left = Right; Right = p; } if( Step.Get_X() < 0.0 ) { Step.Assign(-Step.Get_X(), -Step.Get_Y()); } } else { if( Left.Get_Y() > Right.Get_Y() ) { CSG_Point p = Left; Left = Right; Right = p; } if( Step.Get_Y() < 0.0 ) { Step.Assign(-Step.Get_X(), -Step.Get_Y()); } } //------------------------------------------------- for(double d=0.0; d<=n; d++, A+=dStep, Left+=dStep, Right+=dStep) { Add_Point(A, Left, Right, Step); } return( true ); } //--------------------------------------------------------- bool CGrid_Swath_Profile::Add_Point(CSG_Point Point, CSG_Point Left, CSG_Point Right, CSG_Point Step) { if( !m_pDEM->is_InGrid_byPos(Point) ) { return( false ); } //----------------------------------------------------- double Distance; if( m_pPoints->Get_Count() == 0 ) { Distance = 0.0; } else { CSG_Shape *pLast = m_pPoints->Get_Shape(m_pPoints->Get_Count() - 1); Distance = SG_Get_Distance(Point, pLast->Get_Point(0)); if( Distance == 0.0 ) { return( false ); } Distance += pLast->asDouble(1); } //----------------------------------------------------- CSG_Shape *pPoint = m_pPoints->Add_Shape(); pPoint->Add_Point(Point); pPoint->Set_Value(0, m_pPoints->Get_Count()); pPoint->Set_Value(1, Distance); pPoint->Set_Value(2, Point.Get_X()); pPoint->Set_Value(3, Point.Get_Y()); Add_Swath(pPoint, 4, m_pDEM, Left, Right, Step); for(int i=0, j=VALUE_OFFSET; iGet_Count(); i++, j+=6) { Add_Swath(pPoint, j, m_pValues->asGrid(i), Left, Right, Step); } return( true ); } //--------------------------------------------------------- bool CGrid_Swath_Profile::Add_Swath(CSG_Shape *pPoint, int iEntry, CSG_Grid *pGrid, CSG_Point Left, CSG_Point Right, CSG_Point Step) { double Value; if( pGrid->Get_Value(pPoint->Get_Point(0), Value, GRID_INTERPOLATION_BSpline, false, true) ) { pPoint->Set_Value(iEntry, Value); } else { pPoint->Set_NoData(iEntry); } //----------------------------------------------------- double iRun, dRun, nRun; if( Step.Get_X() > Step.Get_Y() ) { iRun = Left .Get_X(); dRun = Step .Get_X(); nRun = Right .Get_X(); } else { iRun = Left .Get_Y(); dRun = Step .Get_Y(); nRun = Right .Get_Y(); } //----------------------------------------------------- CSG_Simple_Statistics Statistics; for( ; iRun<=nRun; iRun+=dRun, Left+=Step) { if( pGrid->Get_Value(Left, Value, GRID_INTERPOLATION_BSpline, false, true) ) { Statistics += Value; } } //----------------------------------------------------- if( Statistics.Get_Count() > 0 ) { pPoint->Set_Value(iEntry + 1, Statistics.Get_Mean()); pPoint->Set_Value(iEntry + 2, Statistics.Get_Minimum()); pPoint->Set_Value(iEntry + 3, Statistics.Get_Maximum()); pPoint->Set_Value(iEntry + 4, Statistics.Get_Mean() - Statistics.Get_StdDev()); pPoint->Set_Value(iEntry + 5, Statistics.Get_Mean() + Statistics.Get_StdDev()); return( true ); } pPoint->Set_NoData(iEntry + 1); pPoint->Set_NoData(iEntry + 2); pPoint->Set_NoData(iEntry + 3); pPoint->Set_NoData(iEntry + 4); pPoint->Set_NoData(iEntry + 5); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_Profile_From_Lines.cpp0000664000175000017500000002512612565125415031106 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Profile_From_Lines.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // Grid_Profile_From_Lines.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Profile_From_Lines.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Profile_From_Lines::CGrid_Profile_From_Lines(void) { CSG_Parameter *pNode; Set_Name (_TL("Profiles from Lines")); Set_Author (SG_T("O.Conrad (c) 2006")); Set_Description (_TW( "Create profiles from a grid based DEM for each line of a lines layer. " )); Parameters.Add_Grid( NULL , "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "VALUES" , _TL("Values"), _TL("Additional values that shall be saved to the output table."), PARAMETER_INPUT_OPTIONAL ); pNode = Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Table_Field( pNode , "NAME" , _TL("Name"), _TL("naming for splitted lines"), true ); Parameters.Add_Shapes( NULL , "PROFILE" , _TL("Profiles"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Shapes_List( NULL , "PROFILES" , _TL("Profiles"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "SPLIT" , _TL("Each Line as new Profile"), _TL(""), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------- CGrid_Profile_From_Lines::~CGrid_Profile_From_Lines(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Profile_From_Lines::On_Execute(void) { int iLine, iName; //----------------------------------------------------- m_pDEM = Parameters("DEM") ->asGrid(); m_pValues = Parameters("VALUES") ->asGridList(); m_pLines = Parameters("LINES") ->asShapes(); iName = Parameters("NAME") ->asInt(); //----------------------------------------------------- if( Parameters("SPLIT")->asBool() == false ) { if( (m_pProfile = Parameters("PROFILE")->asShapes()) == NULL ) { Parameters("PROFILE")->Set_Value(m_pProfile = SG_Create_Shapes(SHAPE_TYPE_Point)); } Init_Profile(m_pProfile, CSG_String::Format(SG_T("%s [%s]"), m_pDEM->Get_Name(), _TL("Profile"))); for(iLine=0; iLineGet_Count() && Set_Progress(iLine, m_pLines->Get_Count()); iLine++) { Set_Profile(iLine, m_pLines->Get_Shape(iLine)); } return( true ); } //----------------------------------------------------- else { Parameters("PROFILES")->asShapesList()->Del_Items(); for(iLine=0; iLineGet_Count() && Set_Progress(iLine, m_pLines->Get_Count()); iLine++) { Init_Profile(m_pProfile = SG_Create_Shapes(), iName < 0 ? CSG_String::Format(SG_T("%s [%s %d]"), m_pDEM->Get_Name(), _TL("Profile"), iLine + 1) : CSG_String::Format(SG_T("%s [%s %s]"), m_pDEM->Get_Name(), _TL("Profile"), m_pLines->Get_Shape(iLine)->asString(iName)) ); Set_Profile(iLine, m_pLines->Get_Shape(iLine)); Parameters("PROFILES")->asShapesList()->Add_Item(m_pProfile); } return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { F_LINE_ID = 0, F_ID, F_DIST, F_DIST_SURF, F_X, F_Y, F_Z, F_VALUES }; //--------------------------------------------------------- bool CGrid_Profile_From_Lines::Init_Profile(CSG_Shapes *pPoints, const SG_Char *Name) { if( pPoints ) { pPoints->Create(SHAPE_TYPE_Point, Name); pPoints->Add_Field("LINE_ID" , SG_DATATYPE_Int); pPoints->Add_Field("ID" , SG_DATATYPE_Int); pPoints->Add_Field("DIST" , SG_DATATYPE_Double); pPoints->Add_Field("DIST_SURF" , SG_DATATYPE_Double); pPoints->Add_Field("X" , SG_DATATYPE_Double); pPoints->Add_Field("Y" , SG_DATATYPE_Double); pPoints->Add_Field("Z" , SG_DATATYPE_Double); for(int i=0; iGet_Count(); i++) { pPoints->Add_Field(m_pValues->asGrid(i)->Get_Name(), SG_DATATYPE_Double); } return( true ); } return( false ); } //--------------------------------------------------------- bool CGrid_Profile_From_Lines::Set_Profile(int Line_ID, CSG_Shape *pLine) { if( pLine && pLine->Get_Point_Count(0) > 1 ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point A, B; B = pLine->Get_Point(0, iPart); for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { A = B; B = pLine->Get_Point(iPoint, iPart); Set_Profile(Line_ID, iPoint == 1, A, B); } } return( true ); } return( false ); } //--------------------------------------------------------- bool CGrid_Profile_From_Lines::Set_Profile(int Line_ID, bool bStart, const TSG_Point &A, const TSG_Point &B) { double dx, dy, d, n; TSG_Point p; //----------------------------------------------------- dx = fabs(B.x - A.x); dy = fabs(B.y - A.y); if( dx > 0.0 || dy > 0.0 ) { if( dx > dy ) { dx /= Get_Cellsize(); n = dx; dy /= dx; dx = Get_Cellsize(); } else { dy /= Get_Cellsize(); n = dy; dx /= dy; dy = Get_Cellsize(); } if( B.x < A.x ) { dx = -dx; } if( B.y < A.y ) { dy = -dy; } //------------------------------------------------- for(d=0.0, p.x=A.x, p.y=A.y; d<=n; d++, p.x+=dx, p.y+=dy) { Add_Point(Line_ID, bStart, p); bStart = false; } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGrid_Profile_From_Lines::Add_Point(int Line_ID, bool bStart, const TSG_Point &Point) { int x, y, i; double z, Distance, Distance_2; CSG_Shape *pPoint, *pLast; if( Get_System()->Get_World_to_Grid(x, y, Point) && m_pDEM->is_InGrid(x, y) ) { z = m_pDEM->asDouble(x, y); if( bStart || m_pProfile->Get_Count() == 0 ) { Distance = 0.0; Distance_2 = 0.0; } else { pLast = m_pProfile->Get_Shape(m_pProfile->Get_Count() - 1); Distance = SG_Get_Distance(Point, pLast->Get_Point(0)); if( Distance == 0.0 ) { return( false ); } Distance_2 = pLast->asDouble(F_Z) - z; Distance_2 = sqrt(Distance*Distance + Distance_2*Distance_2); Distance += pLast->asDouble(F_DIST); Distance_2 += pLast->asDouble(F_DIST_SURF); } pPoint = m_pProfile->Add_Shape(); pPoint->Add_Point(Point); pPoint->Set_Value(F_LINE_ID , Line_ID); pPoint->Set_Value(F_ID , m_pProfile->Get_Count()); pPoint->Set_Value(F_DIST , Distance); pPoint->Set_Value(F_DIST_SURF, Distance_2); pPoint->Set_Value(F_X , Point.x); pPoint->Set_Value(F_Y , Point.y); pPoint->Set_Value(F_Z , z); for(i=0; iGet_Count(); i++) { pPoint->Set_Value(F_VALUES + i, m_pValues->asGrid(i)->asDouble(x, y)); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_profiles/MLB_Interface.cpp0000664000175000017500000001143512565125415027014 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Profiles") ); case MLB_INFO_Category: return( _TL("Terrain Analysis") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Olaya (c) 2004-06") ); case MLB_INFO_Description: return( _TL("Simple, flow path and swath profiles.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Terrain Analysis|Profiles" )); } } //--------------------------------------------------------- #include "Grid_Profile.h" #include "Grid_Flow_Profile.h" #include "Grid_Swath_Profile.h" #include "Grid_Cross_Profiles.h" #include "Grid_Profile_From_Lines.h" #include "Grid_ProfileFromPoints.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CGrid_Profile ); case 1: return( new CGrid_Flow_Profile ); case 2: return( new CGrid_Swath_Profile ); case 3: return( new CGrid_Cross_Profiles ); case 4: return( new CGrid_Profile_From_Lines ); case 5: return( new CProfileFromPoints ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Makefile.am0000664000175000017500000000155612565125415025755 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_profiles.la libta_profiles_la_SOURCES =\ Grid_Cross_Profiles.cpp\ Grid_Flow_Profile.cpp\ Grid_Profile.cpp\ Grid_ProfileFromPoints.cpp\ Grid_Profile_From_Lines.cpp\ Grid_Swath_Profile.cpp\ MLB_Interface.cpp\ Grid_Cross_Profiles.h\ Grid_Flow_Profile.h\ Grid_Profile.h\ Grid_ProfileFromPoints.h\ Grid_Profile_From_Lines.h\ Grid_Swath_Profile.h\ MLB_Interface.h libta_profiles_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) saga-2.2.3/src/modules/terrain_analysis/ta_profiles/MLB_Interface.h0000664000175000017500000000713112565125415026457 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_profiles_H #define HEADER_INCLUDED__ta_profiles_H //--------------------------------------------------------- #include //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ta_profiles_H saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_ProfileFromPoints.h0000664000175000017500000000257512565125415030462 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_ProfileFromPoints.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* ProfileFromPoints.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CProfileFromPoints : public CSG_Module_Grid { public: CProfileFromPoints(void); virtual ~CProfileFromPoints(void); protected: virtual bool On_Execute(void); }; saga-2.2.3/src/modules/terrain_analysis/ta_profiles/Grid_Profile.cpp0000664000175000017500000002367512565125415027000 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Profile.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_profiles // // // //-------------------------------------------------------// // // // Grid_Profile.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Profile.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define VALUE_OFFSET 6 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Profile::CGrid_Profile(void) { Set_Name (_TL("Profile")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description (_TW( "Create interactively profiles from a grid based DEM\n" "Use left mouse button clicks into a map window to add profile points." "A right mouse button click will finish the profile." )); Set_Drag_Mode (MODULE_INTERACTIVE_DRAG_LINE); Parameters.Add_Grid( NULL, "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL, "VALUES" , _TL("Values"), _TL("Additional values that shall be saved to the output table."), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Shapes( NULL, "POINTS" , _TL("Profile Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL, "LINE" , _TL("Profile Line"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); } //--------------------------------------------------------- CGrid_Profile::~CGrid_Profile(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Profile::On_Execute(void) { m_pDEM = Parameters("DEM") ->asGrid(); m_pValues = Parameters("VALUES") ->asGridList(); m_pPoints = Parameters("POINTS") ->asShapes(); m_pLine = Parameters("LINE") ->asShapes(); m_bAdd = false; DataObject_Update(m_pDEM , SG_UI_DATAOBJECT_SHOW_NEW_MAP); DataObject_Update(m_pLine, SG_UI_DATAOBJECT_SHOW_LAST_MAP); return( true ); } //--------------------------------------------------------- bool CGrid_Profile::On_Execute_Finish(void) { if( m_bAdd ) { Set_Profile(); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Profile::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { switch( Mode ) { default: break; case MODULE_INTERACTIVE_LDOWN: if( !m_bAdd ) { m_bAdd = true; m_pLine->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("Profile [%s]"), m_pDEM->Get_Name())); m_pLine->Add_Field("ID" , SG_DATATYPE_Int); m_pLine->Add_Shape()->Set_Value(0, 1); } m_pLine->Get_Shape(0)->Add_Point(Get_System()->Fit_to_Grid_System(ptWorld)); DataObject_Update(m_pLine); break; case MODULE_INTERACTIVE_RDOWN: Set_Profile(); m_bAdd = false; break; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Profile::Set_Profile(void) { int i; TSG_Point A, B; CSG_Shape *pLine; //----------------------------------------------------- m_pPoints->Create(SHAPE_TYPE_Point, CSG_String::Format(_TL("Profile [%s]"), m_pDEM->Get_Name())); m_pPoints->Add_Field("ID" , SG_DATATYPE_Int); m_pPoints->Add_Field(_TL("Distance") , SG_DATATYPE_Double); m_pPoints->Add_Field(_TL("Distance Overland") , SG_DATATYPE_Double); m_pPoints->Add_Field("X" , SG_DATATYPE_Double); m_pPoints->Add_Field("Y" , SG_DATATYPE_Double); m_pPoints->Add_Field("Z" , SG_DATATYPE_Double); for(i=0; iGet_Count(); i++) { m_pPoints->Add_Field(m_pValues->asGrid(i)->Get_Name(), SG_DATATYPE_Double); } //----------------------------------------------------- if( (pLine = m_pLine->Get_Shape(0)) != NULL && pLine->Get_Point_Count(0) > 1 ) { B = pLine->Get_Point(0); for(i=1; iGet_Point_Count(0); i++) { A = B; B = pLine->Get_Point(i); Set_Profile(A, B); } } //----------------------------------------------------- DataObject_Update(m_pLine); DataObject_Update(m_pPoints); return( m_pPoints->Get_Count() > 0 ); } //--------------------------------------------------------- bool CGrid_Profile::Set_Profile(TSG_Point A, TSG_Point B) { double dx, dy, d, n; TSG_Point p; //----------------------------------------------------- dx = fabs(B.x - A.x); dy = fabs(B.y - A.y); if( dx > 0.0 || dy > 0.0 ) { if( dx > dy ) { dx /= Get_Cellsize(); n = dx; dy /= dx; dx = Get_Cellsize(); } else { dy /= Get_Cellsize(); n = dy; dx /= dy; dy = Get_Cellsize(); } if( B.x < A.x ) { dx = -dx; } if( B.y < A.y ) { dy = -dy; } //------------------------------------------------- for(d=0.0, p.x=A.x, p.y=A.y; d<=n; d++, p.x+=dx, p.y+=dy) { Add_Point(p); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGrid_Profile::Add_Point(CSG_Point Point) { int x, y, i; double z, Distance, Distance_2; CSG_Shape *pPoint, *pLast; if( Get_System()->Get_World_to_Grid(x, y, Point) && m_pDEM->is_InGrid(x, y) ) { z = m_pDEM->asDouble(x, y); if( m_pPoints->Get_Count() == 0 ) { Distance = 0.0; Distance_2 = 0.0; } else { pLast = m_pPoints->Get_Shape(m_pPoints->Get_Count() - 1); Distance = SG_Get_Distance(Point, pLast->Get_Point(0)); if( Distance == 0.0 ) { return( false ); } Distance_2 = pLast->asDouble(5) - z; Distance_2 = sqrt(Distance*Distance + Distance_2*Distance_2); Distance += pLast->asDouble(1); Distance_2 += pLast->asDouble(2); } pPoint = m_pPoints->Add_Shape(); pPoint->Add_Point(Point); pPoint->Set_Value(0, m_pPoints->Get_Count()); pPoint->Set_Value(1, Distance); pPoint->Set_Value(2, Distance_2); pPoint->Set_Value(3, Point.Get_X()); pPoint->Set_Value(4, Point.Get_Y()); pPoint->Set_Value(5, z); for(i=0; iGet_Count(); i++) { pPoint->Set_Value(VALUE_OFFSET + i, m_pValues->asGrid(i)->asDouble(x, y)); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/Makefile.am0000664000175000017500000000017212565125415023437 0ustar00oconradoconrad00000000000000SUBDIRS = ta_slope_stability ta_profiles ta_preprocessor ta_morphometry ta_lighting ta_hydrology ta_compound ta_channels saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/0000775000175000017500000000000012634325751025277 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/WEDGEFAIL_01.h0000664000175000017500000000750412565125415027243 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: WEDGEFAIL_01.h 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // WEDGEFAIL_01.h // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWEDGEFAIL : public CSG_Module_Grid { public: CWEDGEFAIL(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/SHALSTAB_01.cpp0000664000175000017500000004314012565125415027504 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SHALSTAB_01.cpp 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // SHALSTAB_01.cpp // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SHALSTAB_01.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSHALSTAB::CSHALSTAB(void) { CSG_Parameters P; //----------------------------------------------------- Set_Name (_TL("SHALSTAB")); Set_Author (SG_T("A. Günther (c) 2012")); Set_Description (_TW( "\n" "This module is a realization of the SHALSTAB (""Shallow Slope Stability"") model from Montgomery & Dietrich (1994). " "The model computes grid cell critical shallow groundwater recharge values (CR in mm/day) as a measure for relative shallow slope stability, utilizing " "a simple model that combines a steady-state hydrologic model (a topographic wetness index) to predict groundwater pressures with an infinite slope stability model. " "For computation, a slope (in radians) and a catchment area (in m2) grid are required. " "Additionally, information on material density (g/cm3), material friction angle (°), material hydraulic conductivity (m/hr), bulk cohesion (MPa) " "and depth to potential shear plane (m) are required that can be specified either globally or through grids. " "The module produces a continuous CR (mm/day) raster with unconditionally stable cells blanked, and unconditionally unstable cells as CR = 0. " "Optionally, a classified CR grid can be calculated representing seven stability classes.\n" "\n" "Reference: " "Montgomery D. R., Dietrich, W. E. (1994) A physically based model for the topographic control on shallow landsliding. Water Resources Research, 30, 1153-1171..\n" )); Parameters.Add_Grid( NULL, "A", "Slope grid (rad)", "A slope angle grid (in radíans)", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "B", "Catchment area grid (m2)", "A catchment area grid (in square meters)", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "Cmin", "Min Density grid (g/cm3)", "A grid representing minimum material density (in g/cm3)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Cmax", "Max Density grid (g/cm3)", "A grid representing maximum material density (in g/cm3)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Dmin", "Min Hydraulic conductivity grid (m/hr) ", "A grid representing minimum material hydraulic conductivity (in m/hr)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Dmax", "Max Hydraulic conductivity grid (m/hr) ", "A grid representing maximum material hydraulic conductivity (in m/hr)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Emin", "Min Thickness grid (m)", "A grid representing minimum material thickness (in m)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Emax", "Max Thickness grid (m)", "A grid representing maximum material thickness (in m)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Fmin", "Min Friction angle grid (degree) ", "A grid representing minimum material friction angle (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Fmax", "Max Friction angle grid (degree) ", "A grid representing maximum material friction angle (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Jmin", "Min Bulk cohesion grid (MPa) ", "A grid representing minimum bulk cohesion", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Jmax", "Max Bulk cohesion grid (MPa) ", "A grid representing maximum bulk cohesion", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( NULL, "fCmin", "Global minimum density (g/cm3)", "Constant value if no raster set", PARAMETER_TYPE_Double, 1.6 //Initialisierung eines fixen wertes vs Grid für density ); Parameters.Add_Value( NULL, "fCmax", "Global maximum density (g/cm3)", "Constant value if no raster set", PARAMETER_TYPE_Double, 1.6 //Initialisierung eines fixen wertes vs Grid für density ); Parameters.Add_Value( NULL, "fDmin", "Global minimum conductivity (m/hr)", "Constant value if no raster set", PARAMETER_TYPE_Double, 2.7 //Initialisierung eines fixen wertes vs Grid für conductivity ); Parameters.Add_Value( NULL, "fDmax", "Global maximum conductivity (m/hr)", "Constant value if no raster set", PARAMETER_TYPE_Double, 2.7 //Initialisierung eines fixen wertes vs Grid für conductivity ); Parameters.Add_Value( NULL, "fEmin", "Global minimum thickness (m)", "Constant value if no raster set", PARAMETER_TYPE_Double, 1.0 //Initialisierung eines fixen wertes vs Grid für depth ); Parameters.Add_Value( NULL, "fEmax", "Global maximum thickness (m)", "Constant value if no raster set", PARAMETER_TYPE_Double, 1.0 //Initialisierung eines fixen wertes vs Grid für depth ); Parameters.Add_Value( NULL, "fFmin", "Global minimum friction angle (degree)", "Constant value if no raster set", PARAMETER_TYPE_Double, 33.0 //Initialisierung eines fixen wertes vs Grid für friction ); Parameters.Add_Value( NULL, "fFmax", "Global maximum friction angle (degree)", "Constant value if no raster set", PARAMETER_TYPE_Double, 33.0 //Initialisierung eines fixen wertes vs Grid für friction ); Parameters.Add_Value( NULL, "fJmin", "Global minimum bulk cohesion (MPa)", "Constant value if no raster set", PARAMETER_TYPE_Double, 0 //Initialisierung eines fixen wertes vs Grid für cohesion ); Parameters.Add_Value( NULL, "fJmax", "Global maximum bulk cohesion (MPa)", "Constant value if no raster set", PARAMETER_TYPE_Double, 0 //Initialisierung eines fixen wertes vs Grid für cohesion ); Parameters.Add_Value( NULL, "fK", "Parameter sampling runs", "Number of sampling cycles",PARAMETER_TYPE_Int, 1 //Initialisierung eines fixen wertes vs Grid für cohesion ); Parameters.Add_Grid( NULL, "G", "CR values", "Resulting critical recharge (m/day) grid", PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "H", "CR classes", "Classified critical recharge (-) grid", PARAMETER_OUTPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { CR_NODATA = 0, CR_UNSTABLE, CR_0_TO_50, CR_50_TO_100, CR_100_TO_200, CR_200_TO_400, CR_GR_400, CR_STABLE, CR_COUNT }; bool CSHALSTAB::On_Execute(void) { double fCmin = Parameters("fCmin")->asDouble(); double fDmin = Parameters("fDmin")->asDouble(); double fEmin = Parameters("fEmin")->asDouble(); double fFmin = Parameters("fFmin")->asDouble(); double fJmin = Parameters("fJmin")->asDouble(); double fCmax = Parameters("fCmax")->asDouble(); double fDmax = Parameters("fDmax")->asDouble(); double fEmax = Parameters("fEmax")->asDouble(); double fFmax = Parameters("fFmax")->asDouble(); double fJmax = Parameters("fJmax")->asDouble(); double fK = Parameters("fK")->asInt(); double grav = 9.81; CSG_Grid *pA, *pB, *pCmin, *pDmin, *pEmin, *pFmin, *pG, *pH, *pJmin, *pCmax, *pDmax, *pEmax, *pFmax, *pJmax; pA = Parameters("A" )->asGrid(); //slope pB = Parameters("B" )->asGrid(); //flow accumulation pCmin = Parameters("Cmin" )->asGrid(); //density pDmin = Parameters("Dmin" )->asGrid(); //conductivity pEmin = Parameters("Emin" )->asGrid(); //depth pFmin = Parameters("Fmin" )->asGrid(); //friction pCmax = Parameters("Cmax" )->asGrid(); //density pDmax = Parameters("Dmax" )->asGrid(); //conductivity pEmax = Parameters("Emax" )->asGrid(); //depth pFmax = Parameters("Fmax" )->asGrid(); //friction pG = Parameters("G" )->asGrid(); //output critical recharge pH = Parameters("H" )->asGrid(); //optional output classified grid pJmin = Parameters("Jmin" )->asGrid(); //bulk cohesion pJmax = Parameters("Jmax" )->asGrid(); //bulk cohesion for(int y=0; yasDouble(x, y); b = pB->asDouble(x, y); //Abfrage ob Raster oder Globalwerte: cmin = pCmin ? pCmin->asDouble(x, y) : fCmin; dmin = pDmin ? pDmin->asDouble(x, y) : fDmin; emin = pEmin ? pEmin->asDouble(x, y) : fEmin; fmin = pFmin ? pFmin->asDouble(x, y) : fFmin; jmin = pJmin ? pJmin->asDouble(x, y) : fJmin; cmax = pCmax ? pCmax->asDouble(x, y) : fCmax; dmax = pDmax ? pDmax->asDouble(x, y) : fDmax; emax = pEmax ? pEmax->asDouble(x, y) : fEmax; fmax = pFmax ? pFmax->asDouble(x, y) : fFmax; jmax = pJmax ? pJmax->asDouble(x, y) : fJmax; k = fK; if (pA->is_NoData(x, y) || pB->is_NoData(x, y)) { pG->Set_NoData(x, y); if (pH) pH->Set_Value(x, y, CR_NODATA); } else if ((pCmin || pCmax || pDmin || pDmax || pEmin || pEmax || pFmin || pFmax || pJmin || pJmax) && (pCmin && pCmax->is_NoData(x, y) || pDmin && pDmax->is_NoData(x, y) || pEmin && pEmax->is_NoData(x, y) || pFmin && pFmax->is_NoData(x, y) || pJmin && pJmax->is_NoData(x, y))) { pG->Set_NoData(x, y); if (pH) pH->Set_Value(x, y, CR_NODATA); } else { cperc = ((cmax - cmin) / cmax) * 100; //calculate parameter range %: density if (cperc > 0) { n = 0; cc = 0; while ( n < k) //loop through specified random number iterations: { rand_int = rand() % cperc + 0; //calculate random percentage c = ((cmax/100) * rand_int) + cmin; //calculate value cc = cc + c; //sum n = n + 1; } c = cc / n; // calculate mean from random values } else { c = cmax; } dperc = ((dmax - dmin) / dmax) * 100; if (dperc > 0) { n = 0; dd = 0; while ( n < k) { rand_int = rand() % dperc + 0; d = ((dmax/100) * rand_int) + dmin; dd = dd + d; n = n + 1; } d = dd / n; } else { d = dmax; } eperc = ((emax - emin) / emax) * 100; if (eperc > 0) { n = 0; ee = 0; while ( n < k) { rand_int = rand() % eperc + 0; e = ((emax/100) * rand_int) + emin; ee = ee + e; n = n + 1; } e = ee / n; } else { e = emax; } fperc = ((fmax - fmin) / fmax) * 100; if (fperc > 0) { n = 0; ff = 0; while ( n < k) { rand_int = rand() % fperc + 0; f = ((fmax/100) * rand_int) + fmin; ff = ff + f; n = n + 1; } f = ff / n; } else { f = fmax; } jperc = ((jmax - jmin) / jmax) * 100; if (jperc > 0) { n = 0; jj = 0; while ( n < k) { rand_int = rand() % jperc + 0; j = ((jmax/100) * rand_int) + jmin; jj = jj + j; n = n + 1; } j = jj / n; } else { j = jmax; } l = j/((e/cos(a))*c*grav); //calculate dimensionless cohesion //g = ((((sin(a) * (d*24*e)) * c)/(b/pB->Get_Cellsize())) * (1-(tan(a)/tan(f/57.2958)))) *1000; //cohesionless SHALSTAB calculation g = ((((sin(a) * (d*24*e)) * c)/(b/pB->Get_Cellsize())) * (1-((sin(a) - l)/(cos(a)*tan(f/57.2958))))) *1000; //SHALSTAB calculation //if ((tan(a) > (tan(f/57.2958) * (1-(1/c))))) //general stability criterion if (tan(a) > ((tan(f/57.2958) * (1-(1/c)))+(j/cos(a)))) { if (g > 0) //critical recharge pG->Set_Value(x, y, g); else pG->Set_Value(x, y, 0); //unconditionally unstable = 0 } //else if (tan(a) <= (tan(f/57.2958) * (1-(1/c)))) else if (tan(a) <= ((tan(f/57.2958) * (1-(1/c)))+(l/cos(a)))) { pG->Set_NoData(x, y); //unconditionally stable = nodata } if (pH) //calculate optional classified grid { //if ((tan(a) > (tan(f/57.2958) * (1-(1/c))))) if (tan(a) > ((tan(f/57.2958) * (1-(1/c)))+(l/cos(a)))) { if (g <= 0) pH->Set_Value(x, y, CR_UNSTABLE); else if ((g > 0) && (g <= 50)) pH->Set_Value(x, y, CR_0_TO_50); else if ((g > 50) && (g <= 100)) pH->Set_Value(x, y, CR_50_TO_100); else if ((g > 100) && (g <= 200)) pH->Set_Value(x, y, CR_100_TO_200); else if ((g > 200) && (g <= 400)) pH->Set_Value(x, y, CR_200_TO_400); else if (g > 400) pH->Set_Value(x, y, CR_GR_400); } //else if (tan(a) <= (tan(f/57.2958) * (1-(1/c)))) else if (tan(a) <= ((tan(f/57.2958) * (1-(1/c)))+(l/cos(a)))) { pH->Set_Value(x, y, CR_STABLE); } } } } } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pH, P) && P("COLORS_TYPE") && P("LUT") ) { int CR_Colors[CR_COUNT] = { SG_GET_RGB(255, 255, 255), // CR_NODATA SG_GET_RGB(255, 0, 0), // CR_UNSTAB SG_GET_RGB(255, 128, 64), // CR_0-50 SG_GET_RGB(255, 255, 0), // CR_50-100 SG_GET_RGB( 0, 255, 0), // CR_100-200 SG_GET_RGB(128, 255, 255), // CR_200-400 SG_GET_RGB( 0, 0, 255), // CR_>400 SG_GET_RGB(128, 128, 128), // CR_STABLE }; //------------------------------------------------- CSG_Strings Name, Desc; Name += _TL("No data"); Desc += _TL(""); Name += _TL("Uncond. unstable"); Desc += _TL(""); Name += _TL("0-50 mm/day"); Desc += _TL(""); Name += _TL("50-100 mm/day"); Desc += _TL(""); Name += _TL("100-200 mm/day"); Desc += _TL(""); Name += _TL("200-400 mm/day"); Desc += _TL(""); Name += _TL(">400 mm/day"); Desc += _TL(""); Name += _TL("Uncond. stable"); Desc += _TL(""); //------------------------------------------------- CSG_Table *pTable = P("LUT")->asTable(); pTable->Del_Records(); for(int i=0; iAdd_Record(); pRecord->Set_Value(0, CR_Colors[i]); pRecord->Set_Value(1, Name[i].c_str()); pRecord->Set_Value(2, Desc[i].c_str()); pRecord->Set_Value(3, i); pRecord->Set_Value(4, i); } P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table DataObject_Set_Parameters(pH, P); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/Safetyfactor_01.cpp0000664000175000017500000003674212565125415030747 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Safetyfactor_01.cpp 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // Safetyfactor_01.cpp // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Safetyfactor_01.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSafetyfactor::CSafetyfactor(void) { Set_Name (_TL("SAFETYFACTOR")); Set_Author (SG_T("A. Günther (c) 2012")); Set_Description (_TW( "This module computes a slope stability (expressed as a factor-of-safety) raster according to the traditional infinite slope model theory (see cf Selby, 1993) " "The resulting raster represents the ratio of resisting forces/driving forces (fs) on a potential shear plane with fs lesser 1 unstable, fs greater 1 stable. " "Except for a slope raster (in radians), all input variables can be specified either globally or distributed (through grids). " "The module creates a continuous fs raster (values above 10 are truncated), and a binary stability grid with nodata = stable, 1 = unstable (optional)." )); Parameters.Add_Grid( NULL, "A", "Slope grid (rad)", "A slope angle grid (in radíans)", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "Bmin", "Min thickness grid (m) ", "A grid representing minimum cell layer thicknesses to potential shear plane (in meters)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Bmax", "Max thickness grid (m) ", "A grid representing maximum cell layer thicknesses to potential shear plane (in meters)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Cmin", "Min saturation grid (-) ", "A grid representing minimum cell relative water saturation of layer (dimensionless)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Cmax", "Max saturation grid (-) ", "A grid representing maximum cell relative water saturation of layer (dimensionless)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Dmin", "Min friction grid (degree) ", "A grid representing minimum cell frictional shear strength of layer (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Dmax", "Max friction grid (degree) ", "A grid representing maximum cell frictional shear strength of layer (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Emin", "Min density grid (g/cm3)", "A grid representing minimum cell bulk density of layer (in grams per cubiccentimeters)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Emax", "Max density grid (g/cm3)", "A grid representing maximum cell bulk density of layer (in grams per cubiccentimeters)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Fmin", "Min cohesion grid (MPa) ", "A grid representing minimum cell layer cohesion (in Megapascals)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Fmax", "Max cohesion grid (MPa) ", "A grid representing maximum cell layer cohesion (in Megapascals)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( NULL, "fBmin", "Min global thickness (m)", "Constant value if no raster set", PARAMETER_TYPE_Double, 1.0 //Initialisierung eines fixen wertes vs Grid für Mächtigkeit ); Parameters.Add_Value( NULL, "fBmax", "Max global thickness (m)", "Constant value if no raster set", PARAMETER_TYPE_Double, 1.0 //Initialisierung eines fixen wertes vs Grid für Mächtigkeit ); Parameters.Add_Value( NULL, "fCmin", "Min global saturation (-)", "Constant value if no raster set", PARAMETER_TYPE_Double, 0.0 //Initialisierung eines fixen wertes vs Grid für wetness ); Parameters.Add_Value( NULL, "fCmax", "Max global saturation (-)", "Constant value if no raster set", PARAMETER_TYPE_Double, 0.0 //Initialisierung eines fixen wertes vs Grid für wetness ); Parameters.Add_Value( NULL, "fDmin", "Min global friction (degree)", "Constant value if no raster set", PARAMETER_TYPE_Double, 33.0 //Initialisierung eines fixen wertes vs Grid für friction ); Parameters.Add_Value( NULL, "fDmax", "Max global friction (degree)", "Constant value if no raster set", PARAMETER_TYPE_Double, 33.0 //Initialisierung eines fixen wertes vs Grid für friction ); Parameters.Add_Value( NULL, "fEmin", "Min global density (g/cm3)", "Constant value if no raster set", PARAMETER_TYPE_Double, 1.6 //Initialisierung eines fixen wertes vs Grid für density ); Parameters.Add_Value( NULL, "fEmax", "Max global density (g/cm3)", "Constant value if no raster set", PARAMETER_TYPE_Double, 1.6 //Initialisierung eines fixen wertes vs Grid für density ); Parameters.Add_Value( NULL, "fFmin", "Min global cohesion (MPa)", "Constant value if no raster set", PARAMETER_TYPE_Double, 0.0 //Initialisierung eines fixen wertes vs Grid für Cohesion ); Parameters.Add_Value( NULL, "fFmax", "Max global cohesion (MPa)", "Constant value if no raster set", PARAMETER_TYPE_Double, 0.0 //Initialisierung eines fixen wertes vs Grid für Cohesion ); Parameters.Add_Value( NULL, "fI", "Parameter sampling runs", "Number of sampling cycles",PARAMETER_TYPE_Int, 1 //sampling cycles ); Parameters.Add_Grid( NULL, "G", "FS values", "Resulting factor-of-safety (-) grid", PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "H", "FS classes", "Resulting stability (0/1) grid", PARAMETER_OUTPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { FS_NODATA = 0, FS_UNSTABLE, FS_STAB1, FS_STAB2, FS_STAB3, FS_STAB4, FS_COUNT }; bool CSafetyfactor::On_Execute(void) { double fBmin = Parameters("fBmin")->asDouble(); double fCmin = Parameters("fCmin")->asDouble(); double fDmin = Parameters("fDmin")->asDouble(); double fEmin = Parameters("fEmin")->asDouble(); double fFmin = Parameters("fFmin")->asDouble(); double fBmax = Parameters("fBmax")->asDouble(); double fCmax = Parameters("fCmax")->asDouble(); double fDmax = Parameters("fDmax")->asDouble(); double fEmax = Parameters("fEmax")->asDouble(); double fFmax = Parameters("fFmax")->asDouble(); double grav = 9.81; int fI = Parameters("fI")->asInt(); CSG_Grid *pA, *pBmin, *pCmin, *pDmin, *pEmin, *pFmin, *pBmax, *pCmax, *pDmax, *pEmax, *pFmax, *pG, *pH; pA = Parameters("A" )->asGrid(); //slope pBmin = Parameters("Bmin" )->asGrid(); //thickness pCmin = Parameters("Cmin" )->asGrid(); //saturation pDmin = Parameters("Dmin" )->asGrid(); //friction pEmin = Parameters("Emin" )->asGrid(); //density pFmin = Parameters("Fmin" )->asGrid(); //cohesion pBmax = Parameters("Bmax" )->asGrid(); pCmax = Parameters("Cmax" )->asGrid(); //saturation pDmax = Parameters("Dmax" )->asGrid(); //friction pEmax = Parameters("Emax" )->asGrid(); //density pFmax = Parameters("Fmax" )->asGrid(); //cohesion pG = Parameters("G" )->asGrid(); pH = Parameters("H" )->asGrid(); for(int y=0; yasDouble(x, y); bmin = pBmin ? pBmin->asDouble(x, y) : fBmin; //Abfrage ob Raster oder Globalwerte cmin = pCmin ? pCmin->asDouble(x, y) : fCmin; dmin = pDmin ? pDmin->asDouble(x, y) : fDmin; emin = pEmin ? pEmin->asDouble(x, y) : fEmin; fmin = pFmin ? pFmin->asDouble(x, y) : fFmin; bmax = pBmax ? pBmax->asDouble(x, y) : fBmax; //Abfrage ob Raster oder Globalwerte cmax = pCmax ? pCmax->asDouble(x, y) : fCmax; dmax = pDmax ? pDmax->asDouble(x, y) : fDmax; emax = pEmax ? pEmax->asDouble(x, y) : fEmax; fmax = pFmax ? pFmax->asDouble(x, y) : fFmax; h = fI; if (pA->is_NoData(x, y)) { pG->Set_NoData(x, y); if (pH) pH->Set_Value(x, y, FS_NODATA); } else if( (pBmin || pBmax || pCmin || pCmax || pDmin || pDmax || pEmin || pEmax || pFmin || pFmax) && ( pBmin && pBmax->is_NoData(x, y) || pCmin && pCmax->is_NoData(x, y) || pDmin && pDmax->is_NoData(x, y) || pEmin && pEmax->is_NoData(x, y) || pFmin && pFmax->is_NoData(x, y) )) { pG->Set_NoData(x, y); if (pH) pH->Set_Value(x, y, FS_NODATA); } else { bperc = ((bmax - bmin) / bmax) * 100; //calculate parameter range %: density if (bperc > 0) { n = 0; bb = 0; while ( n < h) //loop through specified random number iterations: { rand_int = rand() % bperc + 0; //calculate random percentage b = ((bmax/100) * rand_int) + bmin; //calculate value bb = bb + b; //sum n = n + 1; } b = bb / n; // calculate mean from random values } else { b = bmax; } cperc = ((cmax - cmin) / cmax) * 100; //calculate parameter range %: density if (cperc > 0) { n = 0; cc = 0; while ( n < h) //loop through specified random number iterations: { rand_int = rand() % cperc + 0; //calculate random percentage c = ((cmax/100) * rand_int) + cmin; //calculate value cc = cc + c; //sum n = n + 1; } c = cc / n; // calculate mean from random values } else { c = cmax; } dperc = ((dmax - dmin) / dmax) * 100; if (dperc > 0) { n = 0; dd = 0; while ( n < h) { rand_int = rand() % dperc + 0; d = ((dmax/100) * rand_int) + dmin; dd = dd + d; n = n + 1; } d = dd / n; } else { d = dmax; } eperc = ((emax - emin) / emax) * 100; if (eperc > 0) { n = 0; ee = 0; while ( n < h) { rand_int = rand() % eperc + 0; e = ((emax/100) * rand_int) + emin; ee = ee + e; n = n + 1; } e = ee / n; } else { e = emax; } fperc = ((fmax - fmin) / fmax) * 100; if (fperc > 0) { n = 0; ff = 0; while ( n < h) { rand_int = rand() % fperc + 0; f = ((fmax/100) * rand_int) + fmin; ff = ff + f; n = n + 1; } f = ff / n; } else { f = fmax; } g = ((f * 1000) + (((e * grav) - (c * grav)) * //FS calculation (((b * pow(cos(a), 2) * tan(d/57.2958)))))) / ((e * grav) * b * sin(a) * cos(a)); if (g < 10) //truncate values fs>10 pG->Set_Value(x, y, g); else pG->Set_Value(x, y, 10); if (pH) //create optional binary stabilty grid { if (g < 1) pH->Set_Value(x, y, FS_UNSTABLE); else if ((g >= 1) && (g < 1.5)) pH->Set_Value(x, y, FS_STAB1); else if ((g >= 1.5) && (g < 3)) pH->Set_Value(x, y, FS_STAB2); else if ((g >= 3) && (g < 6)) pH->Set_Value(x, y, FS_STAB3); else if (g >= 6) pH->Set_Value(x, y, FS_STAB4); } } } } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pH, P) && P("COLORS_TYPE") && P("LUT") ) { int TO_Colors[FS_COUNT] = { SG_GET_RGB(255, 255, 255), // FS_NODATA SG_GET_RGB(255, 0, 0), // FS_UNSTABLE SG_GET_RGB(255, 128, 64), // FS_STAB1 SG_GET_RGB(255, 255, 0), // FS_STAB2 SG_GET_RGB( 0, 128, 255), // FS_STAB3 SG_GET_RGB( 0, 255, 0), // FS_STAB4 }; //------------------------------------------------- CSG_Strings Name, Desc; Name += _TL("NO DATA"); Desc += _TL(""); Name += _TL("FS <1"); Desc += _TL(""); Name += _TL("FS 1-1.5"); Desc += _TL(""); Name += _TL("FS 1.5-3"); Desc += _TL(""); Name += _TL("FS 3-6"); Desc += _TL(""); Name += _TL("FS >6"); Desc += _TL(""); //------------------------------------------------- CSG_Table *pTable = P("LUT")->asTable(); pTable->Del_Records(); for(int i=0; iAdd_Record(); pRecord->Set_Value(0, TO_Colors[i]); pRecord->Set_Value(1, Name[i].c_str()); pRecord->Set_Value(2, Desc[i].c_str()); pRecord->Set_Value(3, i); pRecord->Set_Value(4, i); } P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table DataObject_Set_Parameters(pH, P); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/WEDGEFAIL_01.cpp0000664000175000017500000002607612565125415027603 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: WEDGEFAIL_01.cpp 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // WEDGEFAIL_01.cpp // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "WEDGEFAIL_01.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWEDGEFAIL::CWEDGEFAIL(void) { CSG_Parameters P; //----------------------------------------------------- Set_Name (_TL("WEDGEFAIL")); Set_Author (SG_T("A. Günther (c) 2012")); Set_Description (_TW( "\n" "This module determines terrain elements where failure (slide- or topple movements) on geological discontinuies are kinematically possible " "through the spatial application of common frictional feasibility criteria (Günther et al. 2012 and references therein). Both the orientation of slope elements " "specified through aspect- and dip grids (in radians) are required together with the orientation of one planar structure defined through global- or grid dip direction and dip data, " "or two planar structures defined by plunge direction and plunge information of their intersection line (in degrees). The shear strength of the discontinuities is specified " "using global or grid-based friction angle data. Optionally, a cone value can be set allowing for some variance in discontinuity dip orientations. " "The tool operates in slide (testing for plane and wedge sliding) or topple (testing for plane and wedge toppling) modes.\n" "\n" "Reference:\n" "Günther A., Wienhöfer J., Konietzky H. (2012) Automated mapping of rock slope geometry, kinematics and stability with RSS-GIS. Natural Hazards, 61, 29-49..\n" )); Parameters.Add_Grid( NULL, "DEM", "DEM", "A DEM", PARAMETER_INPUT ); /*Parameters.Add_Grid( NULL, "B", "Aspect grid (rad)", "A aspect angle grid (in radians)", PARAMETER_INPUT );*/ Parameters.Add_Grid( NULL, "C", "Dip/Plunge direction grid (degree) ", "A dip- or plunge direction grid (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "D", "Dip/Plunge grid (degree) ", "A dip- or plunge grid (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Emin", "Min friction angle grid (degree) ", "A minimum discontinuity friction angle grid (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Emax", "Max friction angle grid (degree) ", "A maximum discontinuity friction angle grid (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( NULL, "fC", "Global dip/plunge direction (degree)", "Constant value if no raster set", PARAMETER_TYPE_Double, 0 //Initialisierung eines fixen wertes vs Grid für density ); Parameters.Add_Value( NULL, "fD", "Global dip/plunge (degree)", "Constant value if no raster set", PARAMETER_TYPE_Double, 35 //Initialisierung eines fixen wertes vs Grid für conductivity ); Parameters.Add_Value( NULL, "fEmin", "Min global friction angle (degree)", "Constant value if no raster set", PARAMETER_TYPE_Double, 35 //Initialisierung eines fixen wertes vs Grid für depth ); Parameters.Add_Value( NULL, "fEmax", "Max global friction angle (degree)", "Constant value if no raster set", PARAMETER_TYPE_Double, 35 //Initialisierung eines fixen wertes vs Grid für depth ); Parameters.Add_Value( NULL, "ff", "Cone radius (degree)", "Radius of optional cone variance (in degrees)", PARAMETER_TYPE_Int, 0 //Initialisierung eines fixen wertes vs Grid für depth ); Parameters.Add_Grid( NULL, "F", "Failures", "Resulting failure cells (-) grid", PARAMETER_OUTPUT ); Parameters.Add_Value( NULL, "fI", "Parameter sampling runs", "Number of sampling cycles",PARAMETER_TYPE_Int, 1 //sampling cycles ); Parameters.Add_Choice( NULL, "METHOD" , "Mode", "Set failure mode", "Slide|Topple" ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { FI_NODATA = 0, FI_FAILURE, FI_NO_FAILURE, FI_COUNT }; bool CWEDGEFAIL::On_Execute(void) { int Method = Parameters("METHOD" )->asInt(); int ff = Parameters("ff" )->asInt(); double fC = Parameters("fC" )->asDouble(); double fD = Parameters("fD" )->asDouble(); double fEmin = Parameters("fEmin" )->asDouble(); double fEmax = Parameters("fEmax" )->asDouble(); int fI = Parameters("fI" )->asInt(); CSG_Grid *pDEM, *pC, *pD, *pEmin, *pEmax, *pF; pDEM = Parameters("DEM" )->asGrid(); //DEM //pB = Parameters("B" )->asGrid(); //aspect pC = Parameters("C" )->asGrid(); //dip dir pD = Parameters("D" )->asGrid(); //dip pEmin = Parameters("Emin" )->asGrid(); //friction pEmax = Parameters("Emax" )->asGrid(); //friction pF = Parameters("F" )->asGrid(); //output failure for(int y=0; yasDouble(x, y); //b = pB->asDouble(x, y); //Abfrage ob Raster oder Globalwerte: c = pC ? pC->asDouble(x, y) : fC; d = pD ? pD->asDouble(x, y) : fD; emin = pEmin ? pEmin->asDouble(x, y) : fEmin; emax = pEmax ? pEmax->asDouble(x, y) : fEmax; h = fI; if (pDEM->Get_Gradient(x, y, a, b)==false) { pF->Set_Value(x, y, FI_NODATA); } else if ((pC || pD) && (pC->is_NoData(x, y) || pD->is_NoData(x, y))) { pF->Set_Value(x, y, FI_NODATA); } else { eperc = (int)(((emax - emin) / emax) * 100.0); if (eperc > 0) { n = 0; ee = 0; while ( n < h) { rand_int = rand() % eperc + 0; e = ((emax/100) * rand_int) + emin; ee = ee + e; n = n + 1; } e = ee / n; } else { e = emax; } if ((b*M_RAD_TO_DEG) >= c) //Azimuthaldifferenz in grad f = (b*M_RAD_TO_DEG) - c; else if ((b*M_RAD_TO_DEG) < c) f = c - (b*M_RAD_TO_DEG); else f = 0; g = atan((cos(f/M_RAD_TO_DEG)) * tan(a+(ff/M_RAD_TO_DEG))) * M_RAD_TO_DEG; //Berechung apparent slope dip in direction plane/cedge switch (Method) { case 0: //wedge/plane slides if ((e <= d) && (d <= g)) pF->Set_Value(x, y, FI_FAILURE); else pF->Set_Value(x, y, FI_NO_FAILURE); break; case 1: //wedge/plane topples if (g >= ((e+90)-d)) pF->Set_Value(x, y, FI_FAILURE); else pF->Set_Value(x, y, FI_NO_FAILURE); break; } } } } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pF, P) && P("COLORS_TYPE") && P("LUT") ) { int CR_Colors[FI_COUNT] = { SG_GET_RGB(255, 255, 255), // FI_NO_DATA SG_GET_RGB(255, 0, 0), // FI_FAILURE SG_GET_RGB(255, 255, 128), // FI_NO_FAILURE }; //------------------------------------------------- CSG_Strings Name, Desc; Name += _TL("No Data"); Desc += _TL(""); Name += _TL("Failure"); Desc += _TL(""); Name += _TL("No Failure"); Desc += _TL(""); //------------------------------------------------- CSG_Table *pTable = P("LUT")->asTable(); pTable->Del_Records(); for(int i=0; iAdd_Record(); pRecord->Set_Value(0, CR_Colors[i]); pRecord->Set_Value(1, Name[i].c_str()); pRecord->Set_Value(2, Desc[i].c_str()); pRecord->Set_Value(3, i); pRecord->Set_Value(4, i); } P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table DataObject_Set_Parameters(pF, P); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/ANGMAP_01.cpp0000664000175000017500000001763512565125415027260 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ANGMAP_01.cpp 1948 2014-01-17 15:09:07Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // ANGMAP_01.cpp // // // // Copyright (C) 2013 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ANGMAP_01.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CANGMAP::CANGMAP(void) { Set_Name (_TL("ANGMAP")); Set_Author (SG_T("A. Günther (c) 2013")); Set_Description (_TW( "\n" "This module computes the acute angle raster between the topographic surface defined by slope and aspect rasters internally derived from input elevation raster, and a structural plane defined by diop direction- and dip grids. " "Optionally, the dip direction and dip of the cutting line linears between the two planes can be calculated" "\n" "Reference: " "Günther, A. (2003). SLOPEMAP: programs for automated mapping of geometrical and kinematical properties of hard rock hill slopes. Computers & Geosciences, 29, 865 - 875.\n" )); Parameters.Add_Grid( NULL, "DEM", "Elevation", "A Digital Elvation Model (DEM)", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "C", "Dip grid (degrees) ", "A grid representing the dip of the structure plane (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "D", "Dip direction grid (degrees) ", "A grid representing the dip direction of the structure plane (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( NULL, "fB", "Global structure dip (degrees)", "Constant value if no raster set", PARAMETER_TYPE_Double, 45.0 //Initialisierung eines fixen wertes vs Grid für dip ); Parameters.Add_Value( NULL, "fC", "Global structure dip direction (degrees)", "Constant value if no raster set", PARAMETER_TYPE_Double, 90.0 //Initialisierung eines fixen wertes vs Grid für dipdir ); Parameters.Add_Grid( NULL, "E", "Angle", "Acute angle (degrees) grid", PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "F", "CL dipdir", "Dip direction cutting line (degrees)",PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "G", "CL dip", "Dip cutting line (degrees)",PARAMETER_OUTPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CANGMAP::On_Execute(void) { double fB = Parameters("fB")->asDouble(); double fC = Parameters("fC")->asDouble(); CSG_Grid *pDEM, *pC, *pD, *pE, *pF, *pG; pDEM = Parameters("DEM")->asGrid(); //elevation pC = Parameters("C" )->asGrid(); //dip grid pD = Parameters("D" )->asGrid(); //dip dir grid pE = Parameters("E" )->asGrid(); //output angles pF = Parameters("F" )->asGrid(); //output ce dipdir pG = Parameters("G" )->asGrid(); //output ce dip for(int y=0; yGet_Gradient(x, y, a, b) || (pC && pC->is_NoData(x, y)) || (pD && pD->is_NoData(x, y)) ) { if (pE) pE->Set_NoData(x, y); if (pF) pF->Set_NoData(x, y); if (pG) pG->Set_NoData(x, y); } else { double s1, s2, s3, s4, c1, c2, c3, c4; double px, py, pz; double p, pp, ff, aa; c = pC ? pC->asDouble(x, y) : fB; //Abfrage ob Raster oder Globalwerte d = pD ? pD->asDouble(x, y) : fC; //Abfrage ob Raster oder Globalwerte s1 = sin(b + M_PI); s2 = sin((d * M_DEG_TO_RAD) + M_PI); s3 = sin((M_PI/2) - a); s4 = sin((M_PI/2) - (c * M_DEG_TO_RAD)); c1 = cos(b + M_PI); c2 = cos((d * M_DEG_TO_RAD) + M_PI); c3 = cos((M_PI/2) - a); c4 = cos((M_PI/2) - (c * M_DEG_TO_RAD)); px = (s1 * c3 * s4) - (s3 * s2 * s4); py = (s3 * c2 * c4) - (c1 * c3 * c4); pz = (c1 * c3 * s2 * 4) - (s1 * c3 * c2 * c4); if (pz < 0) { px = px * -1; py = py * -1; pz = pz * -1; } p = sqrt((px * px) + (py * py) + (pz * pz)); pp = pz / p; ff = atan(pp / sqrt((1 - (pp * pp)))); aa = atan(py / px); e = ff * M_RAD_TO_DEG; f = aa * M_RAD_TO_DEG; if (px < 0) f = f + 180; else if ((px < 0) && (py < 0)) f = f + 360; if (f > 360) f = f - 360; if (f < 0) f = f + 360; g = sin(p) * M_RAD_TO_DEG; if (pE) pE->Set_Value(x, y, e); if (pF) pF->Set_Value(x, y, f); if (pG) pG->Set_Value(x, y, g); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/WETNESS_01.h0000664000175000017500000000747612565125415027114 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: WETNESS_01.h 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // WETNESS_01.h // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWETNESS : public CSG_Module_Grid { public: CWETNESS(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/SHALSTAB_01.h0000664000175000017500000000750112565125415027152 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SHALSTAB_01.h 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // SHALSTAB_01.h // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSHALSTAB : public CSG_Module_Grid { public: CSHALSTAB(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/Makefile.in0000664000175000017500000005563212622651177027360 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/ta_slope_stability DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libta_slope_stability_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libta_slope_stability_la_OBJECTS = ANGMAP_01.lo MLB_Interface.lo \ Safetyfactor_01.lo SHALSTAB_01.lo TOBIA_01.lo WEDGEFAIL_01.lo \ WETNESS_01.lo libta_slope_stability_la_OBJECTS = \ $(am_libta_slope_stability_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libta_slope_stability_la_SOURCES) DIST_SOURCES = $(libta_slope_stability_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_slope_stability.la libta_slope_stability_la_SOURCES = \ ANGMAP_01.cpp\ MLB_Interface.cpp\ Safetyfactor_01.cpp\ SHALSTAB_01.cpp\ TOBIA_01.cpp\ WEDGEFAIL_01.cpp\ WETNESS_01.cpp\ ANGMAP_01.h\ MLB_Interface.h\ Safetyfactor_01.h\ SHALSTAB_01.h\ TOBIA_01.h\ WEDGEFAIL_01.h\ WETNESS_01.h libta_slope_stability_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) --foreign src/modules/terrain_analysis/ta_slope_stability/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/terrain_analysis/ta_slope_stability/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libta_slope_stability.la: $(libta_slope_stability_la_OBJECTS) $(libta_slope_stability_la_DEPENDENCIES) $(EXTRA_libta_slope_stability_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libta_slope_stability_la_OBJECTS) $(libta_slope_stability_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ANGMAP_01.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SHALSTAB_01.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Safetyfactor_01.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TOBIA_01.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WEDGEFAIL_01.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WETNESS_01.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/Safetyfactor_01.h0000664000175000017500000000751512565125415030410 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Safetyfactor_01.h 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // Safetyfactor_01.h // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSafetyfactor : public CSG_Module_Grid { public: CSafetyfactor(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/WETNESS_01.cpp0000664000175000017500000003714312565125415027441 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: WETNESS_01.cpp 2231 2014-09-15 14:47:01Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // WETNESS_01.cpp // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "WETNESS_01.h" #include //--------------------------------------------------------- #define RUN_MODULE(LIBRARY, MODULE, CONDITION) {\ bool bResult;\ SG_RUN_MODULE(bResult, LIBRARY, MODULE, CONDITION)\ if( !bResult ) return( false );\ } #define SET_PARAMETER(IDENTIFIER, VALUE) pModule->Get_Parameters()->Set_Parameter(SG_T(IDENTIFIER), VALUE) //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWETNESS::CWETNESS(void) { CSG_Parameters P; //----------------------------------------------------- Set_Name (_TL("WETNESS")); Set_Author (SG_T("A. Günther (c) 2012")); Set_Description (_TW( "\n" "This module calculates a topographic wetness index (TWI) following Montgomery & Dietrich (1994) that can be used to estimate the degree of saturation of unconsolidated, permeable " "materials above (more or less) impermeable bedrock. In contrast to the common TOPMODEL (Beven & Kirkby, 1979) - based TWI, this index differs in such that it considers " "hydraulic conductivity to be constant in a soil mantle overlying relatively impermeable bedrock. Also, it uses the sine of the slope rather than its tangens, which is more correct " "and significantly matters for steeper slopes that give raise to landslides. " "For computation, a slope (in radians) and a catchment area (in m2) grid are required. " "Additionally, information on groundwater recharge (m/hr), material hydraulic conductivity (m/hr), " "and depth to potential shear plane (m) are required that can be specified either globally or through grids. " "The module produces a continuous wetness index (-) where cells with WI values > 1 (overland flow) set to 1, and optionally creates a classified WI grid rendering three saturation classes:.\n" "0): Low moisture (WI smaller 0.1)\n" "1): Partially wet (0.1 smaller WI smaller 1)\n" "2): Saturation zone (WI larger 1)\n" "\n" "References:\n" "Beven, K.J., Kirkby, M.J. (1979) A physically-based variable contributing area model of basin hydrology. Hydrology Science Bulletin, 24, 43-69..\n" "\n" "Montgomery D. R., Dietrich, W. E. (1994) A physically based model for the topographic control on shallow landsliding. Water Resources Research, 30, 1153-1171..\n" )); Parameters.Add_Grid( NULL, "DEM", "DEM", "A DEM", PARAMETER_INPUT ); /*Parameters.Add_Grid( NULL, "B", "Catchment area grid (m2)", "A catchment area grid (in square meters)", PARAMETER_INPUT ); */ Parameters.Add_Grid( NULL, "Cmin", "Min hydraulic conductivity grid (m/hr) ", "A grid representing minimum material hydraulic conductivity (in m/hr)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Cmax", "Max hydraulic conductivity grid (m/hr) ", "A grid representing maximum material hydraulic conductivity (in m/hr)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Dmin", "Min groundwater recharge grid (m/hr) ", "A grid representing minimum groundwater recharge (in m/hr)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Dmax", "Max groundwater recharge grid (m/hr) ", "A grid representing maximum groundwater recharge (in m/hr)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Emin", "Min material depth grid (m)", "A grid representing minimum depth to potential shear plane (in m)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "Emax", "Max material depth grid (m)", "A grid representing maximum depth to potential shear plane (in m)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( NULL, "fCmin", "Min global material conductivity (m/hr)", "Constant value if no raster set", PARAMETER_TYPE_Double, 2.7 //Initialisierung eines fixen wertes vs Grid für density ); Parameters.Add_Value( NULL, "fCmax", "Max global material conductivity (m/hr)", "Constant value if no raster set", PARAMETER_TYPE_Double, 2.7 //Initialisierung eines fixen wertes vs Grid für density ); Parameters.Add_Value( NULL, "fDmin", "Min global groundwater recharge (m/hr)", "Constant value if no raster set", PARAMETER_TYPE_Double, 0.001 //Initialisierung eines fixen wertes vs Grid für conductivity ); Parameters.Add_Value( NULL, "fDmax", "Max global groundwater recharge (m/hr)", "Constant value if no raster set", PARAMETER_TYPE_Double, 0.001 //Initialisierung eines fixen wertes vs Grid für conductivity ); Parameters.Add_Value( NULL, "fEmin", "Min global material depth (m)", "Constant value if no raster set", PARAMETER_TYPE_Double, 1.0 //Initialisierung eines fixen wertes vs Grid für depth ); Parameters.Add_Value( NULL, "fEmax", "Max global material depth (m)", "Constant value if no raster set", PARAMETER_TYPE_Double, 1.0 //Initialisierung eines fixen wertes vs Grid für depth ); Parameters.Add_Value( NULL, "fH", "Parameter sampling runs", "Number of sampling cycles",PARAMETER_TYPE_Int, 1 //sampling cycles ); Parameters.Add_Grid( NULL, "F", "WI values", "Resulting wetness index (-) grid", PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "G", "WI classes", "Classified wetness (-) grid", PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Catchment Area Calculation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("Deterministic 8"), _TL("Rho 8"), _TL("Braunschweiger Reliefmodell"), _TL("Deterministic Infinity"), _TL("Multiple Flow Direction"), _TL("Multiple Triangular Flow Directon") ), 4 ); Parameters.Add_Value( NULL , "PREPROC" , _TL("Preprocessing"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { WI_NODATA = 0, WI_LOW_MOISTURE, WI_PARTIALLY_WET, WI_SATURATION_ZONE, WI_COUNT }; bool CWETNESS::On_Execute(void) { double fCmin = Parameters("fCmin")->asDouble(); double fDmin = Parameters("fDmin")->asDouble(); double fEmin = Parameters("fEmin")->asDouble(); double fCmax = Parameters("fCmax")->asDouble(); double fDmax = Parameters("fDmax")->asDouble(); double fEmax = Parameters("fEmax")->asDouble(); double fH = Parameters("fH")->asInt(); CSG_Grid *pDEM, *pB, *pCmin, *pDmin, *pEmin, *pCmax, *pDmax, *pEmax,*pF, *pG; pDEM = Parameters("DEM" )->asGrid(); //DEM pCmin = Parameters("Cmin" )->asGrid(); //conductivity pDmin = Parameters("Dmin" )->asGrid(); //recharge pEmin = Parameters("Emin" )->asGrid(); //depth pCmax = Parameters("Cmax" )->asGrid(); //conductivity pDmax = Parameters("Dmax" )->asGrid(); //recharge pEmax = Parameters("Emax" )->asGrid(); //depth pF = Parameters("F" )->asGrid(); //output wetness index pG = Parameters("G" )->asGrid(); //output wetness classes //----------------------------------------------------- // get catchment area sizes CSG_Grid B(*Get_System(), SG_DATATYPE_Float); pB = &B; if( Parameters("PREPROC")->asBool() ) { CSG_Grid DEM(*Get_System(), SG_DATATYPE_Float); RUN_MODULE("ta_preprocessor" , 2, SET_PARAMETER("DEM" , pDEM) && SET_PARAMETER("DEM_PREPROC" , &DEM) ) RUN_MODULE("ta_hydrology" , 0, SET_PARAMETER("ELEVATION" , &DEM) && SET_PARAMETER("CAREA" , pB) && SET_PARAMETER("METHOD" , Parameters("METHOD")) ) } else { RUN_MODULE("ta_hydrology" , 0, SET_PARAMETER("ELEVATION" , pDEM) && SET_PARAMETER("CAREA" , pB) && SET_PARAMETER("METHOD" , Parameters("METHOD")) ) } //----------------------------------------------------- for(int y=0; yasDouble(x, y); //Abfrage ob Raster oder Globalwerte: cmin = pCmin ? pCmin->asDouble(x, y) : fCmin; dmin = pDmin ? pDmin->asDouble(x, y) : fDmin; emin = pEmin ? pEmin->asDouble(x, y) : fEmin; cmax = pCmax ? pCmax->asDouble(x, y) : fCmax; dmax = pDmax ? pDmax->asDouble(x, y) : fDmax; emax = pEmax ? pEmax->asDouble(x, y) : fEmax; h = fH; if (pDEM->Get_Gradient(x, y, a, ee)==false || (pCmin && pCmin->is_NoData(x, y)) || (pCmax && pCmax->is_NoData(x, y)) || (pDmin && pDmin->is_NoData(x, y)) || (pDmax && pDmax->is_NoData(x, y)) || (pEmin && pEmin->is_NoData(x, y)) || (pEmax && pEmax->is_NoData(x, y)) ) { pF->Set_NoData(x, y); if (pG) pG->Set_Value(x, y, WI_NODATA); } else { cperc = ((cmax - cmin) / cmax) * 100; //calculate parameter range %: conductivity if (cperc > 0) { n = 0; cc = 0; while ( n < h) //loop through specified random number iterations: { rand_int = rand() % cperc + 0; //calculate random percentage c = ((cmax/100) * rand_int) + cmin; //calculate value cc = cc + c; //sum n = n + 1; } c = cc / n; // calculate mean from random values } else { c = cmax; } dperc = ((dmax - dmin) / dmax) * 100; //calculate parameter range %: recharge if (dperc > 0) { n = 0; dd = 0; while ( n < h) //loop through specified random number iterations: { rand_int = rand() % dperc + 0; //calculate random percentage d = ((dmax/100) * rand_int) + dmin; //calculate value dd = dd + d; //sum n = n + 1; } d = dd / n; // calculate mean from random values } else { d = dmax; } eperc = ((emax - emin) / emax) * 100; //calculate parameter range %: depth if (eperc > 0) { n = 0; ee = 0; while ( n < h) //loop through specified random number iterations: { rand_int = rand() % eperc + 0; //calculate random percentage e = ((emax/100) * rand_int) + emin; //calculate value ee = ee + e; //sum n = n + 1; } e = ee / n; // calculate mean from random values } else { e = emax; } f = (d*(b/pB->Get_Cellsize()))/((c*e)*sin(a)); //Wetness index calculation if (f < 1) //calculate wetness index grid pF->Set_Value(x, y, f); else if (f >= 1) pF->Set_Value(x, y, 1); else pF->Set_NoData(x, y); if (pG) //calculate optional classified grid { if (f <= 0.1) pG->Set_Value(x, y, WI_LOW_MOISTURE); else if( f <= 1 )// if ((f > 0.1) && (f <= 1)) pG->Set_Value(x, y, WI_PARTIALLY_WET); else //if (f > 1) pG->Set_Value(x, y, WI_SATURATION_ZONE); } } } } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pG, P) && P("COLORS_TYPE") && P("LUT") ) { int CR_Colors[WI_COUNT] = { SG_GET_RGB(255, 255, 255), // WI_NODATA SG_GET_RGB(255, 255, 0), // WI_LOW_MOISTURE SG_GET_RGB(0, 255, 0), // WI_PARTIALLY_WET SG_GET_RGB(0, 0, 255), // WI_SATURATION_ZONE }; //------------------------------------------------- CSG_Strings Name, Desc; Name += _TL("No data"); Desc += _TL(""); Name += _TL("Low moisture (WI <= 0.1"); Desc += _TL(""); Name += _TL("Partially wet (WI = 0.1 - 1)"); Desc += _TL(""); Name += _TL("Saturation zone (WI > 1)"); Desc += _TL(""); //------------------------------------------------- CSG_Table *pTable = P("LUT")->asTable(); pTable->Del_Records(); for(int i=0; iAdd_Record(); pRecord->Set_Value(0, CR_Colors[i]); pRecord->Set_Value(1, Name[i].c_str()); pRecord->Set_Value(2, Desc[i].c_str()); pRecord->Set_Value(3, i); pRecord->Set_Value(4, i); } P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table DataObject_Set_Parameters(pG, P); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/TOBIA_01.cpp0000664000175000017500000002430212565125415027140 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: TOBIA_01.cpp 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // TOBIA_01.cpp // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "TOBIA_01.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTOBIA::CTOBIA(void) { Set_Name (_TL("TOBIA")); Set_Author (SG_T("A. Günther (c) 2012")); Set_Description (_TW( "\n" "This module computes both a continuous and a categorical TOBIA (""Topography Bedding Intersection Angle"") Index according to Meentemeyer & Moody (2000) " "For computation, a slope and a aspect raster (both in radians) determining slope face orientations are required. " "The categorical TOBIA classifies the alignement of a geological structure to Topography into seven classes:\n" "0) Underdip slope\n" "1) Dip slope\n" "2) Overdip slope\n" "3) Steepened escarpmemt\n" "4) Normal escarpment\n" "5) Subdued escarpment\n" "6) Orthoclinal slope\n" "The continuous TOBIA index ranges from -1 to 1 (parallel orientation)\n" "The structure TOBIA should be calculated with can be set either distributed (through dip direction and dip grids, in degrees!), " "or globally using integers (dip and dip direction, in degrees!). The module creates a TOBIA class integer grid, and (optionally) a continuous TOBIA index grid.\n" "\n" "Reference: " "Meentemeyer R. K., Moody A. (2000). Automated mapping of conformity between topographic and geological surfaces. Computers & Geosciences, 26, 815 - 829.\n" )); Parameters.Add_Grid( NULL, "A", "Slope grid (rad)", "A slope angle grid (in radíans)", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "B", "Aspect grid (rad)", "A aspect angle grid (in radíans)", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "C", "Dip grid (degrees) ", "A grid representing the dip of the structure plane (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "D", "Dip direction grid (degrees) ", "A grid representing the dip direction of the structure plane (in degrees)", PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( NULL, "fB", "Global structure dip (degrees)", "Constant value if no raster set", PARAMETER_TYPE_Double, 45.0 //Initialisierung eines fixen wertes vs Grid für dip ); Parameters.Add_Value( NULL, "fC", "Global structure dip direction (degrees)", "Constant value if no raster set", PARAMETER_TYPE_Double, 90.0 //Initialisierung eines fixen wertes vs Grid für dipdir ); Parameters.Add_Grid( NULL, "E", "TOBIA classes", "Resulting TOBIA classses (1-7) grid", PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "F", "TOBIA index", "Resulting TOBIA index (-) grid",PARAMETER_OUTPUT_OPTIONAL ); } enum { TO_UNDERDIP_SLOPE = 0, TO_DIP_SLOPE, TO_OVERDIP_SLOPE, TO_STEEPENED_ESCARPMENT, TO_NORMAL_ESCARPMENT, TO_SUBDUED_ESCARPMENT, TO_ORTHOCLINAL_SLOPE, TO_COUNT }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTOBIA::On_Execute(void) { double fB = Parameters("fB")->asDouble(); double fC = Parameters("fC")->asDouble(); CSG_Grid *pA, *pB, *pC, *pD, *pE, *pF; pA = Parameters("A" )->asGrid(); //slope pB = Parameters("B" )->asGrid(); //aspect pC = Parameters("C" )->asGrid(); //dip grid pD = Parameters("D" )->asGrid(); //dip dir grid pE = Parameters("E" )->asGrid(); //output TOBIA classes pF = Parameters("F" )->asGrid(); //output TOBIA index for(int y=0; yasDouble(x, y); b = pB->asDouble(x, y); //Abfrage ob Raster oder Globalwerte c = pC ? pC->asDouble(x, y) : fB; d = pC ? pD->asDouble(x, y) : fC; if (pA->is_NoData(x, y)) { pE->Set_NoData(x, y); if (pF) pF->Set_NoData(x, y); } else if ((pC || pD) && (pC->is_NoData(x, y) || (pD->is_NoData(x, y)))) { pE->Set_NoData(x, y); if (pF) pF->Set_NoData(x, y); } else { e = pow(pow((cos(d/57.2958) - cos(b)), 2) + pow((sin(d/57.2958) - sin(b)), 2), 0.5); //TOBIA-classes if (((0 <= e) && (e < 0.7654)) && ((c - (a*57.2958)) > 5)) pE->Set_Value(x, y, TO_UNDERDIP_SLOPE); else if (((0 <= e) && (e < 0.7654)) && ((-5 <= (c - (a*57.2958))) && ((c - (a*57.2958) <= 5)))) pE->Set_Value(x, y, TO_DIP_SLOPE); else if (((0 <= e) && (e < 0.7654)) && ((c - (a*57.2958)) < -5)) pE->Set_Value(x, y, TO_OVERDIP_SLOPE); else if (((1.8478 < e) && (e <= 2)) && ((c - (a*57.2958)) < -5)) pE->Set_Value(x, y, TO_STEEPENED_ESCARPMENT); else if (((1.8478 < e) && (e <= 2)) && ((-5 <= (c - (a*57.2958))) && ((c - (a*57.2958) <= 5)))) pE->Set_Value(x, y, TO_NORMAL_ESCARPMENT); else if (((1.8478 < e) && (e <= 2)) && ((c - (a*57.2958)) > 5)) pE->Set_Value(x, y, TO_SUBDUED_ESCARPMENT); else if ((0.7654 < e) && (e <= 1.8478)) pE->Set_Value(x, y, TO_ORTHOCLINAL_SLOPE); else pE->Set_NoData_Value(0); if (pF) { f = (cos((c/57.2958)) * (cos(a))) + (sin(c/57.2958) * sin(a) * ((cos((d/57.2958) - b)))); //TOBIA-index pF->Set_Value(x, y, f); } } } } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pE, P) && P("COLORS_TYPE") && P("LUT") ) { int TO_Colors[TO_COUNT] = { SG_GET_RGB(255, 255, 0), // TO_UNDERDIP SG_GET_RGB(255, 128, 0), // TO_DIP SG_GET_RGB(255, 0, 0), // TO_OVERDIP SG_GET_RGB( 0, 0, 128), // TO_STEEPENED SG_GET_RGB( 0, 128, 255), // TO_NORMAL SG_GET_RGB(128, 255, 255), // TO_SUBDUED SG_GET_RGB( 0, 255, 64), // TO_ORTHOCLINAL }; //------------------------------------------------- CSG_Strings Name, Desc; Name += _TL("Underdip slope"); Desc += _TL(""); Name += _TL("Dip slope"); Desc += _TL(""); Name += _TL("Overdip slope"); Desc += _TL(""); Name += _TL("Steepened escarpment"); Desc += _TL(""); Name += _TL("Normal escarpment"); Desc += _TL(""); Name += _TL("Subdued escarpment"); Desc += _TL(""); Name += _TL("Orthoclinal slope"); Desc += _TL(""); //------------------------------------------------- CSG_Table *pTable = P("LUT")->asTable(); pTable->Del_Records(); for(int i=0; iAdd_Record(); pRecord->Set_Value(0, TO_Colors[i]); pRecord->Set_Value(1, Name[i].c_str()); pRecord->Set_Value(2, Desc[i].c_str()); pRecord->Set_Value(3, i); pRecord->Set_Value(4, i); } P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table DataObject_Set_Parameters(pE, P); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/MLB_Interface.cpp0000664000175000017500000001155312565125415030400 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2304 2014-10-24 08:55:03Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // 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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return(_TL("Slope Stability")); case MLB_INFO_Category: return( _TL("Terrain Analysis") ); case MLB_INFO_Author: return("A. Günther (c) 2012"); case MLB_INFO_Description: return(_TW( "Tools for slope stability analyses. " "Developed by Andreas Günther, BGR, B2.2" )); case MLB_INFO_Version: return("1.0"); case MLB_INFO_Menu_Path: return(_TL("Terrain Analysis|Slope Stability")); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Safetyfactor_01.h" #include "TOBIA_01.h" #include "SHALSTAB_01.h" #include "WETNESS_01.h" #include "WEDGEFAIL_01.h" #include "ANGMAP_01.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CSafetyfactor ); case 1: return( new CTOBIA ); case 2: return( new CSHALSTAB ); case 3: return( new CWETNESS ); case 4: return( new CWEDGEFAIL ); case 5: return( new CANGMAP ); case 11: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/Makefile.am0000664000175000017500000000143412565125415027333 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_slope_stability.la libta_slope_stability_la_SOURCES =\ ANGMAP_01.cpp\ MLB_Interface.cpp\ Safetyfactor_01.cpp\ SHALSTAB_01.cpp\ TOBIA_01.cpp\ WEDGEFAIL_01.cpp\ WETNESS_01.cpp\ ANGMAP_01.h\ MLB_Interface.h\ Safetyfactor_01.h\ SHALSTAB_01.h\ TOBIA_01.h\ WEDGEFAIL_01.h\ WETNESS_01.h libta_slope_stability_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/MLB_Interface.h0000664000175000017500000000753312565125415030050 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Template_MLB_Interface_H #define HEADER_INCLUDED__Template_MLB_Interface_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef Template_EXPORTS #define Template_EXPORT _SAGA_DLL_EXPORT #else #define Template_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Template_MLB_Interface_H saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/ANGMAP_01.h0000664000175000017500000000747312565125415026724 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ANGMAP_01.h 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // ANGMAP_01.h // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CANGMAP : public CSG_Module_Grid { public: CANGMAP(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_slope_stability/TOBIA_01.h0000664000175000017500000000747012565125415026614 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: TOBIA_01.h 1935 2014-01-10 19:29:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_slope_stability // // // //-------------------------------------------------------// // // // TOBIA_01.h // // // // Copyright (C) 2012 by // // Andreas Günther // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: a.guenther@bgr.de // // // // contact: Andreas Günther // // B2.2 // // BGR // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTOBIA : public CSG_Module_Grid { public: CTOBIA(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/0000775000175000017500000000000012634325752024457 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Morphometry.cpp0000664000175000017500000007177212565125415027523 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Morphometry.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Morphometry.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Morphometry.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMorphometry::CMorphometry(void) { Set_Name (_TL("Slope, Aspect, Curvature")); Set_Author (SG_T("O.Conrad (c) 2001")); Set_Description (_TW( "Calculates the local morphometric terrain parameters slope, aspect and if supported " "by the chosen method also the curvature. Besides tangential curvature also its " "horizontal and vertical components (i.e. plan and profile curvature) can be calculated.\n" "\nReferences:\n\n" "Maximum Slope\n" "- Travis, M.R., Elsner, G.H., Iverson, W.D., Johnson, C.G. (1975):\n" " 'VIEWIT: computation of seen areas, slope, and aspect for land-use planning',\n" " USDA F.S. Gen. Tech. Rep. PSW-11/1975, 70p. Berkeley, California, U.S.A.\n\n" "Maximum Triangle Slope\n" "- Tarboton, D.G. (1997):\n" " 'A new method for the determination of flow directions and upslope areas in grid digital elevation models',\n" " Water Resources Research, Vol.33, No.2, p.309-319\n\n" "Least Squares or Best Fitted Plane\n" "- Horn, B. K. (1981):\n" " 'Hill shading and the relectance map',\n" " Proceedings of the IEEE, v. 69, no. 1, p. 14-47.\n\n" "- Beasley, D.B., Huggins, L.F. (1982):\n" " 'ANSWERS: User's manual',\n" " U.S. EPA-905/9-82-001, Chicago, IL. 54pp.\n\n" "- Costa-Cabral, M., Burges, S.J., (1994):\n" " 'Digital Elevation Model Networks (DEMON): a model of flow over hillslopes for computation of contributing and dispersal areas',\n" " Water Resources Research, v. 30, no. 6, p. 1681-1692.\n\n" "Fit 2.Degree Polynom\n" "- Evans, I.S. (1979):\n" " 'An integrated system of terrain analysis and slope mapping',\n" " Final report on grant DA-ERO-591-73-G0040. University of Durham, England.\n\n" "- Bauer, J., Rohdenburg, H., Bork, H.-R. (1985):\n" " 'Ein Digitales Reliefmodell als Vorraussetzung fuer ein deterministisches Modell der Wasser- und Stoff-Fluesse',\n" " Landschaftsgenese und Landschaftsoekologie, H.10, Parameteraufbereitung fuer deterministische Gebiets-Wassermodelle,\n" " Grundlagenarbeiten zu Analyse von Agrar-Oekosystemen, (Eds.: Bork, H.-R. / Rohdenburg, H.), p.1-15\n\n" "- Heerdegen, R.G., Beran, M.A. (1982):\n" " 'Quantifying source areas through land surface curvature',\n" " Journal of Hydrology, Vol.57\n\n" "- Olaya, V. (2006):\n" " 'Basic Land-Surface Parameters',\n" " in: Hengl, T., Reuter, H.I. [Eds.]: Geomorphometry: Concepts, Software, Applications. " " Developments in Soil Science, Elsevier, Vol.33, 141-169.\n\n" "- Zevenbergen, L.W., Thorne, C.R. (1987):\n" " 'Quantitative analysis of land surface topography',\n" " Earth Surface Processes and Landforms, 12: 47-56.\n\n" "Fit 3.Degree Polynom\n" "- R.M. Haralick (1983):\n" " 'Ridge and valley detection on digital images',\n" " Computer Vision, Graphics and Image Processing, Vol.22, No.1, p.28-38\n\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "SLOPE" , _TL("Slope"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "ASPECT" , _TL("Aspect"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "C_GENE" , _TL("General Curvature"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "C_PROF" , _TL("Profile Curvature"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "C_PLAN" , _TL("Plan Curvature"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "C_TANG" , _TL("Tangential Curvature"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "C_LONG" , _TL("Longitudinal Curvature"), _TL("Zevenbergen & Thorne (1987) refer to this as profile curvature"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "C_CROS" , _TL("Cross-Sectional Curvature"), _TL("Zevenbergen & Thorne (1987) refer to this as plan curvature"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "C_MINI" , _TL("Minimal Curvature"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "C_MAXI" , _TL("Maximal Curvature"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "C_TOTA" , _TL("Total Curvature"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "C_ROTO" , _TL("Flow Line Curvature"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); //----------------------------------------------------- Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("maximum slope (Travis et al. 1975)"), _TL("maximum triangle slope (Tarboton 1997)"), _TL("least squares fitted plane (Horn 1981, Costa-Cabral & Burgess 1996)"), _TL("6 parameter 2nd order polynom (Evans 1979)"), _TL("6 parameter 2nd order polynom (Heerdegen & Beran 1982)"), _TL("6 parameter 2nd order polynom (Bauer, Rohdenburg, Bork 1985)"), _TL("9 parameter 2nd order polynom (Zevenbergen & Thorne 1987)"), _TL("10 parameter 3rd order polynom (Haralick 1983)") ), 6 ); Parameters.Add_Choice( NULL , "UNIT_SLOPE" , _TL("Slope Units"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("radians"), _TL("degree"), _TL("percent") ), 0 ); Parameters.Add_Choice( NULL , "UNIT_ASPECT" , _TL("Aspect Units"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("radians"), _TL("degree") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CMorphometry::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("METHOD")) ) { bool bOn; bOn = pParameter->asInt() >= 3 || pParameter->asInt() == 0; pParameters->Get_Parameter("C_GENE")->Set_Enabled(bOn); pParameters->Get_Parameter("C_PROF")->Set_Enabled(bOn); pParameters->Get_Parameter("C_PLAN")->Set_Enabled(bOn); bOn = pParameter->asInt() >= 3; pParameters->Get_Parameter("C_TANG")->Set_Enabled(bOn); pParameters->Get_Parameter("C_LONG")->Set_Enabled(bOn); pParameters->Get_Parameter("C_CROS")->Set_Enabled(bOn); pParameters->Get_Parameter("C_MINI")->Set_Enabled(bOn); pParameters->Get_Parameter("C_MAXI")->Set_Enabled(bOn); pParameters->Get_Parameter("C_TOTA")->Set_Enabled(bOn); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMorphometry::On_Execute(void) { //----------------------------------------------------- int Method = Parameters("METHOD" )->asInt (); m_pDTM = Parameters("ELEVATION")->asGrid(); m_pSlope = Parameters("SLOPE" )->asGrid(); m_pAspect = Parameters("ASPECT" )->asGrid(); m_pC_Gene = Parameters("C_GENE" )->asGrid(); m_pC_Prof = Parameters("C_PROF" )->asGrid(); m_pC_Plan = Parameters("C_PLAN" )->asGrid(); m_pC_Tang = Parameters("C_TANG" )->asGrid(); m_pC_Long = Parameters("C_LONG" )->asGrid(); m_pC_Cros = Parameters("C_CROS" )->asGrid(); m_pC_Mini = Parameters("C_MINI" )->asGrid(); m_pC_Maxi = Parameters("C_MAXI" )->asGrid(); m_pC_Tota = Parameters("C_TOTA" )->asGrid(); m_pC_Roto = Parameters("C_ROTO" )->asGrid(); if( Method == 0 ) { m_pC_Tang = m_pC_Long = m_pC_Cros = m_pC_Mini = m_pC_Maxi = m_pC_Tota = m_pC_Roto = NULL; } else if( Method < 3 ) { m_pC_Gene = m_pC_Prof = m_pC_Plan = m_pC_Tang = m_pC_Long = m_pC_Cros = m_pC_Mini = m_pC_Maxi = m_pC_Tota = m_pC_Roto = NULL; } //----------------------------------------------------- DataObject_Set_Colors(m_pSlope , 11, SG_COLORS_YELLOW_RED , false); DataObject_Set_Colors(m_pAspect, 11, SG_COLORS_ASPECT_3 , false); DataObject_Set_Colors(m_pC_Gene, 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Prof, 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Plan, 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Tang, 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Long, 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Cros, 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Mini, 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Maxi, 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Tota, 11, SG_COLORS_YELLOW_RED , false); DataObject_Set_Colors(m_pC_Roto, 11, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- m_Unit_Slope = Parameters("UNIT_SLOPE" )->asInt(); if( m_Unit_Slope == 0 ) { m_pSlope->Set_Unit(_TL("Radians")); } else if( m_Unit_Slope == 1 ) { m_pSlope->Set_Unit(_TL("Degree")); } else // if( m_Unit_Slope == 2 ) { m_pSlope->Set_Unit(_TL("Percent")); } //----------------------------------------------------- m_Unit_Aspect = Parameters("UNIT_ASPECT")->asInt(); if( m_Unit_Aspect == 0 ) { m_pAspect->Set_Unit(_TL("Radians")); } else // if( m_Unit_Aspect == 1 ) { m_pAspect->Set_Unit(_TL("Degree")); } //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { Set_NoData(x, y); } else switch( Method ) { case 0: Set_MaximumSlope (x, y); break; case 1: Set_Tarboton (x, y); break; case 2: Set_LeastSquare (x, y); break; case 3: Set_Evans (x, y); break; case 4: Set_Heerdegen (x, y); break; case 5: Set_BRM (x, y); break; case 6: Set_Zevenbergen (x, y); break; case 7: Set_Haralick (x, y); break; } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // Indexing of the Submatrix: // // +-------+ +-------+ +-------+ // | 7 0 1 | | 2 5 8 | | 8 5 2 | // | 6 * 2 | => | 1 4 7 | or | 7 4 1 | // | 5 4 3 | | 0 3 6 | | 6 3 0 | // +-------+ +-------+ +-------+ // //--------------------------------------------------------- inline void CMorphometry::Get_SubMatrix3x3(int x, int y, double Z[9], int Orientation) { static const int Indexes[][8] = { { 5, 8, 7, 6, 3, 0, 1, 2 }, { 5, 2, 1, 0, 3, 6, 7, 8 } }; int *Index = (int *)Indexes[Orientation]; double z = m_pDTM->asDouble(x, y); Z[4] = 0.0; for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy) ) { Z[Index[i]] = m_pDTM->asDouble(ix, iy) - z; } else { ix = Get_xTo(i + 4, x); iy = Get_yTo(i + 4, y); if( m_pDTM->is_InGrid(ix, iy) ) { Z[Index[i]] = z - m_pDTM->asDouble(ix, iy); } else { Z[Index[i]] = 0.0; } } } } //--------------------------------------------------------- inline void CMorphometry::Get_SubMatrix5x5(int x, int y, double Z[25]) { double z = m_pDTM->asDouble(x,y); for(int i=0, iy=y-2; iy<=y+2; iy++) { int jy = iy < 0 ? 0 : (iy >= Get_NY() ? Get_NY() - 1 : iy); for(int ix=x-2; ix<=x+2; ix++, i++) { int jx = ix < 0 ? 0 : (ix >= Get_NX() ? Get_NX() - 1 : ix); Z[i] = m_pDTM->is_InGrid(jx, jy) ? m_pDTM->asDouble(jx, jy) - z : 0.0; } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SET_NODATA(grid) if( grid ) grid->Set_NoData(x, y); #define SET_VALUE(grid, value) if( grid ) grid->Set_Value(x, y, value); //--------------------------------------------------------- inline void CMorphometry::Set_NoData(int x, int y) { SET_NODATA(m_pSlope ) SET_NODATA(m_pAspect) SET_NODATA(m_pC_Gene) SET_NODATA(m_pC_Prof) SET_NODATA(m_pC_Plan) SET_NODATA(m_pC_Tang) SET_NODATA(m_pC_Long) SET_NODATA(m_pC_Cros) SET_NODATA(m_pC_Mini) SET_NODATA(m_pC_Maxi) SET_NODATA(m_pC_Tota) SET_NODATA(m_pC_Roto) } //--------------------------------------------------------- inline void CMorphometry::Set_Gradient(int x, int y, double Slope, double Aspect) { //----------------------------------------------------- if( m_Unit_Slope == 1 ) { SET_VALUE(m_pSlope, Slope * M_RAD_TO_DEG); } else if( m_Unit_Slope == 2 ) { SET_VALUE(m_pSlope, 100.0 * tan(Slope)); } else { SET_VALUE(m_pSlope, Slope); } //----------------------------------------------------- if( m_Unit_Aspect == 1 && Aspect >= 0.0 ) { SET_VALUE(m_pAspect, Aspect * M_RAD_TO_DEG); } else { SET_VALUE(m_pAspect, Aspect); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CMorphometry::Set_From_Polynom(int x, int y, double r, double t, double s, double p, double q) { //----------------------------------------------------- double p2_q2 = p*p + q*q; Set_Gradient(x, y, atan(sqrt(p2_q2)), p != 0.0 ? M_PI_180 + atan2(q, p) : q > 0.0 ? M_PI_270 : q < 0.0 ? M_PI_090 : m_pAspect ? m_pAspect->Get_NoData_Value() : -1 ); //----------------------------------------------------- if( p2_q2 ) { double spq = s * p * q, p2 = p*p, q2 = q*q; r *= 2; t *= 2; SET_VALUE(m_pC_Gene, -2 * (r + t)); SET_VALUE(m_pC_Prof, -(r * p2 + t * q2 + 2 * spq) / (p2_q2 * pow(1 + p2_q2, 1.5))); SET_VALUE(m_pC_Plan, -(t * p2 + r * q2 - 2 * spq) / ( pow( p2_q2, 1.5))); SET_VALUE(m_pC_Tang, -(t * p2 + r * q2 - 2 * spq) / (p2_q2 * pow(1 + p2_q2, 0.5))); SET_VALUE(m_pC_Long, -2 * (r * p2 + t * q2 + spq) / (p2_q2 )); SET_VALUE(m_pC_Cros, -2 * (t * p2 + r * q2 - spq) / (p2_q2 )); SET_VALUE(m_pC_Mini, -r/2 - t/2 - sqrt(0.5 * (r - t)*(r - t) + s*s)); SET_VALUE(m_pC_Maxi, -r/2 - t/2 + sqrt(0.5 * (r - t)*(r - t) + s*s)); SET_VALUE(m_pC_Tota, r*r + 2 * s*s + t*t); SET_VALUE(m_pC_Roto, (p2 - q2) * s - p * q * (r - t)); // rotor // SET_VALUE(m_pC_Gaus, (r * t - 2 * s*s) / (1 + p2_q2)); // total gaussian } } /////////////////////////////////////////////////////////// // // // The Methods // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // Maximum Slope (Travis et al., 1975, Peucker & Douglas, 1975)) // // Travis, M.R., Elsner, G.H., Iverson, W.D., and Johnson, C.G. 1975: // VIEWIT: computation of seen areas, slope, and aspect for land-use planning. // USDA F.S. Gen. Tech. Rep. PSW-11/1975, 70p. Berkeley, California, U.S.A. // //--------------------------------------------------------- void CMorphometry::Set_MaximumSlope(int x, int y) { int i, ix, iy, j, Aspect; double z, Z[8], Slope, Curv, hCurv, a, b; //----------------------------------------------------- z = m_pDTM->asDouble(x, y); Slope = Curv = 0.0; Aspect = -1; for(i=0; i<8; i++) { if( !m_pDTM->is_InGrid(ix = Get_xTo(i, x), iy = Get_yTo(i, y)) ) { Z[i] = 0.0; } else { Z[i] = atan((z - m_pDTM->asDouble(ix, iy)) / Get_Length(i)); Curv += Z[i]; if( Z[i] > Slope ) { Aspect = i; Slope = Z[i]; } } } Set_Gradient(x, y, Slope, Aspect * M_PI_045); //------------------------------------------------- if( Aspect < 0.0 ) { SET_NODATA(m_pAspect); SET_NODATA(m_pC_Gene); SET_NODATA(m_pC_Prof); SET_NODATA(m_pC_Plan); } else { //--------------------------------------------- // Let's now estimate the plan curvature... for(i=Aspect+1, j=0, a=0.0; iAspect; i--, j++) { if( Z[i % 8] < 0.0 ) { b = j + Z[(i + 1) % 8] / (Z[(i + 1) % 8] - Z[i % 8]); break; } } hCurv = 45.0 * (a + b) - 180.0; } else { hCurv = 180.0; } //--------------------------------------------- SET_VALUE(m_pC_Gene, Curv); SET_VALUE(m_pC_Prof, Z[Aspect] + Z[(Aspect + 4) % 8]); SET_VALUE(m_pC_Plan, hCurv); } } //--------------------------------------------------------- // Maximum Triangle Slope // // Tarboton, D.G. (1997): // 'A new method for the determination of flow directions and upslope areas in grid digital elevation models', // Water Resources Research, Vol.33, No.2, p.309-319 // //--------------------------------------------------------- void CMorphometry::Set_Tarboton(int x, int y) { int i, ix, iy, j; double z, Z[8], iSlope, iAspect, Slope, Aspect, G, H; //----------------------------------------------------- z = m_pDTM->asDouble(x, y); for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy) ) { Z[i] = m_pDTM->asDouble(ix, iy); } else { ix = Get_xTo(i + 4, x); iy = Get_yTo(i + 4, y); if( m_pDTM->is_InGrid(ix, iy) ) { Z[i] = z - (m_pDTM->asDouble(ix, iy) - z); } else { Z[i] = z; } } } //--------------------------------------------- Slope = 0.0; Aspect = -1.0; for(i=0, j=1; i<8; i++, j=(j+1)%8) { if( i % 2 ) // i => diagonal { G = (z - Z[j]) / Get_Cellsize(); H = (Z[j] - Z[i]) / Get_Cellsize(); } else // i => orthogonal { G = (z - Z[i]) / Get_Cellsize(); H = (Z[i] - Z[j]) / Get_Cellsize(); } if( H < 0.0 ) { iAspect = 0.0; iSlope = G; } else if( H > G ) { iAspect = M_PI_045; iSlope = (z - Z[i % 2 ? i : j]) / (sqrt(2.0) * Get_Cellsize()); } else { iAspect = atan(H / G); iSlope = sqrt(G*G + H*H); } if( iSlope > Slope ) { Aspect = i * M_PI_045 + (i % 2 ? M_PI_045 - iAspect : iAspect); Slope = iSlope; } } //--------------------------------------------- if( Aspect < 0.0 ) { Set_NoData(x, y); } else { Set_Gradient(x, y, atan(Slope), Aspect); } } //--------------------------------------------------------- // Least Squares or Best Fit Plane (Horn 1981, Beasley & Huggins 1982, Costa-Cabral & Burgess 1994) // // Horn, B. K. (1981): // Hill shading and the relectance map. // Proceedings of the IEEE, v. 69, no. 1, p 14-47. // // Beasley, D.B. and Huggins, L.F. 1982: // ANSWERS: User’s manual. // U.S. EPA-905/9-82-001, Chicago, IL. 54pp. // // Costa-Cabral, M., and Burges, S.J., 1994: // Digital Elevation Model Networks (DEMON): a model of flow over hillslopes for computation of contributing and dispersal areas // Water Resources Research, v. 30, no. 6, p. 1681-1692. // //--------------------------------------------------------- void CMorphometry::Set_LeastSquare(int x, int y) { double Z[9], a, b; Get_SubMatrix3x3(x, y, Z); a = ((Z[2] + 2 * Z[5] + Z[8]) - (Z[0] + 2 * Z[3] + Z[6])) / (8 * Get_Cellsize()); b = ((Z[6] + 2 * Z[7] + Z[8]) - (Z[0] + 2 * Z[1] + Z[2])) / (8 * Get_Cellsize()); Set_Gradient(x, y, atan(sqrt(a*a + b*b)), a != 0.0 ? M_PI_180 + atan2(b, a) : b > 0.0 ? M_PI_270 : b < 0.0 ? M_PI_090 : m_pAspect ? m_pAspect->Get_NoData_Value() : -1 ); } //--------------------------------------------------------- // Quadratic Function Approximation (Heerdegen & Beran, 1984) // // Evans, I.S. (1979): // An integrated system of terrain analysis and slope mapping. // Final report on grant DA-ERO-591-73-G0040. University of Durham, England. // //--------------------------------------------------------- // f(z) = Ax^2 + By^2 + Cxy + Dx + Ey + F // //--------------------------------------------------------- void CMorphometry::Set_Evans(int x, int y) { double Z[9], A, B, C, D, E; Get_SubMatrix3x3(x, y, Z, 1); A = (Z[0] + Z[2] + Z[3] + Z[5] + Z[6] + Z[8] - 2 * (Z[1] + Z[4] + Z[7])) / (6 * Get_Cellarea()); B = (Z[0] + Z[1] + Z[2] + Z[6] + Z[7] + Z[8] - 2 * (Z[3] + Z[4] + Z[5])) / (6 * Get_Cellarea()); C = (Z[2] + Z[6] - Z[0] - Z[8]) / (4 * Get_Cellarea()); D = (Z[2] + Z[5] + Z[8] - Z[0] - Z[3] - Z[6]) / (6 * Get_Cellsize()); E = (Z[0] + Z[1] + Z[2] - Z[6] - Z[7] - Z[8]) / (6 * Get_Cellsize()); Set_From_Polynom(x, y, A, B, C, D, E); } //--------------------------------------------------------- // Quadratic Function Approximation (Heerdegen & Beran, 1984) // // Heerdegen, R.G. / Beran, M.A. (1982): // Quantifying source areas through land surface curvature. // Journal of Hydrology, Vol.57 // //--------------------------------------------------------- // f(z) = Ax^2 + By^2 + Cxy + Dx + Ey + F // //--------------------------------------------------------- void CMorphometry::Set_Heerdegen(int x, int y) { double Z[9], A, B, C, D, E, a, b; Get_SubMatrix3x3(x, y, Z); a = Z[0] + Z[2] + Z[3] + Z[5] + Z[6] + Z[8]; b = Z[0] + Z[1] + Z[2] + Z[6] + Z[7] + Z[8]; A = (0.3 * a - 0.2 * b) / ( Get_Cellarea()); B = (0.3 * b - 0.2 * a) / ( Get_Cellarea()); C = ( Z[0] - Z[2] - Z[6] + Z[8]) / (4 * Get_Cellarea()); D = (-Z[0] + Z[2] - Z[3] + Z[5] - Z[6] + Z[8]) / (6 * Get_Cellsize()); E = (-Z[0] - Z[1] - Z[2] + Z[6] + Z[7] + Z[8]) / (6 * Get_Cellsize()); Set_From_Polynom(x, y, A, B, C, D, E); } //--------------------------------------------------------- // Quadratic Function Approximation (Bauer, Rohdenburg & Bork, 1985) // // Bauer, J. / Rohdenburg, H. / Bork, H.-R., (1985): // 'Ein Digitales Reliefmodell als Vorraussetzung fuer ein deterministisches Modell der Wasser- und Stoff-Fluesse', // Landschaftsgenese und Landschaftsoekologie, H.10, Parameteraufbereitung fuer deterministische Gebiets-Wassermodelle, // Grundlagenarbeiten zu Analyse von Agrar-Oekosystemen, (Eds.: Bork, H.-R. / Rohdenburg, H.), p.1-15 // //--------------------------------------------------------- // f(z) = Ax^2 + By^2 + Cxy + Dx + Ey + F // //--------------------------------------------------------- void CMorphometry::Set_BRM(int x, int y) { double Z[9], A, B, C, D, E; Get_SubMatrix3x3(x, y, Z); A = ( (Z[0] + Z[2] + Z[3] + Z[5] + Z[6] + Z[8]) - 2 * (Z[1] + Z[4] + Z[7]) ) / ( Get_Cellarea()); B = ( (Z[0] + Z[6] + Z[1] + Z[7] + Z[2] + Z[8]) - 2 * (Z[3] + Z[4] + Z[5]) ) / ( Get_Cellarea()); C = ( Z[8] + Z[0] - Z[7] ) / (4 * Get_Cellarea()); D = ( (Z[2] - Z[0]) + (Z[5] - Z[3]) + (Z[8]-Z[6]) ) / (6 * Get_Cellsize()); E = ( (Z[6] - Z[0]) + (Z[7] - Z[1]) + (Z[8]-Z[2]) ) / (6 * Get_Cellsize()); Set_From_Polynom(x, y, A, B, C, D, E); } //--------------------------------------------------------- // Quadratic Function Approximation (Zevenbergen und Thorne, 1986) // // Zevenbergen, L.W. and C.R. Thorne. 1987: // Quantitative analysis of land surface topography // Earth Surface Processes and Landforms, 12: 47-56. // //--------------------------------------------------------- // f(z) = Ax^2y^2 + Bx^2y + Cxy^2 + Dx^2 + Ey^2 + Fxy + Gx + Hy + I // //--------------------------------------------------------- void CMorphometry::Set_Zevenbergen(int x, int y) { double Z[9], D, E, F, G, H; Get_SubMatrix3x3(x, y, Z); D = ((Z[3] + Z[5]) / 2.0 - Z[4]) / ( Get_Cellarea()); E = ((Z[1] + Z[7]) / 2.0 - Z[4]) / ( Get_Cellarea()); F = (Z[0] - Z[2] - Z[6] + Z[8]) / (4 * Get_Cellarea()); G = (Z[5] - Z[3]) / (2 * Get_Cellsize()); H = (Z[7] - Z[1]) / (2 * Get_Cellsize()); Set_From_Polynom(x, y, D, E, F, G, H); } //--------------------------------------------------------- // Cubic Function Approximation (Haralick, 1991) // // R.M. Haralick (1983): // 'Ridge and Valley Detection on digital images', // Computer Vision, Graphics and Image Processing, Vol.22, No.1, p.28-38 // //--------------------------------------------------------- // f(z) = Ax^3 + By^3 + Cx^2y + Dxy^2 + Ex^2 + Fy^2 + Gxy + Hx + Iy + J // //--------------------------------------------------------- void CMorphometry::Set_Haralick(int x, int y) { //----------------------------------------------------- // Matrices for Finite Difference solution... const int Mtrx[][5][5] = { { { 31,- 5,-17,- 5, 31}, {-44,-62,-68,-62,-44}, { 0, 0, 0, 0, 0}, { 44, 62, 68, 62, 44}, {-31, 5, 17, 5,-31} }, { { 31,-44, 0, 44,-31}, {- 5,-62, 0, 62, 5}, {-17,-68, 0, 68, 17}, {- 5,-62, 0, 62, 5}, { 31,-44, 0, 44,-31} }, { { 2, 2, 2, 2, 2}, {- 1,- 1,- 1,- 1,- 1}, {- 2,- 2,- 2,- 2,- 2}, {- 1,- 1,- 1,- 1,- 1}, { 2, 2, 2, 2, 2} }, { { 4, 2, 0,- 2,- 4}, { 2, 1, 0,- 1,- 2}, { 0, 0, 0, 0, 0}, {- 2,- 1, 0, 1, 2}, {- 4,- 2, 0, 2, 4} }, { { 2,- 1,- 2,- 1, 2}, { 2,- 1,- 2,- 1, 2}, { 2,- 1,- 2,- 1, 2}, { 2,- 1,- 2,- 1, 2}, { 2,- 1,- 2,- 1, 2} }, }; const int QMtrx[] = { 4200, 4200, 700, 1000, 700 }; //----------------------------------------------------- int i, ix, iy, n; double Sum, Z[25], k[5]; Get_SubMatrix5x5(x, y, Z); for(i=0; i<5; i++) { for(n=0, Sum=0.0, iy=0; iy<5; iy++) { for(ix=0; ix<5; ix++, n++) { Sum += Z[n] * Mtrx[i][ix][iy]; } } k[i] = Sum / QMtrx[i]; } Set_From_Polynom(x, y, k[4], k[2], k[3], k[1], k[0]); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Convergence_Radius.h0000664000175000017500000001105512565125415030374 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Convergence_Radius.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Convergence_Radius.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Convergence_Radius_H #define HEADER_INCLUDED__Convergence_Radius_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CConvergence_Radius : public CSG_Module_Grid { public: CConvergence_Radius(void); protected: virtual bool On_Execute (void); private: bool m_bSlope, m_bDifference; CSG_Vector m_Direction; CSG_Grid_Cell_Addressor m_Cells; CSG_Grid *m_pDTM, m_Slope, m_Aspect; bool Get_Convergence (int x, int y, double &Convergence); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Convergence_Radius_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/top_hat.h0000664000175000017500000001245412565125415026271 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: top_hat.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // top_hat.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__top_hat_H #define HEADER_INCLUDED__top_hat_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTop_Hat : public CSG_Module_Grid { public: CTop_Hat(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Terrain Classification" )); } protected: virtual bool On_Execute (void); private: bool Get_Focal_Statistics (int x, int y, const CSG_Grid &g, const CSG_Grid_Cell_Addressor &r, CSG_Simple_Statistics &s); bool Get_Focal_Minimum (int x, int y, const CSG_Grid &g, const CSG_Grid_Cell_Addressor &r, double &Minimum); bool Get_Focal_Maximum (int x, int y, const CSG_Grid &g, const CSG_Grid_Cell_Addressor &r, double &Maximum); bool Get_Focal_Extremes (int x, int y, const CSG_Grid &g, const CSG_Grid_Cell_Addressor &r, double &Minimum, double &Maximum); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__top_hat_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/ProtectionIndex.cpp0000664000175000017500000000720712565125415030304 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ProtectionIndex.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* ProtectionIndex.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "ProtectionIndex.h" #define NO_DATA -1 CProtectionIndex::CProtectionIndex(void){ Set_Name(_TL("Morphometric Protection Index")); Set_Author(SG_T("(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", _TL("Elevation"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "PROTECTION", _TL("Protection Index"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Float); Parameters.Add_Value(NULL, "RADIUS", _TL("Radius"), _TL("The radius in map units"), PARAMETER_TYPE_Double, 2000, 0.0, true); }//constructor CProtectionIndex::~CProtectionIndex(void) {} bool CProtectionIndex::On_Execute(void){ int x,y; double dProtectionIndex; CSG_Grid* pProtectionIndex = Parameters("PROTECTION")->asGrid(); m_dRadius = Parameters("RADIUS")->asDouble(); m_pDEM = Parameters("DEM")->asGrid(); for(y=0; ySet_NoData(x,y); }//if else{ pProtectionIndex->Set_Value(x,y, dProtectionIndex); }//else }//for }//for return true; }//method double CProtectionIndex::getProtectionIndex(int x, int y){ int i,j; int iDifX[] = {0,1,1,1,0,-1,-1,-1}; int iDifY[] = {1,1,0,-1,-1,-1,0,1}; double dDifHeight; double dDist; double dAngle; double dProtectionIndex = 0; double aAngle[8]; for (i = 0; i < 8; i++){ j = 1; aAngle[i] = 0; dDist = M_GET_LENGTH(iDifX[i], iDifY[i]) * j * m_pDEM->Get_Cellsize(); while (dDist < m_dRadius){ if (m_pDEM->is_InGrid(x + iDifX[i] * j, y + iDifY[i] * j)){ dDifHeight = m_pDEM->asDouble(x,y); }//if else{ return NO_DATA; } dDifHeight = m_pDEM->asDouble(x + iDifX[i] * j, y + iDifY[i] * j) - m_pDEM->asDouble(x,y); dAngle = atan (dDifHeight / dDist); if (dAngle > aAngle[i]){ aAngle[i] = dAngle; }//if j++; dDist = M_GET_LENGTH(iDifX[i], iDifY[i]) * j * m_pDEM->Get_Cellsize(); }//while dProtectionIndex+=aAngle[i]; }//while return (dProtectionIndex / 8.); }//method saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/anisotropic_heating.h0000664000175000017500000001041412565125415030656 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: anisotropic_heating.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Anisotropic_Heating.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: conrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Anisotropic_Heating_H #define HEADER_INCLUDED__Anisotropic_Heating_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CAnisotropic_Heating : public CSG_Module_Grid { public: CAnisotropic_Heating(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Climate and Weather" )); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Anisotropic_Heating_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/anisotropic_heating.cpp0000664000175000017500000001263412565125415031217 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: anisotropic_heating.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Anisotropic_Heating.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: conrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "anisotropic_heating.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CAnisotropic_Heating::CAnisotropic_Heating(void) { //----------------------------------------------------- Set_Name (_TL("Diurnal Anisotropic Heating")); Set_Author (SG_T("J.Boehner, O.Conrad (c) 2008")); Set_Description(_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "DAH" , _TL("Diurnal Anisotropic Heating"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "ALPHA_MAX" , _TL("Alpha Max (Degree)"), _TL(""), PARAMETER_TYPE_Double , 202.5, 0.0, true, 360.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CAnisotropic_Heating::On_Execute(void) { double alpha_max, alpha, slope; CSG_Grid *pDEM, *pDAH; //----------------------------------------------------- pDEM = Parameters("DEM") ->asGrid(); pDAH = Parameters("DAH") ->asGrid(); alpha_max = Parameters("ALPHA_MAX") ->asDouble() * M_DEG_TO_RAD; //----------------------------------------------------- for(int y=0; yis_NoData(x, y) || !pDEM->Get_Gradient(x, y, slope, alpha) ) { pDAH->Set_NoData(x, y); } else { pDAH->Set_Value(x, y, cos(alpha_max - alpha) * atan(slope)); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Curvature_UpDownSlope.h0000664000175000017500000001133512565125415031107 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Curvature_UpDownSlope.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Curvature_UpDownSlope.h // // // // Copyright (C) 2015 by // // Paolo Gandelli // // // //-------------------------------------------------------// // // // 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: gandelli.paolo@gmail.com // // // // contact: Paolo Gandelli // // Engineering Geology and Geomorphology // // Department of Earth Sciences // // University of Firenze // // Italy // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Curvature_UpDownSlope_H #define HEADER_INCLUDED__Curvature_UpDownSlope_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCurvature_UpDownSlope : public CSG_Module_Grid { public: CCurvature_UpDownSlope(void); protected: virtual bool On_Execute(void); private: double m_Weighting; CSG_Grid *m_pDEM, *m_pC_Local, *m_pC_Up, *m_pC_Up_Local, *m_pC_Down, *m_pC_Down_Local, m_Weights; double Get_Local (int x, int y); bool Get_Upslope (int x, int y); bool Get_Downslope (int x, int y); bool Get_Flow_Proportions (int x, int y, double Proportion[8]); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Curvature_UpDownSlope_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/distance_gradient.h0000664000175000017500000001034112565125415030273 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: distance_gradient.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Distance_Gradient.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Distance_Gradient_H #define HEADER_INCLUDED__Distance_Gradient_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDistance_Gradient : public CSG_Module_Grid { public: CDistance_Gradient(void); virtual ~CDistance_Gradient(void); protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, m_Dir; double Get_hDistance (int x, int y, double vDistance); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Distance_Gradient_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/tpi.h0000664000175000017500000001211312565125415025417 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: tpi.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // tpi.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__tpi_H #define HEADER_INCLUDED__tpi_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTPI : public CSG_Module_Grid { public: CTPI(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Grid_Cell_Addressor m_Cells; CSG_Grid *m_pDEM, *m_pTPI; bool Get_Statistics (int x, int y); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTPI_Classification : public CSG_Module_Grid { public: CTPI_Classification(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Terrain Classification" )); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Distance_Weighting m_Weighting; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__tpi_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/ProtectionIndex.h0000664000175000017500000000260212565125415027743 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ProtectionIndex.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* ProtectionIndex.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "MLB_Interface.h" class CProtectionIndex : public CSG_Module_Grid { public: CProtectionIndex(void); virtual ~CProtectionIndex(void); protected: bool On_Execute(void); private: double getProtectionIndex(int x, int y); CSG_Grid *m_pDEM; double m_dRadius; };saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/SurfaceSpecificPoints.cpp0000664000175000017500000002773112565125415031425 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SurfaceSpecificPoints.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // SurfaceSpecificPoints.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SurfaceSpecificPoints.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSurfaceSpecificPoints::CSurfaceSpecificPoints(void) { CSG_Parameter *pNode; Set_Name (_TL("Surface Specific Points")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (_TW( "References:\n" "Peucker, T.K. and Douglas, D.H., 1975:\n" "'Detection of surface-specific points by local parallel processing of discrete terrain elevation data',\n" "Computer Graphics and Image Processing, 4, 375-387\n" )); Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT ); pNode = Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL("Algorithm for the detection of Surface Specific Points"), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("Mark Highest Neighbour"), _TL("Opposite Neighbours"), _TL("Flow Direction"), _TL("Flow Direction (up and down)"), _TL("Peucker & Douglas") ), 1 ); Parameters.Add_Value( pNode , "THRESHOLD" , _TL("Threshold"), _TL("Threshold for Peucker & Douglas Algorithm"), PARAMETER_TYPE_Double , 2 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSurfaceSpecificPoints::On_Execute(void) { CSG_Grid *pGrid, *pResult; pGrid = Parameters("ELEVATION") ->asGrid(); pResult = Parameters("RESULT") ->asGrid(); switch( Parameters("METHOD")->asInt() ) { case 0: Do_MarkHighestNB (pGrid, pResult); break; case 1: Do_OppositeNB (pGrid, pResult); break; case 2: Do_FlowDirection (pGrid, pResult); break; case 3: Do_FlowDirection2 (pGrid, pResult); break; case 4: Do_PeuckerDouglas (pGrid, pResult, Parameters("THRESHOLD")->asDouble()); break; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSurfaceSpecificPoints::Do_MarkHighestNB(CSG_Grid *pGrid, CSG_Grid *pResult) // Band & Lammers... { int i, x, y, ix, iy, xlo, ylo, xhi, yhi; double lo, hi, z; CSG_Grid *clo, *chi; clo = SG_Create_Grid(pGrid, SG_DATATYPE_Char); chi = SG_Create_Grid(pGrid, SG_DATATYPE_Char); // Pass 1: Auszaehlen... for(y=0; yasDouble(x,y); xhi = xlo = x; yhi = ylo = y; for(i=0; i<4; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( is_InGrid(ix,iy) ) { z = pGrid->asDouble(ix,iy); if( z > hi ) { hi = z; xhi = ix; yhi = iy; } else if( z < lo ) { lo = z; xlo = ix; ylo = iy; } } } clo->Add_Value(xlo,ylo,1); chi->Add_Value(xhi,yhi,1); } } // Pass 2: Setzen... for(y=0; yasChar(x,y) ) { if( !clo->asChar(x,y) ) pResult->Set_Value(x,y, 2); // Sattel else pResult->Set_Value(x,y, 1); // Tiefenlinie } else if( !clo->asChar(x,y) ) pResult->Set_Value(x,y, -1); // Wasserscheide else pResult->Set_Value(x,y, 0); // Nichts... } } delete(clo); delete(chi); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSurfaceSpecificPoints::Do_OppositeNB(CSG_Grid *pGrid, CSG_Grid *pResult) { int i, x, y, ix, iy, jx, jy; double z, iz, jz; CSG_Grid *clo, *chi; clo = SG_Create_Grid(pGrid, SG_DATATYPE_Char); chi = SG_Create_Grid(pGrid, SG_DATATYPE_Char); // Pass 1: Auszaehlen... for(y=0; yasDouble(x,y); for(i=0; i<4; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( is_InGrid(ix,iy) ) { jx = Get_xFrom(i,x); jy = Get_yFrom(i,y); if( is_InGrid(jx,jy) ) { iz = pGrid->asDouble(ix,iy); jz = pGrid->asDouble(jx,jy); if( iz>z && jz>z ) chi->Add_Value(x,y,1); else if( izAdd_Value(x,y,1); } } } } } // Pass 2: Setzen... for(y=0; yasChar(x,y) ) { if( clo->asChar(x,y) ) pResult->Set_Value(x,y, 5); // Sattel else pResult->Set_Value(x,y, chi->asChar(x,y) ); // Tiefenlinie } else if( clo->asChar(x,y) ) pResult->Set_Value(x,y, - clo->asChar(x,y) ); // Wasserscheide else pResult->Set_Value(x,y, 0); // Nichts... } } delete(clo); delete(chi); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSurfaceSpecificPoints::Do_FlowDirection(CSG_Grid *pGrid, CSG_Grid *pResult) { bool bLower; int x, y, i, ix, iy, xLow, yLow; double z, iz, zLow; pResult->Assign(); for(y=0; yasDouble(x,y); bLower = false; for(i=0; i<8; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( is_InGrid(ix,iy) ) { iz = pGrid->asDouble(ix,iy); if(izAdd_Value(xLow, yLow, 1); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSurfaceSpecificPoints::Do_FlowDirection2(CSG_Grid *pGrid, CSG_Grid *pResult) { CSG_Grid Grid(*pGrid), Result(*pResult); Do_FlowDirection(&Grid, &Result); Grid.Invert(); Do_FlowDirection(&Grid, pResult); for(sLong n=0; nAdd_Value(n, -Result.asInt(n)); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSurfaceSpecificPoints::Do_PeuckerDouglas(CSG_Grid *pGrid, CSG_Grid *pResult, double Threshold) { bool wasPlus; int x, y, i, ix, iy, nSgn; double d, dPlus, dMinus, z, alt[8]; for(y=0; yasDouble(x,y); for(i=0; i<8; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( is_InGrid(ix,iy) ) alt[i] = pGrid->asDouble(ix,iy); else alt[i] = z; } dPlus = dMinus = 0; nSgn = 0; wasPlus = (alt[7] - z > 0) ? true : false; for(i=0; i<8; i++) { d = alt[i] - z; if(d>0) { dPlus += d; if(!wasPlus) { nSgn++; wasPlus = true; } } else if(d<0) { dMinus -= d; if(wasPlus) { nSgn++; wasPlus = false; } } } i = 0; if(!dPlus) // Peak... i = 9; else if(!dMinus) // Pit i = -9; else if(nSgn==4) // Pass i = 1; else if(nSgn==2) { i = nSgn = 0; if(alt[7]>z) { while(alt[i++]>z); do nSgn++; while(alt[i++]z); } i = 0; if(nSgn==4) { if(dMinus-dPlus > Threshold) // convex break... i = 2; else if(dPlus-dMinus > Threshold) // concave break... i = -2; } else // lines: { if(dMinus-dPlus>0) // Ridge i = 7; else // Channel i = -7; } } pResult->Set_Value(x,y,i); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Hypsometry.h0000664000175000017500000001117412565125415027014 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hypsometry.h 2103 2014-04-21 12:21:50Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Hypsometry.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Hypsometry_H #define HEADER_INCLUDED__Hypsometry_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_morphometry_EXPORT CHypsometry : public CSG_Module_Grid { public: CHypsometry(void); virtual ~CHypsometry(void); protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool Calculate_A (CSG_Grid *pDGM, CSG_Table *pTable, bool bDown, int nClasses); bool Calculate_B (CSG_Grid *pDEM, CSG_Table *pTable, bool bDown, int nClasses, double zMin, double zMax); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Hypsometry_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/air_flow_height.cpp0000664000175000017500000003571212565125415030322 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: air_flow_height.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Air_Flow_Height.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: conrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "air_flow_height.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CAir_Flow_Height::CAir_Flow_Height(void) { CSG_Parameter *pNode; Set_Name (_TL("Effective Air Flow Heights")); Set_Author (SG_T("J.Boehner, O.Conrad (c) 2008")); Set_Description (_TW( "\nReferences:\n" "- Boehner, J., Antonic, O. (2009): 'Land-surface parameters specific to topo-climatology'." " in: Hengl, T., Reuter, H. (Eds.): 'Geomorphometry - Concepts, Software, Applications'." " Developments in Soil Science, Volume 33, p.195-226, Elsevier.\n" )); Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); pNode = Parameters.Add_Grid( NULL , "DIR" , _TL("Wind Direction"), _TL("Direction into which the wind blows, starting with 0 for North and increasing clockwise."), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Choice( pNode , "DIR_UNITS" , _TL("Wind Direction Units"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("radians"), _TL("degree") ), 0 ); pNode = Parameters.Add_Grid( NULL , "LEN" , _TL("Wind Speed"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "LEN_SCALE" , _TL("Scaling"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Grid( NULL , "AFH" , _TL("Effective Air Flow Heights"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "MAXDIST" , _TL("Search Distance [km]"), _TL(""), PARAMETER_TYPE_Double, 300.0, 0.0, true ); pNode = Parameters.Add_Value( NULL , "DIR_CONST" , _TL("Constant Wind Direction"), _TL("constant direction into the wind blows, given as degree"), PARAMETER_TYPE_Double, 135.0 ); Parameters.Add_Value( pNode , "OLDVER" , _TL("Old Version"), _TL("use old version for constant wind direction (no acceleration and averaging option)"), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "ACCEL" , _TL("Acceleration"), _TL(""), PARAMETER_TYPE_Double, 1.5, 1.0, true ); Parameters.Add_Value( NULL , "PYRAMIDS" , _TL("Elevation Averaging"), _TL("use more averaged elevations when looking at increasing distances"), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "LEE" , _TL("Windward Factor"), _TL(""), PARAMETER_TYPE_Double , 0.5 ); Parameters.Add_Value( NULL , "LUV" , _TL("Luv Factor"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); /* Parameters.Add_Value( NULL , "TRACE" , _TL("Precise Tracing"), _TL(""), PARAMETER_TYPE_Bool, false );/**/ } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CAir_Flow_Height::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "DIR") ) { pParameters->Set_Enabled("DIR_CONST", pParameter->asGrid() == NULL); pParameters->Set_Enabled("DIR_UNITS", pParameter->asGrid() != NULL); pParameters->Set_Enabled("LEN" , pParameter->asGrid() != NULL); pParameters->Set_Enabled("OLDVER" , pParameter->asGrid() == NULL); pParameters->Set_Enabled("PYRAMIDS" , pParameters->Get_Parameter("OLDVER")->asBool() == false); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "LEN") ) { pParameters->Set_Enabled("LEN_SCALE", pParameter->asGrid() != NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "OLDVER") ) { pParameters->Set_Enabled("ACCEL" , pParameter->asBool() == false); pParameters->Set_Enabled("PYRAMIDS" , pParameter->asBool() == false); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CAir_Flow_Height::On_Execute(void) { CSG_Grid *pAFH; //----------------------------------------------------- m_pDEM = Parameters("DEM" )->asGrid(); pAFH = Parameters("AFH" )->asGrid(); m_maxDistance = Parameters("MAXDIST")->asDouble() * 1000.0; m_Acceleration = Parameters("ACCEL" )->asDouble(); m_dLee = Parameters("LEE" )->asDouble(); m_dLuv = Parameters("LUV" )->asDouble(); // m_bTrace = Parameters("TRACE" )->asBool(); //----------------------------------------------------- CSG_Colors Colors(5); Colors.Set_Color(0, 255, 127, 63); Colors.Set_Color(1, 255, 255, 127); Colors.Set_Color(2, 255, 255, 255); Colors.Set_Color(3, 127, 127, 175); Colors.Set_Color(4, 0, 0, 100); DataObject_Set_Colors(pAFH, Colors); //----------------------------------------------------- bool bOldVer = false; if( Parameters("DIR")->asGrid() == NULL ) { bOldVer = Parameters("OLDVER")->asBool(); m_Dir_Const.x = sin(Parameters("DIR_CONST")->asDouble() * M_DEG_TO_RAD); m_Dir_Const.y = cos(Parameters("DIR_CONST")->asDouble() * M_DEG_TO_RAD); if( fabs(m_Dir_Const.x) > fabs(m_Dir_Const.y) ) { m_Dir_Const.y /= fabs(m_Dir_Const.x); m_Dir_Const.x = m_Dir_Const.x < 0 ? -1 : 1; } else { m_Dir_Const.x /= fabs(m_Dir_Const.y); m_Dir_Const.y = m_Dir_Const.y < 0 ? -1 : 1; } } else { if( !m_DX.Create(*Get_System()) || !m_DY.Create(*Get_System()) ) { Error_Set(_TL("could not allocate sufficient memory")); return( false ); } CSG_Grid *pDir = Parameters("DIR")->asGrid(); CSG_Grid *pLen = Parameters("LEN")->asGrid(); double dRadians = Parameters("DIR_UNITS")->asInt() == 0 ? 1.0 : M_DEG_TO_RAD; double dScale = Parameters("LEN_SCALE")->asDouble(); #pragma omp parallel for for(int y=0; yis_NoData(x, y) ) { m_DX.Set_NoData(x, y); } else { double d = pLen ? (!pLen->is_NoData(x, y) ? dScale * pLen->asDouble(x, y) : 0.0) : 1.0; m_DX.Set_Value(x, y, d * sin(pDir->asDouble(x, y) * dRadians)); m_DY.Set_Value(x, y, d * cos(pDir->asDouble(x, y) * dRadians)); } } } } if( Parameters("PYRAMIDS")->asBool() && !bOldVer ) { m_DEM.Create(m_pDEM, 2.0); } //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { pAFH->Set_NoData(x, y); } else { double Luv, Luv_Lee, Lee; if( bOldVer ) { Get_Luv_Old(x, y, m_Dir_Const.x, m_Dir_Const.y, Luv); Get_Lee_Old(x, y, -m_Dir_Const.x, -m_Dir_Const.y, Luv_Lee, Lee); } else { Get_Luv(x, y, Luv); Get_Lee(x, y, Luv_Lee, Lee); } //----------------------------------------- double d, z = m_pDEM->asDouble(x, y); d = 1.0 + (z + Lee != 0.0 ? (z - Lee) / (z + Lee) : 0.0); d = (Luv > Luv_Lee ? Luv - Luv_Lee : 0.0) + z * d*d / 2.0; pAFH->Set_Value(x, y, d < 0.0 ? 0.0 : d); } } } //----------------------------------------------------- m_DX .Destroy(); m_DY .Destroy(); m_DEM.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CAir_Flow_Height::Get_Next(TSG_Point &Position, double Distance, bool bReverse) { if( Distance <= 0.0 ) { return( false ); } double dx, dy; if( !m_DX.is_Valid() ) { dx = m_Dir_Const.x; dy = m_Dir_Const.y; } else { /* if( m_bTrace ) { double d, dMove = bReverse ? -Get_Cellsize() : Get_Cellsize(); for(d=0.0; dGet_Extent(true).Contains(Position) ); } //--------------------------------------------------------- inline bool CAir_Flow_Height::Get_Z(const TSG_Point &Position, double Distance, double &z) { if( m_DEM.Get_Count() > 0 ) { Distance /= 4.0; for(int i=0; iGet_Cellsize() ) { return( m_DEM.Get_Grid(i)->Get_Value(Position, z) ); } } } return( m_pDEM->Get_Value(Position, z) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CAir_Flow_Height::Get_Luv(int x, int y, double &Sum_A) { double Weight_A = Sum_A = 0.0; if( m_pDEM->is_InGrid(x, y) ) { double z, d, id, w; TSG_Point p; d = id = Get_Cellsize(); p = Get_System()->Get_Grid_to_World(x, y); while( id <= m_maxDistance && Get_Next(p, d, false) ) { if( Get_Z(p, d, z) ) { Weight_A += w = d * pow(id, -m_dLuv); Sum_A += w * z; } d *= m_Acceleration; id += d; } if( Weight_A > 0.0 ) { Sum_A /= Weight_A; } } } //--------------------------------------------------------- void CAir_Flow_Height::Get_Lee(int x, int y, double &Sum_A, double &Sum_B) { double Weight_A = Sum_A = 0.0; double Weight_B = Sum_B = 0.0; if( m_pDEM->is_InGrid(x, y) ) { double z, d, id, w; TSG_Point p; d = id = Get_Cellsize(); p = Get_System()->Get_Grid_to_World(x, y); while( id <= m_maxDistance && Get_Next(p, d, true) ) { if( Get_Z(p, d, z) ) { Weight_A += w = d * pow(id, -m_dLuv); Sum_A += w * z; Weight_B += w = d * pow(id, -m_dLee); Sum_B += w * z; } d *= m_Acceleration; id += d; } if( Weight_A > 0.0 ) { Sum_A /= Weight_A; } if( Weight_B > 0.0 ) { Sum_B /= Weight_B; } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CAir_Flow_Height::Get_Luv_Old(int x, int y, double dx, double dy, double &Sum_A) { double Weight_A = Sum_A = 0.0; double w, d = Get_Cellsize() * sqrt(dx*dx + dy*dy); for(double ix=x+dx+0.5, iy=y+dy+0.5, id=d; is_InGrid(x = (int)ix, y = (int)iy) && id<=m_maxDistance; ix+=dx, iy+=dy, id+=d) { if( !m_pDEM->is_NoData(x, y) ) { Weight_A += w = pow(id, -m_dLuv); Sum_A += w * m_pDEM->asDouble(x, y); } } if( Weight_A > 0.0 ) { Sum_A /= Weight_A; } } //--------------------------------------------------------- void CAir_Flow_Height::Get_Lee_Old(int x, int y, double dx, double dy, double &Sum_A, double &Sum_B) { double Weight_A = Sum_A = 0.0; double Weight_B = Sum_B = 0.0; double w, d = Get_Cellsize() * sqrt(dx*dx + dy*dy); for(double ix=x+dx+0.5, iy=y+dy+0.5, id=d; is_InGrid(x = (int)ix, y = (int)iy) && id<=m_maxDistance; ix+=dx, iy+=dy, id+=d) { if( !m_pDEM->is_NoData(x, y) ) { double z = m_pDEM->asDouble(x, y); Weight_A += w = pow(id, -m_dLuv); Sum_A += w * z; Weight_B += w = pow(id, -m_dLee); Sum_B += w * z; } } if( Weight_A > 0.0 ) { Sum_A /= Weight_A; } if( Weight_B > 0.0 ) { Sum_B /= Weight_B; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/distance_gradient.cpp0000664000175000017500000002142612565125415030634 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: distance_gradient.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Distance_Gradient.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "distance_gradient.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDistance_Gradient::CDistance_Gradient(void) { Set_Name (_TL("Downslope Distance Gradient")); Set_Author (SG_T("(c) 2006 by O.Conrad")); Set_Description (_TW( "Calculation of a new topographic index to quantify downslope controls on local drainage. " "\n\n" "References:\n" "- Hjerdt, K.N., McDonnell, J.J., Seibert, J. Rodhe, A. (2004): " " 'A new topographic index to quantify downslope controls on local drainage', " " Water Resources Research, 40\n" "\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "GRADIENT" , _TL("Gradient"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "DIFFERENCE" , _TL("Gradient Difference"), _TL("Difference to local gradient."), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "DISTANCE" , _TL("Vertical Distance"), _TL(""), PARAMETER_TYPE_Double , 10.0, 0.0, true ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("distance"), _TL("gradient (tangens)"), _TL("gradient (degree)") ), 2 ); } //--------------------------------------------------------- CDistance_Gradient::~CDistance_Gradient(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDistance_Gradient::On_Execute(void) { int x, y, Output; double vDistance, hDistance, s, a; CSG_Grid *pGradient, *pDifference; //----------------------------------------------------- m_pDEM = Parameters("DEM") ->asGrid(); pGradient = Parameters("GRADIENT") ->asGrid(); pDifference = Parameters("DIFFERENCE") ->asGrid(); vDistance = Parameters("DISTANCE") ->asDouble(); Output = Parameters("OUTPUT") ->asInt(); //----------------------------------------------------- if( vDistance > 0.0 ) { switch( Output ) { case 0: // distance DataObject_Set_Colors(pGradient, 100, SG_COLORS_WHITE_BLUE , false); pGradient->Set_Unit(_TL("m")); break; case 1: // gradient (ratio) DataObject_Set_Colors(pGradient, 100, SG_COLORS_WHITE_BLUE , true); pGradient->Set_Unit(_TL("")); break; case 2: // gradient (degree) DataObject_Set_Colors(pGradient, 100, SG_COLORS_YELLOW_RED , false); pGradient->Set_Unit(_TL("radians")); break; } if( pDifference ) { DataObject_Set_Colors(pDifference, 100, SG_COLORS_RED_GREY_BLUE , false); pDifference->Set_Unit(_TL("radians")); } //------------------------------------------------- m_Dir.Create(m_pDEM, SG_DATATYPE_Char); for(y=0; yGet_Gradient_NeighborDir(x, y)); } } //------------------------------------------------- for(y=0; y 0.0 ) { switch( Output ) { case 0: // distance pGradient->Set_Value(x, y, hDistance); break; case 1: // gradient (tangens) pGradient->Set_Value(x, y, vDistance / hDistance); break; case 2: // gradient (degree) pGradient->Set_Value(x, y, atan(vDistance / hDistance)); break; } if( pDifference ) { if( m_pDEM->Get_Gradient(x, y, s, a) ) pDifference->Set_Value (x, y, s - atan(vDistance / hDistance)); else pDifference->Set_NoData(x, y); } } else { pGradient->Set_NoData(x, y); if( pDifference ) pDifference->Set_NoData(x, y); } } } //------------------------------------------------- m_Dir.Destroy(); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CDistance_Gradient::Get_hDistance(int x, int y, double vDistance) { int Dir; double zStart, zStop, z, zLast, hDistance; hDistance = 0.0; if( m_pDEM->is_InGrid(x, y) ) { zStart = z = m_pDEM->asDouble(x, y); zStop = zStart - vDistance; while( z > zStop && m_pDEM->is_InGrid(x, y) && (Dir = m_Dir.asInt(x, y)) >= 0 )//&& Process_Get_Okay(false) ) { x += Get_xTo(Dir); y += Get_yTo(Dir); if( m_pDEM->is_InGrid(x, y) ) { zLast = z; z = m_pDEM->asDouble(x, y); if( z < zStop ) { hDistance += Get_Length(Dir) * (zStop - zLast) / (z - zLast); } else { hDistance += Get_Length(Dir); } } else { hDistance += Get_Length(Dir); } } if( !m_pDEM->is_InGrid(x, y) ) { if( (z = zStart - z) > 0.0 ) { hDistance *= vDistance / z; } else { hDistance = SG_Get_Length(m_pDEM->Get_XRange(), m_pDEM->Get_YRange()); } } } return( hDistance ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/top_hat.cpp0000664000175000017500000002754012565125415026626 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: top_hat.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // top_hat.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "top_hat.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTop_Hat::CTop_Hat(void) { //----------------------------------------------------- Set_Name (_TL("Valley and Ridge Detection (Top Hat Approach)")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Calculating fuzzy valley and ridge class memberships using the Top Hat approach. " "Based on the AML script \'tophat\' by Jochen Schmidt, Landcare Research. " "\n" "\nReferences:\n" "Rodriguez, F., Maire, E., Courjault-Rad'e, P., Darrozes, J. (2002): " "The Black Top Hat function applied to a DEM: a tool to estimate recent incision in a mountainous watershed. " "(Estib`ere Watershed, Central Pyrenees). Geophysical Research Letters, 29(6), 9-1 - 9-4.\n" )); //----------------------------------------------------- Parameters.Add_Grid(NULL, "DEM" , _TL("Elevation" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "VALLEY" , _TL("Valley Depth" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "HILL" , _TL("Hill Height" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "VALLEY_IDX", _TL("Valley Index" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "HILL_IDX" , _TL("Hill Index" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "SLOPE_IDX" , _TL("Hillslope Index"), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Value( NULL , "RADIUS_VALLEY" , _TL("Valley Radius"), _TL("radius given in map units used to fill valleys"), PARAMETER_TYPE_Double, 1000.0, 0.0, true ); Parameters.Add_Value( NULL , "RADIUS_HILL" , _TL("Hill Radius"), _TL("radius given in map units used to cut hills"), PARAMETER_TYPE_Double, 1000.0, 0.0, true ); Parameters.Add_Value( NULL , "THRESHOLD" , _TL("Elevation Threshold"), _TL("elevation threshold used to identify hills/valleys"), PARAMETER_TYPE_Double, 100.0, 0.0, true ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Slope Index"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("default"), _TL("alternative") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTop_Hat::On_Execute(void) { int y, Method; double Threshold; CSG_Grid *pDEM, *pValley, *pValley_Idx, *pHill, *pHill_Idx, *pSlope_Idx; //----------------------------------------------------- pDEM = Parameters("DEM" )->asGrid(); pValley = Parameters("VALLEY" )->asGrid(); pValley_Idx = Parameters("VALLEY_IDX")->asGrid(); pHill = Parameters("HILL" )->asGrid(); pHill_Idx = Parameters("HILL_IDX" )->asGrid(); pSlope_Idx = Parameters("SLOPE_IDX" )->asGrid(); Threshold = Parameters("THRESHOLD" )->asDouble(); Method = Parameters("METHOD" )->asInt(); //----------------------------------------------------- CSG_Grid_Cell_Addressor rValley, rHill; if( !rValley.Set_Radius(Parameters("RADIUS_VALLEY")->asDouble() / Get_Cellsize()) ) { Error_Set(_TL("could not initialize search engine for valleys")); return( false ); } if( !rHill .Set_Radius(Parameters("RADIUS_HILL" )->asDouble() / Get_Cellsize()) ) { Error_Set(_TL("could not initialize search engine for hills")); return( false ); } //----------------------------------------------------- DataObject_Set_Colors(pValley , 11, SG_COLORS_WHITE_BLUE); DataObject_Set_Colors(pValley_Idx, 11, SG_COLORS_WHITE_BLUE); DataObject_Set_Colors(pHill , 11, SG_COLORS_WHITE_RED); DataObject_Set_Colors(pHill_Idx , 11, SG_COLORS_WHITE_RED); DataObject_Set_Colors(pSlope_Idx , 11, SG_COLORS_WHITE_GREEN); //----------------------------------------------------- CSG_Grid zMax(*Get_System()), zMin(*Get_System()); for(y=0; yasDouble(x, y); // VALLEY = max(0, focalmin(focalmax(%IN%, CIRCLE, %VALRAD%), CIRCLE, %VALRAD%) - %IN% - %THRES%) // TOP HAT: fill valleys double zValley = M_GET_MAX(0, min - z - Threshold); // HILL = max(0, %IN% - focalmax(focalmin(%IN%, CIRCLE, %HILRAD%), CIRCLE, %HILRAD%) - %THRES%) // TOP HAT: cut hills double zHill = M_GET_MAX(0, z - max - Threshold); if( pValley ) pValley ->Set_Value(x, y, zValley); if( pHill ) pHill ->Set_Value(x, y, zHill); pValley_Idx->Set_Value(x, y, // valley index = con(VALLEY > 0 & HILL <= 0, 1, con(HILL > 0 & VALLEY <= 0, 0, con(VALLEY > 0 | HILL > 0, VALLEY / (HILL + VALLEY), 0))) zValley > 0 && zHill <= 0 ? 1 : (zHill > 0 && zValley <= 0 ? 0 : (zValley > 0 || zHill > 0 ? zValley / (zHill + zValley) : 0)) ); pHill_Idx ->Set_Value(x, y, // hill index = con(VALLEY > 0 & HILL <= 0, 0, con(HILL > 0 & VALLEY <= 0, 1, con(VALLEY > 0 | HILL > 0, HILL / (HILL + VALLEY), 0))) zValley > 0 && zHill <= 0 ? 0 : (zHill > 0 && zValley <= 0 ? 1 : (zValley > 0 || zHill > 0 ? zHill / (zHill + zValley) : 0)) ); if( pSlope_Idx ) { if( Method == 0 ) { pSlope_Idx->Set_Value(x, y, // HILLSLOPE = con(VALLEY <= 0 & HILL <= 0, 1, 2 * min(VALLEY, HILL) / (HILL + VALLEY)) zValley <= 0 && zHill <= 0 ? 1 : 2 * M_GET_MIN(zValley, zHill) / (zHill + zValley) ); } else // maybe better ?! { pSlope_Idx->Set_Value(x, y, // HILLSLOPE = con(VALLEY < %THRES% & hill < %THRES%, 1, sin(3.14152 * 0.5 * (1 - abs(HILLI - VALLI)))) zValley < Threshold && zHill < Threshold ? 1 : sin(3.14152 * 0.5 * (1 - fabs(pHill_Idx->asDouble(x, y) - pValley_Idx->asDouble(x, y)))) ); } } } else { if( pValley ) pValley ->Set_NoData(x, y); if( pHill ) pHill ->Set_NoData(x, y); if( pValley_Idx ) pValley_Idx->Set_NoData(x, y); if( pHill_Idx ) pHill_Idx ->Set_NoData(x, y); if( pSlope_Idx ) pSlope_Idx ->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTop_Hat::Get_Focal_Statistics(int x, int y, const CSG_Grid &g, const CSG_Grid_Cell_Addressor &r, CSG_Simple_Statistics &s) { s.Invalidate(); if( g.is_InGrid(x, y) ) { for(int i=0, ix, iy; i 0 ); } //--------------------------------------------------------- bool CTop_Hat::Get_Focal_Minimum(int x, int y, const CSG_Grid &g, const CSG_Grid_Cell_Addressor &r, double &Minimum) { CSG_Simple_Statistics s; if( Get_Focal_Statistics(x, y, g, r, s) ) { Minimum = s.Get_Minimum(); return( true ); } return( false ); } //--------------------------------------------------------- bool CTop_Hat::Get_Focal_Maximum(int x, int y, const CSG_Grid &g, const CSG_Grid_Cell_Addressor &r, double &Maximum) { CSG_Simple_Statistics s; if( Get_Focal_Statistics(x, y, g, r, s) ) { Maximum = s.Get_Maximum(); return( true ); } return( false ); } //--------------------------------------------------------- bool CTop_Hat::Get_Focal_Extremes(int x, int y, const CSG_Grid &g, const CSG_Grid_Cell_Addressor &r, double &Minimum, double &Maximum) { CSG_Simple_Statistics s; if( Get_Focal_Statistics(x, y, g, r, s) ) { Minimum = s.Get_Minimum(); Maximum = s.Get_Maximum(); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/ruggedness.h0000664000175000017500000001132612565125415026776 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ruggedness.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 CSG_String 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 CSG_String 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 saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Makefile.in0000664000175000017500000006232112622651176026527 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/ta_morphometry DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libta_morphometry_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libta_morphometry_la_OBJECTS = Convergence.lo Convergence_Radius.lo \ Curvature_Classification.lo Curvature_UpDownSlope.lo \ Hypsometry.lo MLB_Interface.lo Morphometry.lo \ ProtectionIndex.lo RealArea.lo SurfaceSpecificPoints.lo \ air_flow_height.lo anisotropic_heating.lo distance_gradient.lo \ fuzzy_landform_elements.lo land_surface_temperature.lo \ mass_balance_index.lo mrvbf.lo param_scale.lo \ relative_heights.lo ruggedness.lo tc_iwahashi_pike.lo \ top_hat.lo tpi.lo wind_effect.lo libta_morphometry_la_OBJECTS = $(am_libta_morphometry_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libta_morphometry_la_SOURCES) DIST_SOURCES = $(libta_morphometry_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1619 2013-03-05 16:07:00Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_morphometry.la libta_morphometry_la_SOURCES = \ Convergence.cpp\ Convergence_Radius.cpp\ Curvature_Classification.cpp\ Curvature_UpDownSlope.cpp\ Hypsometry.cpp\ MLB_Interface.cpp\ Morphometry.cpp\ ProtectionIndex.cpp\ RealArea.cpp\ SurfaceSpecificPoints.cpp\ air_flow_height.cpp\ anisotropic_heating.cpp\ distance_gradient.cpp\ fuzzy_landform_elements.cpp\ land_surface_temperature.cpp\ mass_balance_index.cpp\ mrvbf.cpp\ param_scale.cpp\ relative_heights.cpp\ ruggedness.cpp\ tc_iwahashi_pike.cpp\ top_hat.cpp\ tpi.cpp\ wind_effect.cpp\ Convergence.h\ Convergence_Radius.h\ Curvature_Classification.h\ Curvature_UpDownSlope.h\ Hypsometry.h\ MLB_Interface.h\ Morphometry.h\ ProtectionIndex.h\ RealArea.h\ SurfaceSpecificPoints.h\ air_flow_height.h\ anisotropic_heating.h\ distance_gradient.h\ fuzzy_landform_elements.h\ land_surface_temperature.h\ mass_balance_index.h\ mrvbf.h\ param_scale.h\ relative_heights.h\ ruggedness.h\ tc_iwahashi_pike.h\ top_hat.h\ tpi.h\ wind_effect.h libta_morphometry_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) --foreign src/modules/terrain_analysis/ta_morphometry/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/terrain_analysis/ta_morphometry/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libta_morphometry.la: $(libta_morphometry_la_OBJECTS) $(libta_morphometry_la_DEPENDENCIES) $(EXTRA_libta_morphometry_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libta_morphometry_la_OBJECTS) $(libta_morphometry_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Convergence.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Convergence_Radius.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Curvature_Classification.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Curvature_UpDownSlope.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Hypsometry.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Morphometry.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ProtectionIndex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RealArea.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SurfaceSpecificPoints.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/air_flow_height.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/anisotropic_heating.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/distance_gradient.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fuzzy_landform_elements.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/land_surface_temperature.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mass_balance_index.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mrvbf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/param_scale.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relative_heights.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ruggedness.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc_iwahashi_pike.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/top_hat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tpi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wind_effect.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/relative_heights.h0000664000175000017500000001104612565125415030155 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: relative_heights.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Relative_Heights.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: conrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Relative_Heights_H #define HEADER_INCLUDED__Relative_Heights_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CRelative_Heights : public CSG_Module_Grid { public: CRelative_Heights(void); protected: virtual bool On_Execute (void); private: bool Get_Heights (CSG_Grid *pDEM, CSG_Grid *pH, bool bInverse, double w, double t, double e); bool Get_Heights_Catchment (CSG_Grid *pDEM, CSG_Grid *pH, double w); bool Get_Heights_Modified (CSG_Grid *pDEM, CSG_Grid *pH, double t, double e); double Get_Local_Maximum (CSG_Grid *pGrid, int x, int y); bool Get_Results (CSG_Grid *pDEM, CSG_Grid *pHO, CSG_Grid *pHU); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Relative_Heights_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/RealArea.h0000664000175000017500000000235412565125415026305 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: RealArea.h 1348 2012-03-12 16:17:14Z oconrad $ *********************************************************/ /******************************************************************************* RealArea.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "MLB_Interface.h" class CRealArea : public CSG_Module_Grid { public: CRealArea(void); protected: bool On_Execute (void); }; saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/mrvbf.cpp0000664000175000017500000004225612565125415026305 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: mrvbf.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // MRVBF.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "mrvbf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMRVBF::CMRVBF(void) { Set_Name (_TL("Multiresolution Index of Valley Bottom Flatness (MRVBF)")); Set_Author (SG_T("(c) 2006 by O.Conrad")); Set_Description (_TW( "Calculation of the 'multiresolution index of valley bottom flatness' (MRVBF) and " "the complementary 'multiresolution index of the ridge top flatness' (MRRTF). " "\n\n" "References:\n" "- Gallant, J.C., Dowling, T.I. (2003): " " 'A multiresolution index of valley bottom flatness for mapping depositional areas', " " Water Resources Research, 39/12:1347-1359\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "MRVBF" , _TL("MRVBF"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "MRRTF" , _TL("MRRTF"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "T_SLOPE" , _TL("Initial Threshold for Slope"), _TL(""), PARAMETER_TYPE_Double , 16.0, 0.0, true, 100.0, true ); Parameters.Add_Value( NULL , "T_PCTL_V" , _TL("Threshold for Elevation Percentile (Lowness)"), _TL(""), PARAMETER_TYPE_Double , 0.40, 0.0, true, 1.0, true ); Parameters.Add_Value( NULL , "T_PCTL_R" , _TL("Threshold for Elevation Percentile (Upness)"), _TL(""), PARAMETER_TYPE_Double , 0.35, 0.0, true, 1.0, true ); Parameters.Add_Value( NULL , "P_SLOPE" , _TL("Shape Parameter for Slope"), _TL(""), PARAMETER_TYPE_Double , 4.0 ); Parameters.Add_Value( NULL , "P_PCTL" , _TL("Shape Parameter for Elevation Percentile"), _TL(""), PARAMETER_TYPE_Double , 3.0 ); Parameters.Add_Value( NULL , "UPDATE" , _TL("Update Views"), _TL(""), PARAMETER_TYPE_Bool , true ); Parameters.Add_Value( NULL , "CLASSIFY" , _TL("Classify"), _TL(""), PARAMETER_TYPE_Bool , false ); Parameters.Add_Value( NULL , "MAX_RES" , _TL("Maximum Resolution (Percentage)"), _TL("Maximum resolution as percentage of the diameter of the DEM."), PARAMETER_TYPE_Double , 100.0, 0.0, true, 100.0, true ); } //--------------------------------------------------------- CMRVBF::~CMRVBF(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define UPDATE_VIEWS(b) if( bUpdate ) { DataObject_Update(pMRRTF, b); DataObject_Update(pMRVBF, b); } //--------------------------------------------------------- bool CMRVBF::On_Execute(void) { bool bUpdate; int Level; double T_Slope, Resolution, max_Resolution; CSG_Grid *pDEM, *pMRVBF, *pMRRTF, CF, VF, RF, DEM, Slope, Pctl; //----------------------------------------------------- pDEM = Parameters("DEM") ->asGrid(); pMRVBF = Parameters("MRVBF") ->asGrid(); pMRRTF = Parameters("MRRTF") ->asGrid(); T_Slope = Parameters("T_SLOPE") ->asDouble(); m_T_Pctl_V = Parameters("T_PCTL_V") ->asDouble(); m_T_Pctl_R = Parameters("T_PCTL_R") ->asDouble(); m_P_Slope = Parameters("P_SLOPE") ->asDouble(); m_P_Pctl = Parameters("P_PCTL") ->asDouble(); bUpdate = Parameters("UPDATE") ->asBool(); max_Resolution = Parameters("MAX_RES") ->asDouble() / 100.0; Resolution = SG_Get_Length(Get_System()->Get_XRange(), Get_System()->Get_YRange()); max_Resolution = max_Resolution * Resolution; //----------------------------------------------------- if( 1 ) { // DataObject_Set_Colors(pMRVBF, 100, SG_COLORS_WHITE_BLUE , false); DataObject_Set_Colors(pMRVBF, 100, SG_COLORS_RED_GREY_BLUE , false); // DataObject_Set_Colors(pMRRTF, 100, SG_COLORS_RED_GREY_BLUE , true); DataObject_Set_Colors(pMRRTF, 100, SG_COLORS_WHITE_RED , false); CSG_Grid CF, VF, RF, DEM, Slopes, Percentiles; VF.Create(*Get_System(), SG_DATATYPE_Float); RF.Create(*Get_System(), SG_DATATYPE_Float); CF.Create(*Get_System(), SG_DATATYPE_Float); CF.Assign(1.0); DEM.Create(*pDEM); //------------------------------------------------- Level = 1; Resolution = Get_Cellsize(); Process_Set_Text(CSG_String::Format(SG_T("%d. %s"), Level, _TL("step"))); Message_Add(CSG_String::Format(SG_T("%s: %d, %s: %.2f, %s %.2f"), _TL("step"), Level, _TL("resolution"), Resolution, _TL("threshold slope"), T_Slope)); Get_Slopes (&DEM, &Slopes); Get_Percentiles (&DEM, &Percentiles, 3); Get_Flatness (&Slopes, &Percentiles, &CF, pMRVBF, pMRRTF, T_Slope); UPDATE_VIEWS (true); //------------------------------------------------- T_Slope /= 2.0; Level++; Process_Set_Text(CSG_String::Format(SG_T("%d. %s"), Level, _TL("step"))); Message_Add(CSG_String::Format(SG_T("%s: %d, %s: %.2f, %s %.2f"), _TL("step"), Level, _TL("resolution"), Resolution, _TL("threshold slope"), T_Slope)); Get_Percentiles (&DEM, &Percentiles, 6); Get_Flatness (&Slopes, &Percentiles, &CF, &VF, &RF, T_Slope); Get_MRVBF (Level, pMRVBF, &VF, pMRRTF, &RF); UPDATE_VIEWS (false); //------------------------------------------------- while( Process_Get_Okay(false) && Resolution < max_Resolution ) { Resolution *= 3.0; T_Slope /= 2.0; Level++; Process_Set_Text(CSG_String::Format(SG_T("%d. %s"), Level, _TL("step"))); Message_Add(CSG_String::Format(SG_T("%s: %d, %s: %.2f, %s %.2f"), _TL("step"), Level, _TL("resolution"), Resolution, _TL("threshold slope"), T_Slope)); Get_Values (&DEM, &Slopes, &Percentiles, Resolution); Get_Flatness (&Slopes, &Percentiles, &CF, &VF, &RF, T_Slope); Get_MRVBF (Level, pMRVBF, &VF, pMRRTF, &RF); UPDATE_VIEWS (false); } if( Parameters("CLASSIFY")->asBool() ) { Get_Classified(pMRVBF); Get_Classified(pMRRTF); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CMRVBF::Get_Transformation(double x, double t, double p) { return( 1.0 / (1.0 + pow(x / t, p)) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMRVBF::Get_Smoothed(CSG_Grid *pDEM, CSG_Grid *pSmoothed, int Radius, double Smoothing) { if( pDEM && pSmoothed ) { int x, y, ix, iy, jx, jy, kx, ky; double d, s; CSG_Grid Kernel(SG_DATATYPE_Double, 1 + 2 * Radius, 1 + 2 * Radius); for(iy=-Radius, ky=0; iy<=Radius; iy++, ky++) { for(ix=-Radius, kx=0; ix<=Radius; ix++, kx++) { Kernel.Set_Value(kx, ky, 4.3565 * exp(-SG_Get_Square(sqrt((double)ix*ix + iy*iy) / 3.0)) ); // Kernel.Set_Value(kx, ky, exp(-(ix*ix + iy*iy) / (2.0 * s)) / (2.0 * M_PI * s)); } } pSmoothed->Create(pDEM, SG_DATATYPE_Float); for(y=0; yGet_NY() && Set_Progress(y, pDEM->Get_NY()); y++) { for(x=0; xGet_NX(); x++) { for(iy=-Radius, jy=y-Radius, ky=0, s=d=0.0; iy<=Radius; iy++, jy++, ky++) { for(ix=-Radius, jx=x-Radius, kx=0; ix<=Radius; ix++, jx++, kx++) { if( pDEM->is_InGrid(jx, jy) ) { s += Kernel.asDouble(kx, ky) * pDEM->asDouble(jx, jy); d += Kernel.asDouble(kx, ky); } } } if( d > 0.0 ) { pSmoothed->Set_Value(x, y, s / d); } else { pSmoothed->Set_NoData(x, y); } } } return( true ); } return( false ); } //--------------------------------------------------------- bool CMRVBF::Get_Values(CSG_Grid *pDEM, CSG_Grid *pSlopes, CSG_Grid *pPercentiles, double Resolution) { if( pDEM && pDEM->is_Valid() && pSlopes && pPercentiles ) { int nx, ny; CSG_Grid Smoothed; Get_Smoothed(pDEM, &Smoothed, 5, 3.0); Get_Slopes(&Smoothed, pSlopes); nx = 2 + (int)(pDEM->Get_XRange() / Resolution); ny = 2 + (int)(pDEM->Get_YRange() / Resolution); pDEM->Create(SG_DATATYPE_Float, nx, ny, Resolution, pDEM->Get_XMin(), pDEM->Get_YMin()); pDEM->Assign(&Smoothed, GRID_INTERPOLATION_NearestNeighbour); Get_Percentiles(pDEM, pPercentiles, 6); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMRVBF::Get_Percentile(CSG_Grid *pDEM, int x, int y, double &Percentile) { if( pDEM && pDEM->is_Valid() && pDEM->is_InGrid(x, y, true) ) { int iRadius, iPoint, nPoints, nLower, ix, iy; double z = pDEM->asDouble(x, y); for(iRadius=0, nPoints=0, nLower=0; iRadiusis_InGrid(ix, iy) ) { nPoints++; if( pDEM->asDouble(ix, iy) < z ) { nLower++; } } } } if( nPoints > 1 ) { Percentile = (double)nLower / (double)(nPoints - 1.0); return( true ); } } return( false ); } //--------------------------------------------------------- bool CMRVBF::Get_Percentiles(CSG_Grid *pDEM, CSG_Grid *pPercentiles, int Radius) { if( pDEM && pDEM->is_Valid() ) { pPercentiles->Create(pDEM->Get_System(), SG_DATATYPE_Float); m_Radius.Create(Radius); for(int y=0; yGet_NY() && Set_Progress(y, pDEM->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { double Percentile; if( !Get_Percentile(pDEM, x, y, Percentile) ) { pPercentiles->Set_NoData(x, y); } else { pPercentiles->Set_Value (x, y, Percentile); } } } return( true ); } return( false ); } //--------------------------------------------------------- bool CMRVBF::Get_Slopes(CSG_Grid *pDEM, CSG_Grid *pSlopes) { if( pDEM && pDEM->is_Valid() ) { pSlopes->Create(pDEM->Get_System(), SG_DATATYPE_Float); for(int y=0; yGet_NY() && Set_Progress(y, pDEM->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { double Slope, Aspect; if( !pDEM->Get_Gradient(x, y, Slope, Aspect) ) { pSlopes->Set_NoData(x, y); } else { pSlopes->Set_Value (x, y, 100.0 * tan(Slope)); } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMRVBF::Get_Flatness(CSG_Grid *pSlopes, CSG_Grid *pPercentiles, CSG_Grid *pCF, CSG_Grid *pVF, CSG_Grid *pRF, double T_Slope) { // const int Interpolation = GRID_INTERPOLATION_Bilinear; const int Interpolation = GRID_INTERPOLATION_BSpline; if( pSlopes && pSlopes->is_Valid() && pPercentiles && pPercentiles->is_Valid() ) { int x, y; double xp, yp, Slope, Percentile, cf, vf, rf; for(y=0, yp=Get_YMin(); yGet_Value(xp, yp, Slope , Interpolation) && pPercentiles->Get_Value(xp, yp, Percentile, Interpolation) ) { cf = pCF->asDouble(x, y) * Get_Transformation(Slope, T_Slope, m_P_Slope); vf = cf * Get_Transformation( Percentile, m_T_Pctl_V, m_P_Pctl); rf = cf * Get_Transformation(1.0 - Percentile, m_T_Pctl_R, m_P_Pctl); pCF->Set_Value (x, y, cf); pVF->Set_Value (x, y, 1.0 - Get_Transformation(vf, 0.3, 4.0)); pRF->Set_Value (x, y, 1.0 - Get_Transformation(rf, 0.3, 4.0)); } else { pVF->Set_NoData (x, y); pRF->Set_NoData (x, y); } } } return( true ); } return( false ); } //--------------------------------------------------------- bool CMRVBF::Get_MRVBF(int Level, CSG_Grid *pMRVBF, CSG_Grid *pVF, CSG_Grid *pMRRTF, CSG_Grid *pRF) { if( pMRVBF && pVF && pMRRTF && pRF ) { double d, w, t, p; t = 0.4; p = log((Level - 0.5) / 0.1) / log(1.5); for(int y=0; yis_NoData(x, y) && !pVF->is_NoData(x, y) ) { d = pVF->asDouble(x, y); w = 1.0 - Get_Transformation(d, t, p); pMRVBF->Set_Value(x, y, w * (Level - 1 + d) + (1.0 - w) * pMRVBF->asDouble(x, y)); } if( !pMRRTF->is_NoData(x, y) && !pRF->is_NoData(x, y) ) { d = pRF->asDouble(x, y); w = 1.0 - Get_Transformation(d, t, p); pMRRTF->Set_Value(x, y, w * (Level - 1 + d) + (1.0 - w) * pMRRTF->asDouble(x, y)); } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMRVBF::Get_Classified(CSG_Grid *pMRF) { if( pMRF && pMRF->is_Valid() ) { for(int y=0; yis_NoData(x, y) ) { double d = pMRF->asDouble(x, y); if ( d < 0.5 ) pMRF->Set_Value(x, y, 0.0); else if ( d < 1.5 ) pMRF->Set_Value(x, y, 1.0); else if ( d < 2.5 ) pMRF->Set_Value(x, y, 2.0); else if ( d < 3.5 ) pMRF->Set_Value(x, y, 3.0); else if ( d < 4.5 ) pMRF->Set_Value(x, y, 4.0); else if ( d < 5.5 ) pMRF->Set_Value(x, y, 5.0); else pMRF->Set_Value(x, y, 6.0); } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/tc_iwahashi_pike.cpp0000664000175000017500000006414112570021310030442 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: tpi.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // tc_iwahashi_pike.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "tc_iwahashi_pike.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTC_Parameter_Base::CTC_Parameter_Base(void) {} //--------------------------------------------------------- void CTC_Parameter_Base::On_Construction(void) { Parameters.Add_Value( NULL , "SCALE" , _TL("Scale (Cells)"), _TL(""), PARAMETER_TYPE_Int, 10, 1, true ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format("%s|%s|", _TL("counting cells"), _TL("resampling") ), 1 ); m_Kernel.Get_Weighting().Set_Weighting(SG_DISTWGHT_GAUSS); m_Kernel.Get_Weighting().Set_BandWidth(0.7); m_Kernel.Get_Weighting().Create_Parameters(&Parameters, false); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTC_Parameter_Base::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("DISTANCE_WEIGHTING", pParameter->asInt() == 0); } m_Kernel.Get_Weighting().Enable_Parameters(pParameters); return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTC_Parameter_Base::Get_Parameter(CSG_Grid *pValues, CSG_Grid *pParameter) { DataObject_Set_Colors(pParameter, 10, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- if( Parameters("METHOD")->asInt() == 0 ) { m_Kernel.Get_Weighting().Set_Parameters(&Parameters); m_Kernel.Get_Weighting().Set_BandWidth(Parameters("SCALE")->asDouble() * m_Kernel.Get_Weighting().Get_BandWidth()); m_Kernel.Set_Radius(Parameters("SCALE")->asDouble()); for(int y=0; yis_NoData(x, y) ) { pParameter->Set_NoData(x, y); } else { double d, w, nTotal = 0.0, nValid = 0.0; for(int i=0, ix, iy; iis_InGrid(ix, iy) ) { nTotal += w; if( pValues->asInt(ix, iy) != 0 ) { nValid += w; } } } pParameter->Set_Value(x, y, nTotal > 0.0 ? 100.0 * nValid / nTotal : 0.0); // make percentage } } } m_Kernel.Destroy(); } //----------------------------------------------------- else { double Cellsize = Parameters("SCALE")->asInt() * Get_Cellsize(); if( Cellsize > 0.5 * SG_Get_Length(Get_System()->Get_XRange(), Get_System()->Get_YRange()) ) { Error_Set(_TL("resampling cell size is too large")); return( false ); } CSG_Grid Values(CSG_Grid_System(Cellsize, Get_XMin(), Get_YMin(), Get_XMax(), Get_YMax()), SG_DATATYPE_Float); Values.Assign(pValues, GRID_INTERPOLATION_Mean_Cells); for(int y=0; yis_NoData(x, y) || !Values.Get_Value(px, py, z, GRID_INTERPOLATION_BSpline) ) { pParameter->Set_NoData(x, y); } else { pParameter->Set_Value(x, y, 100.0 * z); // make percentage } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTC_Texture::CTC_Texture(void) { //----------------------------------------------------- Set_Name (_TL("Terrain Surface Texture")); Set_Author ("O.Conrad (c) 2012"); Set_Description (_TW( "Terrain surface texture as proposed by Iwahashi & Pike (2007) for subsequent terrain classification.\n" "\n" "Reference:\n" "Iwahashi, J. & Pike, R.J. (2007): " "Automated classifications of topography from DEMs by an unsupervised nested-means algorithm and a three-part geometric signature. " "Geomorphology, Vol. 86, pp. 409–440\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "TEXTURE" , _TL("Texture"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Flat Area Threshold"), _TL("maximum difference between original and median filtered elevation (3x3 moving window) that still is recognized flat"), PARAMETER_TYPE_Double, 1.0, 0.0, true ); //----------------------------------------------------- On_Construction(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTC_Texture::On_Execute(void) { //----------------------------------------------------- CSG_Grid Noise(*Get_System(), SG_DATATYPE_Char); double Epsilon = Parameters("EPSILON")->asDouble(); m_pDEM = Parameters("DEM")->asGrid(); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { Noise.Set_NoData(x, y); } else { Noise.Set_Value(x, y, Get_Noise(x, y, Epsilon)); } } } //----------------------------------------------------- return( Get_Parameter(&Noise, Parameters("TEXTURE")->asGrid()) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // returns 1 if the cell represents a 'peak/crest' or // if the cell is a 'pit/trough' based on the difference to // median of a 3x3 neighbourhood //--------------------------------------------------------- int CTC_Texture::Get_Noise(int x, int y, double Epsilon) { CSG_Simple_Statistics s(true); for(int iy=y-1; iy<=y+1; iy++) { for(int ix=x-1; ix<=x+1; ix++) { if( m_pDEM->is_InGrid(ix, iy) ) { s += m_pDEM->asDouble(ix, iy); } } } return( fabs(m_pDEM->asDouble(x, y) - s.Get_Median()) > Epsilon ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTC_Convexity::CTC_Convexity(void) { //----------------------------------------------------- Set_Name (_TL("Terrain Surface Convexity")); Set_Author ("O.Conrad (c) 2012"); Set_Description (_TW( "Terrain surface convexity as proposed by Iwahashi & Pike (2007) for subsequent terrain classification.\n" "\n" "Reference:\n" "Iwahashi, J. & Pike, R.J. (2007): " "Automated classifications of topography from DEMs by an unsupervised nested-means algorithm and a three-part geometric signature. " "Geomorphology, Vol. 86, pp. 409–440\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CONVEXITY" , _TL("Convexity"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "KERNEL" , _TL("Laplacian Filter Kernel"), _TL(""), CSG_String::Format("%s|%s|%s|", _TL("conventional four-neighbourhood"), _TL("conventional eight-neihbourhood"), _TL("eight-neihbourhood (distance based weighting)") ) ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Type"), _TL(""), CSG_String::Format("%s|%s|", _TL("convexity"), _TL("concavity") ) ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Flat Area Threshold"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); //----------------------------------------------------- On_Construction(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTC_Convexity::On_Execute(void) { //----------------------------------------------------- const double Kernels[3][2] = { { 1, 0 }, { 1, 1 }, { 1, 1 / sqrt(2.0) } }; int Kernel = Parameters("KERNEL")->asInt(); //----------------------------------------------------- CSG_Grid Laplace(*Get_System(), SG_DATATYPE_Char); double Epsilon = Parameters("EPSILON")->asDouble(); int Type = Parameters("TYPE" )->asInt (); m_pDEM = Parameters("DEM")->asGrid(); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { Laplace.Set_NoData(x, y); } else { Laplace.Set_Value(x, y, Get_Laplace(x, y, Kernels[Kernel], Type, Epsilon)); } } } //----------------------------------------------------- return( Get_Parameter(&Laplace, Parameters("CONVEXITY")->asGrid()) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTC_Convexity::Get_Laplace(int x, int y, const double Kernel[2], int Type, double Epsilon) { double Sum = 4 * (Kernel[0] + Kernel[1]) * m_pDEM->asDouble(x, y); for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); double iz = m_pDEM->is_InGrid(ix, iy) ? m_pDEM->asDouble(ix, iy) : m_pDEM->asDouble(x, y); Sum -= Kernel[i % 2] * iz; } return( Type == 0 ? Sum > Epsilon ? 1 : 0 : Sum < -Epsilon ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define CLASS_FLAG_NODATA 0xFF // 11111111 #define CLASS_FLAG_SLOPE 0x40 // 01000000 #define CLASS_FLAG_CONVEXITY 0x20 // 00100000 #define CLASS_FLAG_TEXTURE 0x10 // 00010000 #define CLASS_FLAG_LEVEL 0x07 // 00000111 /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTC_Classification::CTC_Classification(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Terrain Surface Classification (Iwahashi and Pike)")); Set_Author ("O.Conrad (c) 2012"); Set_Description (_TW( "Terrain surface classification as proposed by Iwahashi & Pike (2007).\n" "\n" "Reference:\n" "Iwahashi, J. & Pike, R.J. (2007): " "Automated classifications of topography from DEMs by an unsupervised nested-means algorithm and a three-part geometric signature. " "Geomorphology, Vol. 86, pp. 409–440\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SLOPE" , _TL("Slope"), _TL(""), PARAMETER_INPUT_OPTIONAL ); pNode = Parameters.Add_Grid( NULL , "CONVEXITY" , _TL("Convexity"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "CONV_RECALC" , _TL("Recalculate"), _TL(""), PARAMETER_TYPE_Bool, false ); pNode = Parameters.Add_Grid( NULL , "TEXTURE" , _TL("Texture"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "TEXT_RECALC" , _TL("Recalculate"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Grid( NULL , "LANDFORMS" , _TL("Landforms"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Byte ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Number of Classes"), _TL(""), SG_T("8|12|16|"), 2 ); //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "CONV_NODE" , _TL("Convexity"), _TL("") ); Parameters.Add_Value( pNode , "CONV_SCALE" , _TL("Scale (Cells)"), _TL(""), PARAMETER_TYPE_Int, 10, 1, true ); Parameters.Add_Choice( pNode , "CONV_KERNEL" , _TL("Laplacian Filter Kernel"), _TL(""), CSG_String::Format("%s|%s|%s|", _TL("four-neighbourhood"), _TL("eight-neihbourhood"), _TL("eight-neihbourhood (distance based weighting)") ) ); Parameters.Add_Choice( pNode , "CONV_TYPE" , _TL("Type"), _TL(""), CSG_String::Format("%s|%s|", _TL("convexity"), _TL("concavity") ) ); Parameters.Add_Value( pNode , "CONV_EPSILON", _TL("Flat Area Threshold"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "TEXT_NODE" , _TL("Texture"), _TL("") ); Parameters.Add_Value( pNode , "TEXT_SCALE" , _TL("Scale (Cells)"), _TL(""), PARAMETER_TYPE_Int, 10, 1, true ); Parameters.Add_Value( pNode , "TEXT_EPSILON", _TL("Flat Area Threshold"), _TL("maximum difference between original and median filtered elevation (3x3 moving window) that still is recognized flat"), PARAMETER_TYPE_Double, 1.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTC_Classification::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { pParameters->Set_Enabled("DEM", pParameters->Get_Parameter("SLOPE" )->asGrid() == NULL || pParameters->Get_Parameter("CONVEXITY" )->asGrid() == NULL || pParameters->Get_Parameter("TEXTURE" )->asGrid() == NULL ); if( !SG_STR_CMP(pParameter->Get_Identifier(), "CONVEXITY") ) { pParameters->Set_Enabled("CONV_RECALC", pParameter->asGrid() != NULL); } pParameters->Set_Enabled("CONV_NODE", pParameters->Get_Parameter("CONVEXITY" )->asGrid() == NULL || pParameters->Get_Parameter("CONV_RECALC")->asBool() ); if( !SG_STR_CMP(pParameter->Get_Identifier(), "TEXTURE") ) { pParameters->Set_Enabled("TEXT_RECALC" , pParameter->asGrid() != NULL); } pParameters->Set_Enabled("TEXT_NODE", pParameters->Get_Parameter("TEXTURE" )->asGrid() == NULL || pParameters->Get_Parameter("TEXT_RECALC")->asBool() ); return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTC_Classification::On_Execute(void) { //----------------------------------------------------- m_pSlope = Parameters("SLOPE" )->asGrid(); m_pConvexity = Parameters("CONVEXITY")->asGrid(); m_pTexture = Parameters("TEXTURE" )->asGrid(); if( (!m_pSlope || !m_pConvexity || !m_pTexture) && !Parameters("DEM")->asGrid() ) { return( false ); } //----------------------------------------------------- CSG_Grid Slope; if( !m_pSlope ) { Slope.Create(*Get_System()); m_pSlope = &Slope; CSG_Grid *pDEM = Parameters("DEM")->asGrid(); for(int y=0; yGet_Gradient(x, y, s, a) ) { Slope.Set_Value(x, y, s); } else { Slope.Set_NoData(x, y); } } } } //----------------------------------------------------- if( !m_pConvexity || Parameters("CONV_RECALC")->asBool() ) { CTC_Convexity c; c.Set_Parameter( "DEM", Parameters("DEM")); c.Set_Parameter( "SCALE", Parameters("CONV_SCALE")); c.Set_Parameter( "KERNEL", Parameters("CONV_KERNEL")); c.Set_Parameter( "TYPE", Parameters("CONV_TYPE")); c.Set_Parameter( "EPSILON", Parameters("CONV_EPSILON")); c.Set_Parameter("CONVEXITY", m_pConvexity); if( !c.Execute() ) { return( false ); } Parameters("CONVEXITY")->Set_Value(m_pConvexity = c.Get_Parameters()->Get_Parameter("CONVEXITY")->asGrid()); } //----------------------------------------------------- if( !m_pTexture || Parameters("TEXT_RECALC")->asBool() ) { CTC_Texture c; c.Set_Parameter( "DEM", Parameters("DEM")); c.Set_Parameter( "SCALE", Parameters("TEXT_SCALE")); c.Set_Parameter("EPSILON", Parameters("TEXT_EPSILON")); c.Set_Parameter("TEXTURE", m_pTexture); if( !c.Execute() ) { return( false ); } Parameters("TEXTURE")->Set_Value(m_pTexture = c.Get_Parameters()->Get_Parameter("TEXTURE")->asGrid()); } //----------------------------------------------------- return( Get_Classes() ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTC_Classification::Get_Classes(void) { //----------------------------------------------------- int Level, nLevels = 1 + Parameters("TYPE")->asInt(); CSG_Grid *pLandforms = Parameters("LANDFORMS")->asGrid(); pLandforms->Assign(0.0); pLandforms->Set_NoData_Value(CLASS_FLAG_NODATA); Set_LUT(pLandforms, nLevels); //----------------------------------------------------- for(Level=1; Level<=nLevels && Process_Get_Okay(); Level++) { Process_Set_Text(CSG_String::Format("%s: %d", _TL("Level"), Level)); m_Mean_Slope = Level == 1 ? m_pSlope ->Get_Mean() : m_Stat_Slope .Get_Mean(); m_Mean_Convexity = Level == 1 ? m_pConvexity->Get_Mean() : m_Stat_Convexity.Get_Mean(); m_Mean_Texture = Level == 1 ? m_pTexture ->Get_Mean() : m_Stat_Texture .Get_Mean(); m_Stat_Slope .Invalidate(); m_Stat_Convexity.Invalidate(); m_Stat_Texture .Invalidate(); for(int y=0; yasInt(x, y) == 0 ) { pLandforms->Set_Value(x, y, Get_Class(Level, x, y, Level == nLevels)); } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- int CTC_Classification::Get_Class(int Level, int x, int y, bool bLastLevel) { if( Level == 1 && (m_pSlope->is_NoData(x, y) || m_pConvexity->is_NoData(x, y) || m_pTexture->is_NoData(x, y)) ) { return( CLASS_FLAG_NODATA ); } //----------------------------------------------------- if( m_pSlope->asDouble(x, y) > m_Mean_Slope ) { Level |= CLASS_FLAG_SLOPE; } else if( !bLastLevel ) { m_Stat_Slope += m_pSlope ->asDouble(x, y); m_Stat_Convexity += m_pConvexity->asDouble(x, y); m_Stat_Texture += m_pTexture ->asDouble(x, y); return( 0 ); // check again on next level } if( m_pConvexity->asDouble(x, y) > m_Mean_Convexity ) { Level |= CLASS_FLAG_CONVEXITY; } if( m_pTexture->asDouble(x, y) > m_Mean_Texture ) { Level |= CLASS_FLAG_TEXTURE; } return( Level ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define ADD_CLASS(Level, Slope, Convexity, Texture, Color, sSlope) {\ CSG_Table_Record *pClass = pLUT->asTable()->Add_Record();\ pClass->Set_Value(0, SG_GET_RGB(SG_GET_B(Color), SG_GET_G(Color), SG_GET_R(Color)));\ pClass->Set_Value(1, CSG_String::Format("%d) %s slope, %s texture, %s convexity", pLUT->asTable()->Get_Count(), SG_T(sSlope),\ Texture ? SG_T("fine") : SG_T("coarse"),\ Convexity ? SG_T("high") : SG_T("low")));\ pClass->Set_Value(2, pClass->asString(1));\ pClass->Set_Value(3, Level|(Slope ? CLASS_FLAG_SLOPE : 0)|(Convexity ? CLASS_FLAG_CONVEXITY : 0)|(Texture ? CLASS_FLAG_TEXTURE : 0));\ pClass->Set_Value(4, pClass->asInt(3));\ } //--------------------------------------------------------- void CTC_Classification::Set_LUT(CSG_Grid *pLandforms, int nLevels) { CSG_Parameter *pLUT = DataObject_Get_Parameter(pLandforms, "LUT"); if( !pLUT || !pLUT->asTable() ) { return; } pLUT->asTable()->Del_Records(); switch( nLevels ) { case 1: // 8 classes // l s c t ADD_CLASS(1, 1, 1, 1, 0x7F4633, "steep" ); // class 1 ADD_CLASS(1, 1, 1, 0, 0xFF00FF, "steep" ); // class 2 ADD_CLASS(1, 1, 0, 1, 0xC16E2E, "steep" ); // class 3 ADD_CLASS(1, 1, 0, 0, 0xFC97CF, "steep" ); // class 4 ADD_CLASS(1, 0, 1, 1, 0x66A726, "gentle" ); // class 5 ADD_CLASS(1, 0, 1, 0, 0xFFFF40, "gentle" ); // class 6 ADD_CLASS(1, 0, 0, 1, 0xAEFF7B, "gentle" ); // class 7 ADD_CLASS(1, 0, 0, 0, 0xFFFFBF, "gentle" ); // class 8 break; case 2: // 12 classes ADD_CLASS(1, 1, 1, 1, 0x7F4633, "steep" ); // class 1 ADD_CLASS(1, 1, 1, 0, 0xFF00FF, "steep" ); // class 2 ADD_CLASS(1, 1, 0, 1, 0xC16E2E, "steep" ); // class 3 ADD_CLASS(1, 1, 0, 0, 0xFC97CF, "steep" ); // class 4 ADD_CLASS(2, 1, 1, 1, 0xFA9600, "moderate" ); // class 5 ADD_CLASS(2, 1, 1, 0, 0xFD43A8, "moderate" ); // class 6 ADD_CLASS(2, 1, 0, 1, 0xFBCF66, "moderate" ); // class 7 ADD_CLASS(2, 1, 0, 0, 0xF9C4D4, "moderate" ); // class 8 ADD_CLASS(2, 0, 1, 1, 0x66A726, "gentle" ); // class 9 ADD_CLASS(2, 0, 1, 0, 0xFFFF40, "gentle" ); // class 10 ADD_CLASS(2, 0, 0, 1, 0xAEFF7B, "gentle" ); // class 11 ADD_CLASS(2, 0, 0, 0, 0xFFFFBF, "gentle" ); // class 12 break; default: // 16 classes ADD_CLASS(1, 1, 1, 1, 0x7F4633, "very steep"); // class 1 ADD_CLASS(1, 1, 1, 0, 0xFF00FF, "very steep"); // class 2 ADD_CLASS(1, 1, 0, 1, 0xC16E2E, "very steep"); // class 3 ADD_CLASS(1, 1, 0, 0, 0xFC97CF, "very steep"); // class 4 ADD_CLASS(2, 1, 1, 1, 0xFA9600, "steep" ); // class 5 ADD_CLASS(2, 1, 1, 0, 0xFD43A8, "steep" ); // class 6 ADD_CLASS(2, 1, 0, 1, 0xFBCF66, "steep" ); // class 7 ADD_CLASS(2, 1, 0, 0, 0xF9C4D4, "steep" ); // class 8 ADD_CLASS(3, 1, 1, 1, 0x019E73, "moderate" ); // class 9 ADD_CLASS(3, 1, 1, 0, 0xC4B71D, "moderate" ); // class 10 ADD_CLASS(3, 1, 0, 1, 0x0072B1, "moderate" ); // class 11 ADD_CLASS(3, 1, 0, 0, 0xD7D700, "moderate" ); // class 12 ADD_CLASS(3, 0, 1, 1, 0xA0FD8E, "gentle" ); // class 13 ADD_CLASS(3, 0, 1, 0, 0xE9E915, "gentle" ); // class 14 ADD_CLASS(3, 0, 0, 1, 0x003B5B, "gentle" ); // class 15 ADD_CLASS(3, 0, 0, 0, 0xF2FEC0, "gentle" ); // class 16 break; } DataObject_Set_Parameter(pLandforms, pLUT); DataObject_Set_Parameter(pLandforms, "COLORS_TYPE", 1); // Color Classification Type: Lookup Table } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/mass_balance_index.h0000664000175000017500000001055112565125415030426 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: mass_balance_index.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // mass_balance_index.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__mass_balance_index_H #define HEADER_INCLUDED__mass_balance_index_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMass_Balance_Index : public CSG_Module_Grid { public: CMass_Balance_Index(void); virtual ~CMass_Balance_Index(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("R:Indices" )); } protected: virtual bool On_Execute (void); private: double Get_Transformed (double x, double t); bool Get_Morphometry (int x, int y, CSG_Grid *pDEM, double &Slope, double &Curve); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__mass_balance_index_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/wind_effect.cpp0000664000175000017500000005105112605406442027434 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wind_effect.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // wind_effect.cpp // // // // Copyright (C) 2008 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringeler@saga-gis.org // // // // contact: Andre Ringeler // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "wind_effect.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWind_Effect::CWind_Effect(void) { CSG_Parameter *pNode; Set_Name (_TL("Wind Effect (Windward / Leeward Index)")); Set_Author ("J.Boehner, A.Ringeler (c) 2008, O.Conrad (c) 2011"); Set_Description (_TW( "The 'Wind Effect' is a dimensionless index. Values below 1 indicate wind shadowed areas " "whereas values above 1 indicate areas exposed to wind, all with regard to the specified " "wind direction. Wind direction, i.e. the direction into which the wind blows, might be " "either constant or variying in space, if a wind direction grid is supplied.\n" "\nReferences:\n
    " "
    • " " Boehner, J., Antonic, O. (2009):" " Land-surface parameters specific to topo-climatology." " in: Hengl, T., Reuter, H. (Eds.): 'Geomorphometry - Concepts, Software, Applications'." " Developments in Soil Science, Volume 33, p.195-226, Elsevier." "
    • " " Gerlitz, L., Conrad, O., Böhner, J. (2015):" " Large scale atmospheric forcing and topographic modification of precipitation rates over High Asia – a neural network based approach." " Earth System Dynamics, 6, 1-21. doi:10.5194/esd-6-1-2015." "
    \n" )); Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); pNode = Parameters.Add_Grid( NULL , "DIR" , _TL("Wind Direction"), _TL("Direction into which the wind blows, starting with 0 for North and increasing clockwise."), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Choice( pNode , "DIR_UNITS" , _TL("Wind Direction Units"), _TL(""), CSG_String::Format("%s|%s|", _TL("radians"), _TL("degree") ), 0 ); pNode = Parameters.Add_Grid( NULL , "LEN" , _TL("Wind Speed"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "LEN_SCALE" , _TL("Scaling"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Grid( NULL , "EFFECT" , _TL("Wind Effect"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "AFH" , _TL("Effective Air Flow Heights"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "MAXDIST" , _TL("Search Distance [km]"), _TL(""), PARAMETER_TYPE_Double, 300.0, 0.0, true ); pNode = Parameters.Add_Value( NULL , "DIR_CONST" , _TL("Constant Wind Direction"), _TL("constant direction into the wind blows, given as degree"), PARAMETER_TYPE_Double, 135.0 ); Parameters.Add_Value( pNode , "OLDVER" , _TL("Old Version"), _TL("use old version for constant wind direction (no acceleration and averaging option)"), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "ACCEL" , _TL("Acceleration"), _TL(""), PARAMETER_TYPE_Double, 1.5, 1.0, true ); Parameters.Add_Value( NULL , "PYRAMIDS" , _TL("Elevation Averaging"), _TL("use more averaged elevations when looking at increasing distances"), PARAMETER_TYPE_Bool, false ); /* Parameters.Add_Value( NULL , "TRACE" , _TL("Precise Tracing"), _TL(""), PARAMETER_TYPE_Bool, false );/**/ } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CWind_Effect::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "DIR") ) { pParameters->Set_Enabled("DIR_CONST", pParameter->asGrid() == NULL); pParameters->Set_Enabled("DIR_UNITS", pParameter->asGrid() != NULL); pParameters->Set_Enabled("LEN" , pParameter->asGrid() != NULL); pParameters->Set_Enabled("OLDVER" , pParameter->asGrid() == NULL); pParameters->Set_Enabled("PYRAMIDS" , pParameters->Get_Parameter("OLDVER")->asBool() == false); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "LEN") ) { pParameters->Set_Enabled("LEN_SCALE", pParameter->asGrid() != NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "OLDVER") ) { pParameters->Set_Enabled("ACCEL" , pParameter->asBool() == false); pParameters->Set_Enabled("PYRAMIDS" , pParameter->asBool() == false); } return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWind_Effect::On_Execute(void) { CSG_Grid *pEffect, *pAFH; //----------------------------------------------------- m_pDEM = Parameters("DEM" )->asGrid(); pEffect = Parameters("EFFECT" )->asGrid(); pAFH = Parameters("AFH" )->asGrid(); m_maxDistance = Parameters("MAXDIST")->asDouble() * 1000.0; m_Acceleration = Parameters("ACCEL" )->asDouble(); // m_bTrace = Parameters("TRACE" )->asBool(); //----------------------------------------------------- CSG_Colors Colors(5); Colors.Set_Color(0, 255, 127, 63); Colors.Set_Color(1, 255, 255, 127); Colors.Set_Color(2, 255, 255, 255); Colors.Set_Color(3, 127, 127, 175); Colors.Set_Color(4, 0, 0, 100); DataObject_Set_Colors(pEffect, Colors); DataObject_Set_Colors(pAFH , Colors); //----------------------------------------------------- bool bOldVer = false; if( Parameters("DIR")->asGrid() == NULL ) { bOldVer = Parameters("OLDVER")->asBool(); m_Dir_Const.x = sin(Parameters("DIR_CONST")->asDouble() * M_DEG_TO_RAD); m_Dir_Const.y = cos(Parameters("DIR_CONST")->asDouble() * M_DEG_TO_RAD); if( fabs(m_Dir_Const.x) > fabs(m_Dir_Const.y) ) { m_Dir_Const.y /= fabs(m_Dir_Const.x); m_Dir_Const.x = m_Dir_Const.x < 0 ? -1 : 1; } else { m_Dir_Const.x /= fabs(m_Dir_Const.y); m_Dir_Const.y = m_Dir_Const.y < 0 ? -1 : 1; } } else { if( !m_DX.Create(*Get_System()) || !m_DY.Create(*Get_System()) ) { Error_Set(_TL("could not allocate sufficient memory")); return( false ); } CSG_Grid *pDir = Parameters("DIR")->asGrid(); CSG_Grid *pLen = Parameters("LEN")->asGrid(); double dRadians = Parameters("DIR_UNITS")->asInt() == 0 ? 1.0 : M_DEG_TO_RAD; double dScale = Parameters("LEN_SCALE")->asDouble(); #pragma omp parallel for for(int y=0; yis_NoData(x, y) ) { m_DX.Set_NoData(x, y); } else { double d = pLen ? (!pLen->is_NoData(x, y) ? dScale * pLen->asDouble(x, y) : 0.0) : 1.0; m_DX.Set_Value(x, y, d * sin(pDir->asDouble(x, y) * dRadians)); m_DY.Set_Value(x, y, d * cos(pDir->asDouble(x, y) * dRadians)); } } } } if( Parameters("PYRAMIDS")->asBool() && !bOldVer ) { m_DEM.Create(m_pDEM, 2.0); } //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { pEffect->Set_NoData(x, y); if( pAFH ) { pAFH->Set_NoData(x, y); } } else { double Luv, Luv_Lee, Lee; if( bOldVer ) { Get_Luv_Old(x, y, m_Dir_Const.x, m_Dir_Const.y, Luv); Get_Lee_Old(x, y, -m_Dir_Const.x, -m_Dir_Const.y, Luv_Lee, Lee); } else { Get_Luv(x, y, Luv); Get_Lee(x, y, Luv_Lee, Lee); } //----------------------------------------- if( pAFH ) { double d, z = m_pDEM->asDouble(x, y); d = 1.0 + (z + Lee != 0.0 ? (z - Lee) / (z + Lee) : 0.0); d = (Luv > Luv_Lee ? Luv - Luv_Lee : 0.0) + z * d*d / 2.0; pAFH->Set_Value(x, y, d < 0.0 ? 0.0 : d); } //----------------------------------------- Luv += Luv_Lee; Luv = Luv > 0.0 ? 1.0 + log(1.0 + Luv) : 1.0 / (1.0 + log(1.0 - Luv)); Lee = Lee > 0.0 ? sqrt(1.0 + log(1.0 + Lee)) : 1.0 / sqrt(1.0 + log(1.0 - Lee)); Luv = pow(Luv, 0.25); Lee = pow(Lee, 0.25); pEffect->Set_Value(x, y, Luv * Lee); } } } //----------------------------------------------------- m_DX .Destroy(); m_DY .Destroy(); m_DEM.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CWind_Effect::Get_Next(TSG_Point &Position, double Distance, bool bReverse) { if( Distance <= 0.0 ) { return( false ); } double dx, dy; if( !m_DX.is_Valid() ) { dx = m_Dir_Const.x; dy = m_Dir_Const.y; } else { /* if( m_bTrace ) { double d, dMove = bReverse ? -Get_Cellsize() : Get_Cellsize(); for(d=0.0; dGet_Extent(true).Contains(Position) ); } //--------------------------------------------------------- inline bool CWind_Effect::Get_Z(const TSG_Point &Position, double Distance, double &z) { if( m_DEM.Get_Count() > 0 ) { Distance /= 4.0; for(int i=0; iGet_Cellsize() ) { return( m_DEM.Get_Grid(i)->Get_Value(Position, z) ); } } } return( m_pDEM->Get_Value(Position, z) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CWind_Effect::Get_Luv(int x, int y, double &Sum_A) { double Weight_A = Sum_A = 0.0; if( m_pDEM->is_InGrid(x, y) ) { double z, iz, d, id, w; TSG_Point p; z = m_pDEM->asDouble(x, y); d = id = Get_Cellsize(); p = Get_System()->Get_Grid_to_World(x, y); while( id <= m_maxDistance && Get_Next(p, d, true) ) { if( Get_Z(p, d, iz) ) { Weight_A += w = d / id; Sum_A += w * atan2(z - iz, sqrt(id)); } d *= m_Acceleration; id += d; } if( Weight_A > 0.0 ) { Sum_A /= Weight_A; } } } //--------------------------------------------------------- void CWind_Effect::Get_Lee(int x, int y, double &Sum_A, double &Sum_B) { double Weight_A = Sum_A = 0.0; double Weight_B = Sum_B = 0.0; if( m_pDEM->is_InGrid(x, y) ) { double z, iz, d, id, w; TSG_Point p; z = m_pDEM->asDouble(x, y); d = id = Get_Cellsize(); p = Get_System()->Get_Grid_to_World(x, y); while( id <= m_maxDistance && Get_Next(p, d, true) ) { if( Get_Z(p, d, iz) ) { iz = atan2(z - iz, sqrt(id)); Weight_A += w = d / id; Sum_A += w * iz; Weight_B += w = d / log(1.0 + id); Sum_B += w * iz; } d *= m_Acceleration; id += d; } if( Weight_A > 0.0 ) { Sum_A /= Weight_A; } if( Weight_B > 0.0 ) { Sum_B /= Weight_B; } } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CWind_Effect::Get_Luv_Old(int x, int y, double dx, double dy, double &Sum_A) { double Weight_A = Sum_A = 0.0; double w, d = Get_Cellsize() * sqrt(dx*dx + dy*dy); for(double ix=x+dx+0.5, iy=y+dy+0.5, id=d, z=m_pDEM->asDouble(x, y); is_InGrid(x = (int)ix, y = (int)iy) && id<=m_maxDistance; ix+=dx, iy+=dy, id+=d) { if( !m_pDEM->is_NoData(x, y) ) { Weight_A += w = 1.0 / id; Sum_A += w * atan2(z - m_pDEM->asDouble(x, y), sqrt(id)); } } if( Weight_A > 0.0 ) { Sum_A /= Weight_A; } } //--------------------------------------------------------- void CWind_Effect::Get_Lee_Old(int x, int y, double dx, double dy, double &Sum_A, double &Sum_B) { double Weight_A = Sum_A = 0.0; double Weight_B = Sum_B = 0.0; double w, d = Get_Cellsize() * sqrt(dx*dx + dy*dy); for(double ix=x+dx+0.5, iy=y+dy+0.5, id=d, z=m_pDEM->asDouble(x, y); is_InGrid(x = (int)ix, y = (int)iy) && id<=m_maxDistance; ix+=dx, iy+=dy, id+=d) { if( !m_pDEM->is_NoData(x, y) ) { double iz = atan2(z - m_pDEM->asDouble(x, y), sqrt(id)); Weight_A += w = 1.0 / id; Sum_A += w * iz; Weight_B += w = 1.0 / log(1.0 + id); Sum_B += w * iz; } } if( Weight_A > 0.0 ) { Sum_A /= Weight_A; } if( Weight_B > 0.0 ) { Sum_B /= Weight_B; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWind_Exposition::CWind_Exposition(void) { Set_Name (_TL("Wind Exposition Index")); Set_Author ("J.Boehner, O.Conrad (c) 2015"); Set_Description (_TW( "This tool calculates the average 'Wind Effect Index' for all directions using an angular step. " "Like the 'Wind Effect Index' it is a dimensionless index. Values below 1 indicate wind shadowed areas " "whereas values above 1 indicate areas exposed to wind.\n" "\nReferences:\n" "
    • " " Boehner, J., Antonic, O. (2009):" " Land-surface parameters specific to topo-climatology." " in: Hengl, T., Reuter, H. (Eds.): 'Geomorphometry - Concepts, Software, Applications'." " Developments in Soil Science, Volume 33, p.195-226, Elsevier." "
    • " " Gerlitz, L., Conrad, O., Böhner, J. (2015):" " Large scale atmospheric forcing and topographic modification of precipitation rates over High Asia – a neural network based approach." " Earth System Dynamics, 6, 1-21. doi:10.5194/esd-6-1-2015." "
    \n" )); Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "EXPOSITION" , _TL("Wind Exposition"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "MAXDIST" , _TL("Search Distance [km]"), _TL(""), PARAMETER_TYPE_Double, 300.0, 0.0, true ); Parameters.Add_Value( NULL , "STEP" , _TL("Angular Step Size (Degree)"), _TL(""), PARAMETER_TYPE_Double, 15.0, 1.0, true, 45.0, true ); Parameters.Add_Value( NULL , "OLDVER" , _TL("Old Version"), _TL("use old version for constant wind direction (no acceleration and averaging option)"), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "ACCEL" , _TL("Acceleration"), _TL(""), PARAMETER_TYPE_Double, 1.5, 1.0, true ); Parameters.Add_Value( NULL , "PYRAMIDS" , _TL("Elevation Averaging"), _TL("use more averaged elevations when looking at increasing distances"), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CWind_Exposition::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "OLDVER") ) { pParameters->Set_Enabled("ACCEL" , pParameter->asBool() == false); pParameters->Set_Enabled("PYRAMIDS" , pParameter->asBool() == false); } return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWind_Exposition::On_Execute(void) { //----------------------------------------------------- CSG_Grid Exposition(*Get_System()), *pExposition = Parameters("EXPOSITION")->asGrid(); CSG_Colors Colors(5); Colors.Set_Color(0, 255, 127, 63); Colors.Set_Color(1, 255, 255, 127); Colors.Set_Color(2, 255, 255, 255); Colors.Set_Color(3, 127, 127, 175); Colors.Set_Color(4, 0, 0, 100); DataObject_Set_Colors(pExposition, Colors); //----------------------------------------------------- CWind_Effect Tool; Tool.Settings_Push(NULL); Tool.Set_Parameter("EFFECT" , &Exposition); Tool.Set_Parameter("DEM" , Parameters("DEM" )); Tool.Set_Parameter("MAXDIST" , Parameters("MAXDIST" )); Tool.Set_Parameter("OLDVER" , Parameters("OLDVER" )); Tool.Set_Parameter("ACCEL" , Parameters("ACCEL" )); Tool.Set_Parameter("PYRAMIDS" , Parameters("PYRAMIDS")); //----------------------------------------------------- int nDirections = 0; double dDirection = Parameters("STEP")->asDouble(); for(double Direction=0.0; Direction<360.0 && Process_Get_Okay(); Direction+=dDirection) { Process_Set_Text(CSG_String::Format("%s: %.1f", _TL("Direction"), Direction)); Tool.Set_Parameter("DIR_CONST", Direction); SG_UI_Msg_Lock(true); if( Tool.Execute() ) { SG_UI_Progress_Lock(true); if( nDirections++ == 0 ) { pExposition->Assign(&Exposition); } else { pExposition->Add (Exposition); } SG_UI_Progress_Lock(false); } SG_UI_Msg_Lock(false); } //----------------------------------------------------- if( nDirections > 0 ) { pExposition->Multiply(1.0 / (double)nDirections); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Convergence_Radius.cpp0000664000175000017500000002133112565125415030725 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Convergence_Radius.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Convergence_Radius.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "Convergence_Radius.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CConvergence_Radius::CConvergence_Radius(void) { Set_Name (_TL("Convergence Index (Search Radius)")); Set_Author (SG_T("O.Conrad (c) 2003")); Set_Description (_TW( "Reference:\n" "Koethe, R. & Lehmeier, F. (1996): SARA - System zur Automatischen Relief-Analyse. " "User Manual, 2. Edition [Dept. of Geography, University of Goettingen, unpublished]\n\n" )); Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CONVERGENCE" , _TL("Convergence Index"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Radius [Cells]"), _TL(""), PARAMETER_TYPE_Double, 10.0, 1.0, true ); Parameters.Add_Parameters( NULL , "WEIGHTING" , _TL("Weighting"), _TL("") )->asParameters()->Assign(m_Cells.Get_Weighting().Get_Parameters()); Parameters.Add_Value( NULL , "SLOPE" , _TL("Gradient"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL , "DIFFERENCE" , _TL("Difference"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("direction to the center cell"), _TL("center cell's aspect direction") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CConvergence_Radius::On_Execute(void) { int y; CSG_Grid *pConvergence; //----------------------------------------------------- m_pDTM = Parameters("ELEVATION") ->asGrid(); pConvergence = Parameters("CONVERGENCE") ->asGrid(); m_bSlope = Parameters("SLOPE") ->asBool(); m_bDifference = Parameters("DIFFERENCE") ->asInt() == 0; //----------------------------------------------------- m_Cells.Get_Weighting().Set_Parameters(Parameters("WEIGHTING")->asParameters()); if( !m_Cells.Set_Radius(Parameters("RADIUS")->asDouble()) ) { return( false ); } //----------------------------------------------------- DataObject_Set_Colors(pConvergence, 100, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- m_Direction.Create(m_Cells.Get_Count()); for(int i=0; i 0 ? M_PI_270 : M_PI_090); } } //----------------------------------------------------- m_Slope .Create(*Get_System(), SG_DATATYPE_Float); m_Aspect.Create(*Get_System(), SG_DATATYPE_Float); for(y=0; yis_InGrid(x, y) && m_pDTM->Get_Gradient(x, y, Slope, Aspect) && Aspect >= 0.0 ) { m_Slope .Set_Value(x, y, Slope); m_Aspect.Set_Value(x, y, Aspect); } else { m_Slope .Set_NoData(x, y); m_Aspect.Set_NoData(x, y); } } } //----------------------------------------------------- for(y=0; ySet_Value(x, y, d); } else { pConvergence->Set_NoData(x, y); } } } //----------------------------------------------------- m_Cells .Destroy(); m_Direction .Destroy(); m_Slope .Destroy(); m_Aspect .Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CConvergence_Radius::Get_Convergence(int x, int y, double &Convergence) { //----------------------------------------------------- if( !m_pDTM->is_InGrid(x, y) ) { return( false ); } //----------------------------------------------------- int i, ix, iy; double iDistance, iWeight, z; CSG_Simple_Statistics s; //----------------------------------------------------- for(i=0, z=m_pDTM->asDouble(x, y); i 0.0 && m_Aspect.is_InGrid(ix, iy) ) { double d, Direction = m_bDifference ? m_Direction[i] : m_Aspect.asDouble(x, y); d = fmod(m_Aspect.asDouble(ix, iy) - Direction, M_PI_360); if( d < -M_PI_180 ) { d += M_PI_360; } else if( d > M_PI_180 ) { d -= M_PI_360; } // s.Add_Value(m_bSlope ? fabs(d) * tan(m_Slope(ix, iy)) : fabs(d), iWeight); s.Add_Value(fabs(d), m_bSlope ? iWeight * tan(m_Slope(ix, iy)) : iWeight); } } //----------------------------------------------------- if( s.Get_Count() > 0 ) { Convergence = (s.Get_Mean() - M_PI_090) * 100.0 / M_PI_090; return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/RealArea.cpp0000664000175000017500000000362012565125415026635 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: RealArea.cpp 1348 2012-03-12 16:17:14Z oconrad $ *********************************************************/ /******************************************************************************* RealArea.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "RealArea.h" CRealArea::CRealArea(void) { Set_Name (_TL("Real Surface Area")); Set_Author (SG_T("V. Olaya (c) 2004")); Set_Description (_TW( "Calculates real (not projected) cell area" )); Parameters.Add_Grid(NULL, "DEM" , _TL("Elevation" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "AREA", _TL("Surface Area"), _TL(""), PARAMETER_OUTPUT); } bool CRealArea::On_Execute(void) { CSG_Grid *pDEM = Parameters("DEM" )->asGrid(); CSG_Grid *pArea = Parameters("AREA")->asGrid(); for(int y=0; yGet_Gradient(x, y, s, a) ) { pArea->Set_Value(x, y, Get_System()->Get_Cellarea() / cos(s)); } else { pArea->Set_NoData(x,y); } } } return( true ); } saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/fuzzy_landform_elements.h0000664000175000017500000001216512565125415031577 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: fuzzy_landform_elements.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // fuzzy_landform_elements.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__fuzzy_landform_elements_H #define HEADER_INCLUDED__fuzzy_landform_elements_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFuzzy_Landform_Elements : public CSG_Module_Grid { public: CFuzzy_Landform_Elements(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Terrain Classification" )); } protected: virtual bool On_Execute (void); private: bool m_bSlopeToDeg; double m_loSlope, m_hiSlope, m_loCurve, m_hiCurve; bool Get_Memberships (double Input[], double Membership[], int &Element, double &MaxMem, double &Entropy, double &CI); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__fuzzy_landform_elements_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/mass_balance_index.cpp0000664000175000017500000002416612565125415030770 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: mass_balance_index.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // mass_balance_index.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "mass_balance_index.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define MBI_LEVEL_2 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMass_Balance_Index::CMass_Balance_Index(void) { Set_Name (_TL("Mass Balance Index")); Set_Author (SG_T("(c) 2008 by O.Conrad")); Set_Description (_TW( "\n" "References:\n" "\n" "Friedrich, K. (1996): " "Digitale Reliefgliederungsverfahren zur Ableitung bodenkundlich relevanter Flaecheneinheiten. " "Frankfurter Geowissenschaftliche Arbeiten D 21, Frankfurt/M., " "online.\n" "\n" "Friedrich, K. (1998): " "Multivariate distance methods for geomorphographic relief classification. " "in Heinecke, H., Eckelmann, W., Thomasson, A., Jones, J., Montanarella, L., Buckley, B. (eds.): " "Land Inforamtion Systems - Developments for planning the sustainable use of land resources. " "European Soil Bureau - Research Report 4, EUR 17729 EN, Office for oficial publications of the European Communities, Ispra, pp. 259-266, " "online.\n" "\n" "Moeller, M., Volk, M., Friedrich, K., Lymburner, L. (2008): " "Placing soil-genesis and transport processes into a landscape context: A multiscale terrain-analysis approach. " "Journal of Plant Nutrition and Soil Science, 171, pp. 419-430, DOI: 10.1002/jpln.200625039\n" "\n" )); //----------------------------------------------------- #ifdef MBI_LEVEL_2 Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); #else Parameters.Add_Grid( NULL , "SLOPE" , _TL("Slope"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CURVE" , _TL("Curvature"), _TL(""), PARAMETER_INPUT ); #endif Parameters.Add_Grid( NULL , "HREL" , _TL("Vertical Distance to Channel Network"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "MBI" , _TL("Mass Balance Index"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "TSLOPE" , _TL("T Slope"), _TL(""), PARAMETER_TYPE_Double , 15.0, 0.0, true ); Parameters.Add_Value( NULL , "TCURVE" , _TL("T Curvature"), _TL(""), PARAMETER_TYPE_Double , 0.01, 0.0, true ); Parameters.Add_Value( NULL , "THREL" , _TL("T Vertical Distance to Channel Network"), _TL(""), PARAMETER_TYPE_Double , 15.0, 0.0, true ); } //--------------------------------------------------------- CMass_Balance_Index::~CMass_Balance_Index(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMass_Balance_Index::On_Execute(void) { int x, y; double TSlope, TCurve, THRel, fSlope, fCurve, fHRel; //----------------------------------------------------- #ifdef MBI_LEVEL_2 CSG_Grid *pDEM = Parameters("DEM") ->asGrid(); #else CSG_Grid *pSlope = Parameters("SLOPE") ->asGrid(); CSG_Grid *pCurve = Parameters("CURVE") ->asGrid(); #endif CSG_Grid *pHRel = Parameters("HREL") ->asGrid(); CSG_Grid *pMBI = Parameters("MBI") ->asGrid(); TSlope = Parameters("TSLOPE") ->asDouble(); TCurve = Parameters("TCURVE") ->asDouble(); THRel = Parameters("THREL") ->asDouble(); //----------------------------------------------------- DataObject_Set_Colors(pMBI, 100, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- for(y=0; yis_NoData(x, y)) && Get_Morphometry(x, y, pDEM, fSlope, fCurve) ) { #else if( (pHRel == NULL || !pHRel->is_NoData(x, y)) && !pSlope->is_NoData(x, y) && pCurve->is_NoData(x, y) ) { fSlope = pSlope->asDouble(x, y); fCurve = pCurve->asDouble(x, y); #endif if( pHRel ) { fHRel = pHRel ->asDouble(x, y); fSlope = Get_Transformed(fSlope, TSlope); fCurve = Get_Transformed(fCurve, TCurve); fHRel = Get_Transformed(fHRel , THRel); pMBI ->Set_Value(x, y, fCurve < 0.0 ? fCurve * (1.0 - fSlope) * (1.0 - fHRel) : fCurve * (1.0 + fSlope) * (1.0 + fHRel) ); } else { fSlope = Get_Transformed(fSlope, TSlope); fCurve = Get_Transformed(fCurve, TCurve); pMBI ->Set_Value(x, y, fCurve < 0.0 ? fCurve * (1.0 - fSlope) : fCurve * (1.0 + fSlope) ); } } else { pMBI ->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CMass_Balance_Index::Get_Transformed(double x, double t) { t += fabs(x); return( t > 0.0 ? x / t : 0.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMass_Balance_Index::Get_Morphometry(int x, int y, CSG_Grid *pDEM, double &Slope, double &Curve) { int i, ix, iy; double z, zm[8], G, H, E, D; if( pDEM->is_InGrid(x, y) ) { z = pDEM->asDouble(x, y); for(i=0; i<8; i++) { ix = pDEM->Get_System().Get_xTo(i, x); iy = pDEM->Get_System().Get_yTo(i, y); if( is_InGrid(ix, iy) ) { zm[i] = pDEM->asDouble(ix, iy) - z; } else { ix = pDEM->Get_System().Get_xFrom(i, x); iy = pDEM->Get_System().Get_yFrom(i, y); if( is_InGrid(ix, iy) ) { zm[i] = z - pDEM->asDouble(ix, iy); } else { zm[i] = 0.0; } } } D = ((zm[0] + zm[4]) / 2.0) / pDEM->Get_Cellarea(); E = ((zm[2] + zm[6]) / 2.0) / pDEM->Get_Cellarea(); // F = (zm[5] - zm[7] - zm[3] + zm[1]) / (4.0 * pDEM->Get_Cellarea()); G = (zm[0] - zm[4]) / (2.0 * pDEM->Get_Cellsize()); H = (zm[2] - zm[6]) / (2.0 * pDEM->Get_Cellsize()); Slope = atan(sqrt(G*G + H*H)); Curve = -2.0 * (E + D); return( true ); } Slope = 0.0; Curve = 0.0; return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/land_surface_temperature.h0000664000175000017500000001045212565125415031672 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: land_surface_temperature.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Land_Surface_Temperature.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: conrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Land_Surface_Temperature_H #define HEADER_INCLUDED__Land_Surface_Temperature_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLand_Surface_Temperature : public CSG_Module_Grid { public: CLand_Surface_Temperature(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Climate and Weather" )); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Land_Surface_Temperature_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/tc_iwahashi_pike.h0000664000175000017500000001447612570021310030115 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: tpi.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // tc_iwahashi_pike.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__tc_iwahashi_pike_H #define HEADER_INCLUDED__tc_iwahashi_pike_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTC_Parameter_Base : public CSG_Module_Grid { public: CTC_Parameter_Base(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); void On_Construction (void); bool Get_Parameter (CSG_Grid *pValues, CSG_Grid *pParameter); private: CSG_Grid_Cell_Addressor m_Kernel; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTC_Texture : public CTC_Parameter_Base { public: CTC_Texture(void); protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM; int Get_Noise (int x, int y, double Epsilon = 0.0); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTC_Convexity : public CTC_Parameter_Base { public: CTC_Convexity(void); protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM; int Get_Laplace (int x, int y, const double Kernel[2], int Type, double Epsilon); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTC_Classification : public CSG_Module_Grid { public: CTC_Classification(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Terrain Classification" )); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: double m_Mean_Slope, m_Mean_Convexity, m_Mean_Texture; CSG_Simple_Statistics m_Stat_Slope, m_Stat_Convexity, m_Stat_Texture; CSG_Grid *m_pSlope, *m_pConvexity, *m_pTexture; bool Get_Classes (void); int Get_Class (int Level, int x, int y, bool bLastLevel); void Set_LUT (CSG_Grid *pLandforms, int nLevels); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__tc_iwahashi_pike_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/param_scale.cpp0000664000175000017500000005244312565125415027437 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: param_scale.cpp 2435 2015-03-05 17:17:00Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // morphometry // // // //-------------------------------------------------------// // // // param_scale.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "param_scale.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define FLAT 1 #define PIT 2 #define CHANNEL 3 #define PASS 4 #define RIDGE 5 #define PEAK 6 //--------------------------------------------------------- #define LUT_SET_CLASS(id, name, color) { CSG_Table_Record *pR = pLUT->asTable()->Add_Record(); pR->Set_Value(0, color); pR->Set_Value(1, name); pR->Set_Value(3, id); pR->Set_Value(3, id); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CParam_Scale::CParam_Scale(void) { Set_Name (_TL("Morphometric Features")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Uses a multi-scale approach by fitting quadratic " "parameters to any size window (via least squares) " "to derive slope, aspect and curvatures (optional output) " "for subsequent classification of morphometric features " "(peaks, ridges, passes, channels, pits and planes). " "This is the method as proposed and implemented by Jo Wood " "(1996) in LandSerf and GRASS GIS (r.param.scale). " "\n\n" "Optional output is described in the following. " "Generalised elevation is the smoothed input DEM. " "Slope is the magnitude of maximum gradient. It is given " "for steepest slope angle and measured in degrees. " "Aspect is the direction of maximum gradient. " "Profile curvature is the curvature intersecting with the " "plane defined by the Z axis and maximum gradient direction. " "Positive values describe convex profile curvature, negative " "values concave profile. Plan curvature is the horizontal " "curvature, intersecting with the XY plane. Longitudinal " "curvature is the profile curvature intersecting with the " "plane defined by the surface normal and maximum gradient " "direction. Cross-sectional curvature is the tangential " "curvature intersecting with the plane defined by the surface " "normal and a tangent to the contour - perpendicular to " "maximum gradient direction. Minimum curvature is measured " "in direction perpendicular to the direction of of maximum " "curvature. The maximum curvature is measured in any direction. " "\n\n" "References:" "\n\n" "Wood, J. (1996): The Geomorphological characterisation of Digital Elevation Models. " "Diss., Department of Geography, University of Leicester, U.K. " "online." "\n\n" "Wood, J. (2009): Geomorphometry in LandSerf. " "In: Hengl, T. and Reuter, H.I. [Eds.]: Geomorphometry: Concepts, Software, Applications. " "Developments in Soil Science, Elsevier, Vol.33, 333-349." "\n\n" "LandSerf Homepage." )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid(NULL, "FEATURES" , _TL("Morphometric Features") , _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Byte); Parameters.Add_Grid(NULL, "ELEVATION", _TL("Generalized Surface") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "SLOPE" , _TL("Slope") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "ASPECT" , _TL("Aspect") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "PROFC" , _TL("Profile Curvature") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "PLANC" , _TL("Plan Curvature") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "LONGC" , _TL("Longitudinal Curvature") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "CROSC" , _TL("Cross-Sectional Curvature"), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "MAXIC" , _TL("Maximum Curvature") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "MINIC" , _TL("Minimum Curvature") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Value( NULL , "SIZE" , _TL("Scale Radius (Cells)"), _TL("Size of processing window (= 1 + 2 * radius) given as number of cells"), PARAMETER_TYPE_Int, 5, 1, true ); Parameters.Add_Value( NULL , "TOL_SLOPE" , _TL("Slope Tolerance"), _TL("Slope tolerance that defines a 'flat' surface (degrees)"), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Value( NULL , "TOL_CURVE" , _TL("Curvature Tolerance"), _TL("Curvature tolerance that defines 'planar' surface"), PARAMETER_TYPE_Double, 0.0001 ); Parameters.Add_Value( NULL , "EXPONENT" , _TL("Distance Weighting Exponent"), _TL("Exponent for distance weighting (0.0-4.0)"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 4.0, true ); Parameters.Add_Value( NULL , "ZSCALE" , _TL("Vertical Scaling"), _TL("Vertical scaling factor"), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Value( NULL , "CONSTRAIN" , _TL("Constrain"), _TL("Constrain model through central window cell"), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GRID_SET_NODATA(pGrid) if( pGrid ) pGrid->Set_NoData(x, y); #define GRID_SET_VALUE(pGrid, z) if( pGrid ) pGrid->Set_Value (x, y, z); //--------------------------------------------------------- bool CParam_Scale::On_Execute(void) { //----------------------------------------------------- bool bConstrain; int Index[6]; double zScale, Tol_Slope, Tol_Curve; CSG_Matrix Normal; //----------------------------------------------------- bConstrain = Parameters("CONSTRAIN")->asBool(); zScale = Parameters("ZSCALE" )->asDouble(); if( zScale <= 0.0 ) { zScale = 1.0; } Tol_Slope = Parameters("TOL_SLOPE")->asDouble(); Tol_Curve = Parameters("TOL_CURVE")->asDouble(); m_pDEM = Parameters("DEM" )->asGrid(); //----------------------------------------------------- CSG_Grid *pFeature = Parameters("FEATURES" )->asGrid(); CSG_Grid *pElevation = Parameters("ELEVATION")->asGrid(); CSG_Grid *pSlope = Parameters("SLOPE" )->asGrid(); CSG_Grid *pAspect = Parameters("ASPECT" )->asGrid(); CSG_Grid *pProfC = Parameters("PROFC" )->asGrid(); CSG_Grid *pPlanC = Parameters("PLANC" )->asGrid(); CSG_Grid *pLongC = Parameters("LONGC" )->asGrid(); CSG_Grid *pCrosC = Parameters("CROSC" )->asGrid(); CSG_Grid *pMiniC = Parameters("MINIC" )->asGrid(); CSG_Grid *pMaxiC = Parameters("MAXIC" )->asGrid(); //----------------------------------------------------- if( !Get_Weights() ) { return( false ); } if( !Get_Normal(Normal) ) { return( false ); } // To constrain the quadtratic through the central cell, ignore the calculations involving the // coefficient f. Since these are all in the last row and column of the matrix, simply redimension. if( !SG_Matrix_LU_Decomposition(bConstrain ? 5 : 6, Index, Normal.Get_Data()) ) { return( false ); } //----------------------------------------------------- for(int y=0; yasDouble(x, y)); // Add central elevation back GRID_SET_VALUE(pSlope , slope); GRID_SET_VALUE(pAspect , aspect); GRID_SET_VALUE(pProfC , profc); GRID_SET_VALUE(pPlanC , planc); GRID_SET_VALUE(pLongC , longc); GRID_SET_VALUE(pCrosC , crosc); GRID_SET_VALUE(pMiniC , minic); GRID_SET_VALUE(pMaxiC , maxic); } else { GRID_SET_NODATA(pFeature); GRID_SET_NODATA(pElevation); GRID_SET_NODATA(pSlope); GRID_SET_NODATA(pAspect); GRID_SET_NODATA(pProfC); GRID_SET_NODATA(pPlanC); GRID_SET_NODATA(pLongC); GRID_SET_NODATA(pCrosC); GRID_SET_NODATA(pMiniC); GRID_SET_NODATA(pMaxiC); } } } //----------------------------------------------------- CSG_Parameter *pLUT = DataObject_Get_Parameter(pFeature, "LUT"); if( pLUT && pLUT->asTable() ) { pLUT->asTable()->Del_Records(); LUT_SET_CLASS(FLAT , _TL("Planar" ), SG_GET_RGB(180, 180, 180)); LUT_SET_CLASS(PIT , _TL("Pit" ), SG_GET_RGB( 0, 0, 0)); LUT_SET_CLASS(CHANNEL, _TL("Channel" ), SG_GET_RGB( 0, 0, 255)); LUT_SET_CLASS(PASS , _TL("Pass (saddle)"), SG_GET_RGB( 0, 255, 0)); LUT_SET_CLASS(RIDGE , _TL("Ridge" ), SG_GET_RGB(255, 255, 0)); LUT_SET_CLASS(PEAK , _TL("Peak" ), SG_GET_RGB(255, 0, 0)); DataObject_Set_Parameter(pFeature, pLUT); DataObject_Set_Parameter(pFeature, "COLORS_TYPE", 1); // Color Classification Type: Lookup Table } //----------------------------------------------------- DataObject_Set_Colors(pSlope , 11, SG_COLORS_YELLOW_RED); DataObject_Set_Colors(pAspect, 11, SG_COLORS_ASPECT_3); DataObject_Set_Colors(pProfC , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(pPlanC , 11, SG_COLORS_RED_GREY_BLUE, false); DataObject_Set_Colors(pLongC , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(pCrosC , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(pMiniC , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(pMaxiC , 11, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CParam_Scale::Get_Parameters(double zScale, double coeff[6], double &elevation, double &slope, double &aspect, double &profc, double &planc, double &longc, double &crosc, double &minic, double &maxic) { // Quadratic function in the form of // z = ax^2 + by^2 + cxy + dx + ey + f // Rescale coefficients if a Z scaling is required. double a = coeff[0] * zScale; double b = coeff[1] * zScale; double c = coeff[2] * zScale; double d = coeff[3] * zScale; double e = coeff[4] * zScale; double f = coeff[5]; // f does not need rescaling as it is only used for smoothing. elevation = f; slope = M_RAD_TO_DEG * atan(sqrt((d * d) + (e * e))); aspect = M_RAD_TO_DEG * atan2(e, d); // W=0, N=+90, E=180, S=-90(=270) aspect = fmod(270.0 - aspect, 360.0); profc = !d && !e ? 0.0 : -2.0 * (a * d * d + b * e * e + c * e * d) / ((e * e + d * d) * pow(1.0 + d * d + e * e, 1.5)); planc = !d && !e ? 0.0 : 2.0 * (b * d * d + a * e * e - c * d * e) / pow(e * e + d * d, 1.5); longc = !d && !e ? 0.0 : -2.0 * (a * d * d + b * e * e + c * d * e) / (d * d + e * e); crosc = !d && !e ? 0.0 : -2.0 * (b * d * d + a * e * e - c * d * e) / (d * d + e * e); minic = -a - b - sqrt((a - b) * (a - b) + c * c); maxic = -a - b + sqrt((a - b) * (a - b) + c * c); return( true ); } //--------------------------------------------------------- inline int CParam_Scale::Get_Feature(double slope, double minic, double maxic, double crosc, double Tol_Slope, double Tol_Curve) { //----------------------------------------------------- // Feature | slope | crosc | maxic | minic // --------+-------+-------+-------+------- // Peak | 0 | # | +ve | +ve // Ridge | 0 | # | +ve | 0 // | +ve | +ve | # | # // Pass | 0 | # | +ve | -ve // Plane | 0 | # | 0 | 0 // | +ve | 0 | # | # // Channel | 0 | # | 0 | -ve // | +ve | -ve | # | # // Pit | 0 | # | -ve | -ve // // Table 5.3 Simplified feature classification criteria. // # indicates undefined, or not part of selection criteria. // http://www.geog.le.ac.uk/jwo/research/dem_char/thesis/05feat.htm //----------------------------------------------------- // Case 1: Surface is sloping. Cannot be a peak, pass or pit. // Therefore calculate the cross-sectional curvature to // characterise as channel, ridge or planar. if( slope > Tol_Slope ) { if( crosc > Tol_Curve ) { return( RIDGE ); } else if( crosc < -Tol_Curve ) { return( CHANNEL ); } else { return( FLAT ); } } //----------------------------------------------------- // Case 2: Surface has (approximately) vertical slope normal. // Feature can be of any type. else { if( maxic > Tol_Curve ) { if( minic > Tol_Curve ) { return( PEAK ); } else if( minic < -Tol_Curve ) { return( PASS ); } else { return( RIDGE ); } } else if( maxic < -Tol_Curve ) { if( minic < -Tol_Curve ) { return( PIT ); } } else { if( minic < -Tol_Curve ) { return( CHANNEL ); } else if( minic > Tol_Curve && minic < -Tol_Curve ) { return( FLAT ); } } } return( FLAT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // find_weight() Function to find the weightings matrix for the // observed cell values. // Uses an inverse distance function that can be // calibrated with an exponent (0= no decay, // 1=linear decay, 2=squared distance decay etc.) // V.1.1, Jo Wood, 11th May, 1995. //--------------------------------------------------------- bool CParam_Scale::Get_Weights(void) { if( (m_Radius = Parameters("SIZE")->asInt()) < 1 || !m_Weights.Create(1 + 2 * m_Radius, 1 + 2 * m_Radius) ) { return( false ); } double Exponent = Parameters("EXPONENT")->asDouble(); // Find inverse distance of all cells to centre. for(int y=0; yis_NoData(x, y) || x < m_Radius || x > Get_NX() - m_Radius || y < m_Radius || y > Get_NY() - m_Radius ) { return( false ); } //----------------------------------------------------- int ix, iy, jx, jy; double dx, dy, dz, z; Observed.Create(6); z = m_pDEM->asDouble(x, y); for(iy=0, jy=y-m_Radius, dy=-m_Radius*Get_Cellsize(); iyis_InGrid(jx, jy) ? m_pDEM->asDouble(jx, jy) - z : 0.0; if( dz ) { dz *= m_Weights[iy][ix]; Observed[0] += dz * dx * dx; Observed[1] += dz * dy * dy; Observed[2] += dz * dx * dy; Observed[3] += dz * dx; Observed[4] += dz * dy; if( !bConstrain ) // if constrained, should remain 0.0 { Observed[5] += dz; } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/SurfaceSpecificPoints.h0000664000175000017500000001174212565125415031065 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SurfaceSpecificPoints.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // SurfaceSpecificPoints.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__SurfaceSpecificPoints_H #define HEADER_INCLUDED__SurfaceSpecificPoints_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_morphometry_EXPORT CSurfaceSpecificPoints : public CSG_Module_Grid { public: CSurfaceSpecificPoints(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Terrain Classification" )); } protected: virtual bool On_Execute (void); private: void Do_MarkHighestNB (CSG_Grid *pGrid, CSG_Grid *pResult); void Do_OppositeNB (CSG_Grid *pGrid, CSG_Grid *pResult); void Do_FlowDirection (CSG_Grid *pGrid, CSG_Grid *pResult); void Do_FlowDirection2 (CSG_Grid *pGrid, CSG_Grid *pResult); void Do_PeuckerDouglas (CSG_Grid *pGrid, CSG_Grid *pResult, double Threshold); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__SurfaceSpecificPoints_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/param_scale.h0000664000175000017500000001120712565125415027075 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: param_scale.h 2435 2015-03-05 17:17:00Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // morphometry // // // //-------------------------------------------------------// // // // param_scale.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__param_scale_H #define HEADER_INCLUDED__param_scale_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CParam_Scale : public CSG_Module_Grid { public: CParam_Scale(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Terrain Classification" )); } protected: virtual bool On_Execute (void); private: int m_Radius; CSG_Matrix m_Weights; CSG_Grid *m_pDEM; bool Get_Parameters (double zScale, double coeff[6], double &elevation, double &slope, double &aspect, double &profc, double &planc, double &longc, double &crosc, double &minic, double &maxic); int Get_Feature (double slope, double minic, double maxic, double crosc, double Tol_Slope, double Tol_Curve); bool Get_Weights (void); bool Get_Normal (CSG_Matrix &Normal); bool Get_Observed (int x, int y, CSG_Vector &Observed, bool bConstrain); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__param_scale_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/air_flow_height.h0000664000175000017500000001170412565125415027762 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: air_flow_height.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Air_Flow_Height.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: conrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Air_Flow_Height_H #define HEADER_INCLUDED__Air_Flow_Height_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CAir_Flow_Height : public CSG_Module_Grid { public: CAir_Flow_Height(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Climate and Weather" )); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool m_bTrace; double m_maxDistance, m_Acceleration, m_dLee, m_dLuv; TSG_Point m_Dir_Const; CSG_Grid *m_pDEM, m_DX, m_DY; CSG_Grid_Pyramid m_DEM; bool Get_Next (TSG_Point &Position, double Distance, bool bReverse); bool Get_Z (const TSG_Point &Position, double Distance, double &z); void Get_Luv (int x, int y, double &Sum_A); void Get_Lee (int x, int y, double &Sum_A, double &Sum_B); void Get_Luv_Old (int x, int y, double dx, double dy, double &Sum_A); void Get_Lee_Old (int x, int y, double dx, double dy, double &Sum_A, double &Sum_B); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Air_Flow_Height_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/land_surface_temperature.cpp0000664000175000017500000001553312565125415032232 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: land_surface_temperature.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Land_Surface_Temperature.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: conrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "land_surface_temperature.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLand_Surface_Temperature::CLand_Surface_Temperature(void) { //----------------------------------------------------- Set_Name (_TL("Land Surface Temperature")); Set_Author (SG_T("(c) 2008 by O.Conrad")); Set_Description(_TW( "References:\n" "Bohner, J., Antonic, O. (2008): " "'Land-suface parameters specific to topo-climatology'. " "in: Hengl, T., Reuter, H. (Eds.): 'Geomorphometry - Concepts, Software, Applications', in press\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation [m]"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SWR" , _TL("Short Wave Radiation [kW/m2]"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "LAI" , _TL("Leaf Area Index"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "LST" , _TL("Land Surface Temperature [Deg.Celsius]"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "Z_REFERENCE" , _TL("Elevation at Reference Station [m]"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( NULL , "T_REFERENCE" , _TL("Temperature at Reference Station [Deg.Celsius]"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( NULL , "T_GRADIENT" , _TL("Temperature Gradient [Deg.Celsius/km]"), _TL(""), PARAMETER_TYPE_Double , 6.5 ); Parameters.Add_Value( NULL , "C_FACTOR" , _TL("C Factor"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLand_Surface_Temperature::On_Execute(void) { double Z_reference, T_reference, T_gradient, C_Factor, LAI_max, Z, SWR, LAI, LST; CSG_Grid *pDEM, *pSWR, *pLAI, *pLST; //----------------------------------------------------- pDEM = Parameters("DEM") ->asGrid(); pSWR = Parameters("SWR") ->asGrid(); pLAI = Parameters("LAI") ->asGrid(); pLST = Parameters("LST") ->asGrid(); Z_reference = Parameters("Z_REFERENCE") ->asDouble(); T_reference = Parameters("T_REFERENCE") ->asDouble(); T_gradient = Parameters("T_GRADIENT") ->asDouble(); C_Factor = Parameters("C_FACTOR") ->asDouble(); LAI_max = pLAI->Get_ZMax(); //----------------------------------------------------- if( LAI_max > 0.0 ) { for(int y=0; yis_NoData(x, y) || pSWR->is_NoData(x, y) || pLAI->is_NoData(x, y) || (SWR = pSWR->asDouble(x, y)) <= 0.0 ) { pLST->Set_NoData(x, y); } else { Z = pDEM->asDouble(x, y); SWR = pSWR->asDouble(x, y); LAI = pLAI->asDouble(x, y); LST = T_reference - (T_gradient * (Z - Z_reference)) / 1000.0 + C_Factor * (SWR - 1.0 / SWR) * (1.0 - LAI / LAI_max); pLST->Set_Value(x, y, LST); } } } return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Morphometry.h0000664000175000017500000001270312565125415027155 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Morphometry.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Morphometry.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Morphometry_H #define HEADER_INCLUDED__Morphometry_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_morphometry_EXPORT CMorphometry : public CSG_Module_Grid { public: CMorphometry(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_Unit_Slope, m_Unit_Aspect; CSG_Grid *m_pDTM, *m_pSlope, *m_pAspect, *m_pC_Gene, *m_pC_Prof, *m_pC_Plan, *m_pC_Tang, *m_pC_Long, *m_pC_Cros, *m_pC_Mini, *m_pC_Maxi, *m_pC_Tota, *m_pC_Roto; //----------------------------------------------------- void Get_SubMatrix3x3 (int x, int y, double Z[ 9], int Orientation = 0); void Get_SubMatrix5x5 (int x, int y, double Z[25]); //----------------------------------------------------- void Set_NoData (int x, int y); void Set_Gradient (int x, int y, double Slope, double Aspect); void Set_From_Polynom (int x, int y, double r, double t, double s, double p, double q); //----------------------------------------------------- void Set_MaximumSlope (int x, int y); void Set_Tarboton (int x, int y); void Set_LeastSquare (int x, int y); void Set_Evans (int x, int y); void Set_Heerdegen (int x, int y); void Set_BRM (int x, int y); void Set_Zevenbergen (int x, int y); void Set_Haralick (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Morphometry_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/relative_heights.cpp0000664000175000017500000011411412565125415030510 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: relative_heights.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Relative_Heights.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: conrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "relative_heights.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CRelative_Heights::CRelative_Heights(void) { //----------------------------------------------------- Set_Name (_TL("Relative Heights and Slope Positions")); Set_Author (SG_T("J.Boehner, O.Conrad (c) 2008")); Set_Description (_TW( "The module allows one to calculate several terrain indices from a digital " "elevation model.\n\n" "General information on the computational concept can be found in:\n" "- Boehner, J. and Selige, T. (2006): Spatial prediction of soil attributes using " "terrain analysis and climate regionalisation. In: Boehner, J., McCloy, K.R., Strobl, J. " "[Ed.]: SAGA - Analysis and Modelling Applications, Goettinger Geographische Abhandlungen, " "Goettingen: 13-28. " "(pdf)\n\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "HO" , _TL("Slope Height"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "HU" , _TL("Valley Depth"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "NH" , _TL("Normalized Height"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "SH" , _TL("Standardized Height"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "MS" , _TL("Mid-Slope Positon"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "W" , _TL("w"), _TW("The parameter weights the influence of catchment size on relative elevation " "(inversely proportional)."), PARAMETER_TYPE_Double , 0.5, 0.0, true ); Parameters.Add_Value( NULL , "T" , _TL("t"), _TW("The parameter controls the amount by which a maximum in the neighbourhood " "of a cell is taken over into the cell (considering the local slope between the cells). " "The smaller 't' and/or the smaller the slope, the more of the maximum value " "is taken over into the cell. This results in a greater generalization/smoothing " "of the result. The greater 't' and/or the higher the slope, the less is taken " "over into the cell and the result will show a more irregular pattern caused " "by small changes in elevation between the cells."), PARAMETER_TYPE_Double , 10.0, 0.0, true ); Parameters.Add_Value( NULL , "E" , _TL("e"), _TL("The parameter controls the position of relative height maxima as a function of slope."), PARAMETER_TYPE_Double , 2.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CRelative_Heights::On_Execute(void) { //----------------------------------------------------- CSG_Grid *pDEM = Parameters("DEM")->asGrid(); CSG_Grid *pHO = Parameters("HO" )->asGrid(); CSG_Grid *pHU = Parameters("HU" )->asGrid(); double w = Parameters("W")->asDouble(); double t = Parameters("T")->asDouble(); double e = Parameters("E")->asDouble(); if( !pDEM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } //----------------------------------------------------- Message_Add(_TL("Pass 1")); Get_Heights(pDEM, pHO, true , w, t, e); Message_Add(_TL("Pass 2")); Get_Heights(pDEM, pHU, false, w, t, e); Get_Results(pDEM, pHO, pHU); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CRelative_Heights::Get_Heights(CSG_Grid *pDEM, CSG_Grid *pH, bool bInverse, double w, double t, double e) { CSG_Grid Inverse; if( bInverse ) { Inverse.Create(*pDEM); Inverse.Invert(); pDEM = &Inverse; } //----------------------------------------------------- return( Get_Heights_Catchment(pDEM, pH, w) && Get_Heights_Modified (pDEM, pH, t, e) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CRelative_Heights::Get_Heights_Catchment(CSG_Grid *pDEM, CSG_Grid *pH, double Weight) { const double MFD_Converge = 1.1; int x, y, i, ix, iy; double z, d, dz[8], dzSum, c, w, h; CSG_Grid C, W; //----------------------------------------------------- Process_Set_Text(_TL("Relative heights calculation...")); C .Create(*Get_System()); W .Create(*Get_System()); C .Assign(Get_System()->Get_Cellarea()); W .Assign(0.0); pH->Assign(0.0); //----------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y, true, false) || pDEM->is_NoData(x, y) ) { pH->Set_NoData(x, y); } else { z = pDEM->asDouble(x, y); c = C .asDouble(x, y); w = W .asDouble(x, y) + pow(1.0 / c, Weight); //{W[p] = (1/C[p])^w;} h = pH ->asDouble(x, y) + pow(1.0 / c, Weight) * z; //{H[p] = (1/C[p])^w * M[p];} pH->Set_Value(x, y, h / w - z); //{H[p] = -1 * (M[p] - H[p]/W[p]);} for(i=0, dzSum=0.0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( pDEM->is_InGrid(ix, iy) && (d = z - pDEM->asDouble(ix, iy)) > 0.0 ) { dzSum += (dz[i] = pow(atan(d / Get_Length(i)), MFD_Converge)); } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { for(i=0; i<8; i++) { if( dz[i] > 0.0 ) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); d = dz[i] / dzSum; C .Add_Value(ix, iy, d * c); W .Add_Value(ix, iy, d * w); //{W[p] = W[p] + W[p+pul] * UL[p] + W[p+pl] * LL[p] + W[p+pol] * OL[p] + W[p+po] * OO[p] + W[p+por] * OR[p] + W[p+pr] * RR[p] + W[p+pur] * UR[p] + W[p+pu] * UU[p]; gefunden = 1;} pH->Add_Value(ix, iy, d * h); //{H[p] = H[p] + H[p+pul] * UL[p] + H[p+pl] * LL[p] + H[p+pol] * OL[p] + H[p+po] * OO[p] + H[p+por] * OR[p] + H[p+pr] * RR[p] + H[p+pur] * UR[p] + H[p+pu] * UU[p]; gefunden = 1;} } } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // in den folgenden drei Schritten werden Maxima der // relativen Höhe H in Abhängigkeit der Neigung gesaugt. // Der e-Parameter steuert die stärke der Maximum-Streckung //--------------------------------------------------------- bool CRelative_Heights::Get_Heights_Modified(CSG_Grid *pDEM, CSG_Grid *pH, double t, double e) { int y; CSG_Grid H, H_Last, T; //----------------------------------------------------- Process_Set_Text(_TL("Modify: pre-processing...")); T.Create(pH); for(y=0; yis_NoData(x, y) && !pDEM->is_NoData(x, y) && pDEM->Get_Gradient(x, y, z, d) ) { pH->Set_Value(x, y, d = pow(pH->asDouble(x, y), e)); // {X[p] = H[p]^e;} z = pow(t, z); z = pow(1.0 / z, exp(z)); T.Set_Value(x, y, z); } else { T.Set_NoData(x, y); } } } H .Create(*pH); H_Last.Create(*pH); //----------------------------------------------------- int nChanges = 1; for(int Iteration=1; nChanges && Process_Get_Okay(); Iteration++) { nChanges = 0; #pragma omp parallel for private(y) reduction(+:nChanges) for(y=0; y H.asDouble(x, y) ) { nChanges++; H.Set_Value(x, y, z); } } } } if( nChanges > 0 ) { nChanges = 0; #pragma omp parallel for private(y) reduction(+:nChanges) for(y=0; y 0)"), Iteration, nChanges)); } //----------------------------------------------------- Process_Set_Text(_TL("Modify: post-processing...")); for(y=0; ySet_NoData(x, y); } else { for(iy=y-1, bRecalculate=false; iy<=y+1 && !bRecalculate; iy++) { for(ix=x-1; ix<=x+1 && !bRecalculate; ix++) { if( H.is_InGrid(ix, iy) && pH->is_InGrid(ix, iy) && H.asDouble(ix, iy) > pH->asDouble(ix, iy) ) { bRecalculate = true; } } } if( bRecalculate ) { for(iy=y-1, z=0.0, n=0; iy<=y+1; iy++) { for(ix=x-1; ix<=x+1; ix++) { if( H.is_InGrid(ix, iy) ) { n++; z += H.asDouble(ix, iy); } } } z = z / (double)n; } else { z = H.asDouble(x, y); } pH->Set_Value(x, y, pow(z, 1.0 / e)); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- double CRelative_Heights::Get_Local_Maximum(CSG_Grid *pGrid, int x, int y) { if( pGrid->is_InGrid(x, y) ) { double z = pGrid->asDouble(x, y); for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( pGrid->is_InGrid(ix, iy) && pGrid->asDouble(ix, iy) > z ) { z = pGrid->asDouble(ix, iy); } } return( z ); } return( 0.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // auf Grundlage von HO und HU wird die Normierte Höhe // (NH) mit Höhenwerten zwischen minimal 0 (=unten) und // maximal 1 (= oben) wie beim NDVI bestimmt. Die // Standardisierte Höhe SH streckt das Relief auf ein // Höhenspektrum zwischen theoretisch 0 (=unten) und // dem Maximum der jeweiligen Scheitelbereiche, so dass // die ursprüngliche Reliefenergie erhalten bleibt. // Selbstverständlich muss für Anwendungen überprüft // werden, ob und welche relativen Höhen (HU, HO, SH) // logarithmiert dargestellt werden. Als Beispiel ist // die Standardisierte Höhe logarithmiert berechnet (SHL) //--------------------------------------------------------- bool CRelative_Heights::Get_Results(CSG_Grid *pDEM, CSG_Grid *pHO, CSG_Grid *pHU) { Process_Set_Text(_TL("Final processing...")); CSG_Grid *pNH = Parameters("NH") ->asGrid(); CSG_Grid *pSH = Parameters("SH") ->asGrid(); CSG_Grid *pMS = Parameters("MS") ->asGrid(); for(int y=0; yis_NoData(x, y) || pHO->is_NoData(x, y) || pHU->is_NoData(x, y) || ((ho = pHO->asDouble(x, y)) + (hu = pHU->asDouble(x, y))) == 0.0 ) { pNH->Set_NoData(x, y); pSH->Set_NoData(x, y); pMS->Set_NoData(x, y); } else { nh = 0.5 * (1.0 + (ho - hu) / (ho + hu)); pNH->Set_Value(x, y, nh); pSH->Set_Value(x, y, nh * (pDEM->asDouble(x, y) - pDEM->Get_ZMin()) + pDEM->Get_ZMin()); //, nh * pDEM->asDouble(x, y)); pMS->Set_Value(x, y, fabs(2.0 * nh - 1.0)); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // The original BSL script by J.Böhner //--------------------------------------------------------- /* Matrix Loop, O("sch-hoe.grd"), N("sch-nei.grd"), M, R, UL, LL, OL, OO, OR, RR, UR, UU, X, Y, Z, C, W, H, HO, HU, NH, SH, SHL; Point ploop, p, pul, pu, pur, pl, pr, pol, po, por; Float w, e, wul, wll, wol, woo, wor, wrr, wur, wuu; Integer t, h, i, j, k, l, m, n, o, gefunden; w = 0.5; e = 2; t = 10; pul.x = -1; pul.y = -1; pu.x = 0; pu.y = -1; pur.x = 1; pur.y = -1; pl.x = -1; pl.y = 0; pr.x = 1; pr.y = 0; pol.x = -1; pol.y = 1; po.x = 0; po.y = 1; por.x = 1; por.y = 1; M = O; R = O; UL = O; LL = O; OL = O; OO = O; OR = O; RR = O; UR = O; UU = O; X = O; Y = O; Z = O; C = O; W = O; H = O; HO = O; HU = O; NH = O; SH = O; SHL = O; Loop.xanz = 100000; Loop.yanz = 1; h = 0; i = 0; j = 0; k = 0; l = 0; m = 0; n = 0; o = 0; // Das gesamte Verfahren besteht aus zwei identischen Schritten zur Bestimmung von Höhe über Kulmination (HO) und Höhe unter Kulmination (HU). Für HO wird das DGM zunächst umgedreht // foreach p in M do {M[p] = -1 * O[p];} // hier wird eine Hilfsmatrix X erzeugt, die in der folgenden Schleife fafür sorgt, dass noch nicht attributisierte Rasterzellen in Ihrer Position identifiziert werden können // foreach p in X do { if (p.x == 0 || p.x == M.xanz - 1 || p.y == 0 || p.y == M.yanz - 1) {X[p] = -10000;} else {X[p] = M[p];} } // hier wird eine Matrix R erzeugt, die ausgehend von lokalen Maxima fortlaufend Rangplatzziffernerzeugt // foreach ploop in Loop do { ploop.x = 1; h = h +1; gefunden = 0; foreach p in X do { if (X[p] == max9(p, X) && X[p] > -10000) {X[p] = -10000; R[p] = h; gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } setRandN(R); // hier wird eine Hilfsmatrix R erzeugt, die Rangplatzziffern am Rand duch 0 ersetzt // foreach p in R do { if (p.x == 0 || p.x == M.xanz - 1 || p.y == 0 || p.y == M.yanz - 1) {R[p] = 0;} else {R[p] = R[p];} } // hier wird eine Matrix Z erzeugt, die die positiven Winkel zu den 8 Nachbarzellen aufsummiert // foreach p in Z do { if(p.x == 0 && p.y == 0) { if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((woo + wor + wrr) == 0) {Z[p] = 0;} else {Z[p] = woo + wor + wrr;} } else { if(p.x == 0 && p.y == (M.yanz - 1)) { if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = wrr + wur + wuu;} } else { if(p.x == M.xanz - 1 && p.y == M.yanz - 1) { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wuu;} } else { if(p.x == M.xanz - 1 && p.y == 0) { if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((wll + wol + woo) == 0) {Z[p] = 0;} else {Z[p] = wll + wol + woo;} } else { if(p.x == 0) { if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((woo + wor + wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = woo + wor + wrr + wur + wuu;} } else { if(p.x == M.xanz - 1) { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wol + woo + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wol + woo + wuu;} } else { if(p.y == 0) { if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((wll + wol + woo + wor + wrr) == 0) {Z[p] = 0;} else {Z[p] = wll + wol + woo + wor + wrr;} } else { if(p.y == M.yanz - 1) { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wrr + wur + wuu;} } else { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wol + woo + wor + wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wol + woo + wor + wrr + wur + wuu;} } }}}}}}}} // hier werden Grids UL bis UU (im Uhrzeigersinn) erzeugt, die angeben, welchen Anteil des Inhalts einer benachbarten Rasterzelle in die Zielrasterzelle (zentrale Rasterzelle im 9er Feld) übergen wird // foreach p in UL do { if (p.x == 0 || p.y == 0) {UL[p] = 0;} else { if((M[p] - M[p+pul]) < 0 && Z[p+pul] > 0) {UL[p] = (atan((M[p+pul] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+pul];} else {UL[p] = 0;} } } foreach p in LL do { if (p.x == 0) {LL[p] = 0;} else { if((M[p] - M[p+pl]) < 0 && Z[p+pl] > 0) {LL[p] = (atan((M[p+pl] - M[p])/M.dxy))/Z[p+pl];} else {LL[p] = 0;} } } foreach p in OL do { if (p.x == 0 || p.y == M.yanz - 1) {OL[p] = 0;} else { if((M[p] - M[p+pol]) < 0 && Z[p+pol] > 0) {OL[p] = (atan((M[p+pol] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+pol];} else {OL[p] = 0;} } } foreach p in OO do { if (p.y == M.yanz - 1) {OO[p] = 0;} else { if((M[p] - M[p+po]) < 0 && Z[p+po] > 0) {OO[p] = (atan((M[p+po] - M[p])/M.dxy))/Z[p+po];} else {OO[p] = 0;} } } foreach p in OR do { if (p.x == M.xanz - 1 || p.y == M.yanz - 1) {OR[p] = 0;} else { if((M[p] - M[p+por]) < 0 && Z[p+por] > 0) {OR[p] = (atan((M[p+por] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+por];} else {OR[p] = 0;} } } foreach p in RR do { if (p.x == M.xanz - 1) {RR[p] = 0;} else { if((M[p] - M[p+pr]) < 0 && Z[p+pr] > 0) {RR[p] = (atan((M[p+pr] - M[p])/M.dxy))/Z[p+pr];} else {RR[p] = 0;} } } foreach p in UR do { if (p.x == M.xanz - 1 || p.y == 0) {UR[p] = 0;} else { if((M[p] - M[p+pur]) < 0 && Z[p+pur] > 0) {UR[p] = (atan((M[p+pur] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+pur];} else {UR[p] = 0;} } } foreach p in UU do { if (p.y == 0) {UU[p] = 0;} else { if((M[p] - M[p+pu]) < 0 && Z[p+pu] > 0) {UU[p] = (atan((M[p+pu] - M[p])/M.dxy))/Z[p+pu];} else {UU[p] = 0;} } } // in den folgenden drei Schritten wird nach der "multiple flow methode" die Einzugsgebietsgröße C ermittelt // foreach p in Z do {Z[p] = 1;} foreach ploop in Loop do { ploop.x = 1; i = i +1; gefunden = 0; foreach p in Z do { if (R[p] == i) {Z[p] = 1 + Z[p+pul] * UL[p] + Z[p+pl] * LL[p] + Z[p+pol] * OL[p] + Z[p+po] * OO[p] + Z[p+por] * OR[p] + Z[p+pr] * RR[p] + Z[p+pur] * UR[p] + Z[p+pu] * UU[p]; gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } setRandN(Z); foreach p in C do {C[p] = Z[p] * M.dxy^2;} // in den folgenden zwei Schritten werden Gewichte umgekehrt-proportional zur Einzugsgebietsgröße nach der multiple flow methode aufsummiert. Der w-parameter steuert die stärke der Gewichtung // foreach p in W do {W[p] = (1/C[p])^w;} foreach ploop in Loop do { ploop.x = 1; k = k +1; gefunden = 0; foreach p in W do { if (R[p] == k) {W[p] = W[p] + W[p+pul] * UL[p] + W[p+pl] * LL[p] + W[p+pol] * OL[p] + W[p+po] * OO[p] + W[p+por] * OR[p] + W[p+pr] * RR[p] + W[p+pur] * UR[p] + W[p+pu] * UU[p]; gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } setRandN(W); // in den folgenden zwei Schritten werden Höhenwerte und Gewichte nach der multiple flow methode in der Matrix H aufsummiert, wobei lokale Maxima im Einzugsgebiet am stärksten in H eingehen. Der w-Parameter steuert die Stärke der Maximumgewichtung // foreach p in H do {H[p] = M[p] * (1/C[p])^w;} foreach ploop in Loop do { ploop.x = 1; l = l +1; gefunden = 0; foreach p in H do { if (R[p] == l) {H[p] = H[p] + H[p+pul] * UL[p] + H[p+pl] * LL[p] + H[p+pol] * OL[p] + H[p+po] * OO[p] + H[p+por] * OR[p] + H[p+pr] * RR[p] + H[p+pur] * UR[p] + H[p+pu] * UU[p]; gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } setRandN(H); // im folgenden Schritt wird eine relative Höhe H über dem gewichteten arithmetischen Mittel der Einzugsgebietsgröße bestimmt // foreach p in H do { if (isRand(p, M) == 0) {H[p] = -1 * (M[p] - H[p]/W[p]);} } setRandN(H); // in den folgenden drei Schritten werden Maxima der relativen Höhe H in Abhängigkeit der Neigung gesaugt. Der e-Parameter steuert die stärke der Maximum-Streckung // foreach p in X do {X[p] = H[p]^e;} foreach ploop in Loop do { ploop.x = 1; m = m +1; gefunden = 0; foreach p in X do { if ((((1/t^N[p])^exp(t^N[p])) * max9(p, X)) > X[p]) {X[p] = (((1/t^N[p])^exp(t^N[p])) * max9(p, X)); gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } foreach p in HO do { if (isRand(p, M) == 0) { if(H[p]^e < X[p] || H[p+pul]^e < X[p+pul] || H[p+pl]^e < X[p+pl] || H[p+pol]^e < X[p+pol] || H[p+po]^e < X[p+po] || H[p+por]^e < X[p+por] || H[p+pr]^e < X[p+pr] || H[p+pur]^e < X[p+pur] || H[p+pu]^e < X[p+pu]) {HO[p] = ((X[p] + X[p+pul] + X[p+pu] + X[p+pur] + X[p+pl] + X[p+pr] + X[p+pol] + X[p+po] + X[p+por])/9)^(1/e);} else {HO[p] = X[p]^(1/e);} } } setRandN(HO); foreach p in Z do { h = 0; i = 0; j = 0; k = 0; l = 0; m = 0; } // hier wird das DGM nicht umgedreht // foreach p in M do {M[p] = O[p];} // hier wird eine Hilfsmatrix X erzeugt, die in der folgenden Schleife fafür sorgt, dass noch nicht attributisierte Rasterzellen in Ihrer Position identifiziert werden können // foreach p in X do { if (p.x == 0 || p.x == M.xanz - 1 || p.y == 0 || p.y == M.yanz - 1) {X[p] = -10000;} else {X[p] = M[p];} } // hier wird eine Matrix R erzeugt, die ausgehend von lokalen Maxima fortlaufend Rangplatzziffernerzeugt // foreach ploop in Loop do { ploop.x = 1; h = h +1; gefunden = 0; foreach p in X do { if (X[p] == max9(p, X) && X[p] > -10000) {X[p] = -10000; R[p] = h; gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } setRandN(R); // hier wird eine Hilfsmatrix R erzeugt, die Rangplatzziffern am Rand duch 0 ersetzt // foreach p in R do { if (p.x == 0 || p.x == M.xanz - 1 || p.y == 0 || p.y == M.yanz - 1) {R[p] = 0;} else {R[p] = R[p];} } // hier wird eine Matrix Z erzeugt, die die positiven Winkel zu den 8 Nachbarzellen aufsummiert // foreach p in Z do { if(p.x == 0 && p.y == 0) { if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((woo + wor + wrr) == 0) {Z[p] = 0;} else {Z[p] = woo + wor + wrr;} } else { if(p.x == 0 && p.y == (M.yanz - 1)) { if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = wrr + wur + wuu;} } else { if(p.x == M.xanz - 1 && p.y == M.yanz - 1) { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wuu;} } else { if(p.x == M.xanz - 1 && p.y == 0) { if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((wll + wol + woo) == 0) {Z[p] = 0;} else {Z[p] = wll + wol + woo;} } else { if(p.x == 0) { if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((woo + wor + wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = woo + wor + wrr + wur + wuu;} } else { if(p.x == M.xanz - 1) { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wol + woo + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wol + woo + wuu;} } else { if(p.y == 0) { if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((wll + wol + woo + wor + wrr) == 0) {Z[p] = 0;} else {Z[p] = wll + wol + woo + wor + wrr;} } else { if(p.y == M.yanz - 1) { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wrr + wur + wuu;} } else { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wol + woo + wor + wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wol + woo + wor + wrr + wur + wuu;} } }}}}}}}} // hier werden Grids UL bis UU (im Uhrzeigersinn) erzeugt, die angeben, welchen Anteil des Inhalts einer benachbarten Rasterzelle in die Zielrasterzelle (zentrale Rasterzelle im 9er Feld) übergen wird // foreach p in UL do { if (p.x == 0 || p.y == 0) {UL[p] = 0;} else { if((M[p] - M[p+pul]) < 0 && Z[p+pul] > 0) {UL[p] = (atan((M[p+pul] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+pul];} else {UL[p] = 0;} } } foreach p in LL do { if (p.x == 0) {LL[p] = 0;} else { if((M[p] - M[p+pl]) < 0 && Z[p+pl] > 0) {LL[p] = (atan((M[p+pl] - M[p])/M.dxy))/Z[p+pl];} else {LL[p] = 0;} } } foreach p in OL do { if (p.x == 0 || p.y == M.yanz - 1) {OL[p] = 0;} else { if((M[p] - M[p+pol]) < 0 && Z[p+pol] > 0) {OL[p] = (atan((M[p+pol] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+pol];} else {OL[p] = 0;} } } foreach p in OO do { if (p.y == M.yanz - 1) {OO[p] = 0;} else { if((M[p] - M[p+po]) < 0 && Z[p+po] > 0) {OO[p] = (atan((M[p+po] - M[p])/M.dxy))/Z[p+po];} else {OO[p] = 0;} } } foreach p in OR do { if (p.x == M.xanz - 1 || p.y == M.yanz - 1) {OR[p] = 0;} else { if((M[p] - M[p+por]) < 0 && Z[p+por] > 0) {OR[p] = (atan((M[p+por] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+por];} else {OR[p] = 0;} } } foreach p in RR do { if (p.x == M.xanz - 1) {RR[p] = 0;} else { if((M[p] - M[p+pr]) < 0 && Z[p+pr] > 0) {RR[p] = (atan((M[p+pr] - M[p])/M.dxy))/Z[p+pr];} else {RR[p] = 0;} } } foreach p in UR do { if (p.x == M.xanz - 1 || p.y == 0) {UR[p] = 0;} else { if((M[p] - M[p+pur]) < 0 && Z[p+pur] > 0) {UR[p] = (atan((M[p+pur] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+pur];} else {UR[p] = 0;} } } foreach p in UU do { if (p.y == 0) {UU[p] = 0;} else { if((M[p] - M[p+pu]) < 0 && Z[p+pu] > 0) {UU[p] = (atan((M[p+pu] - M[p])/M.dxy))/Z[p+pu];} else {UU[p] = 0;} } } // in den folgenden drei Schritten wird nach der "multiple flow methode" die Einzugsgebietsgröße C ermittelt // foreach p in Z do {Z[p] = 1;} foreach ploop in Loop do { ploop.x = 1; i = i +1; gefunden = 0; foreach p in Z do { if (R[p] == i) {Z[p] = 1 + Z[p+pul] * UL[p] + Z[p+pl] * LL[p] + Z[p+pol] * OL[p] + Z[p+po] * OO[p] + Z[p+por] * OR[p] + Z[p+pr] * RR[p] + Z[p+pur] * UR[p] + Z[p+pu] * UU[p]; gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } setRandN(Z); foreach p in C do {C[p] = Z[p] * M.dxy^2;} // in den folgenden zwei Schritten werden Gewichte umgekehrt-proportional zur Einzugsgebietsgröße nach der multiple flow methode aufsummiert. Der w-parameter steuert die stärke der Gewichtung // foreach p in W do {W[p] = (1/C[p])^w;} foreach ploop in Loop do { ploop.x = 1; k = k +1; gefunden = 0; foreach p in W do { if (R[p] == k) {W[p] = W[p] + W[p+pul] * UL[p] + W[p+pl] * LL[p] + W[p+pol] * OL[p] + W[p+po] * OO[p] + W[p+por] * OR[p] + W[p+pr] * RR[p] + W[p+pur] * UR[p] + W[p+pu] * UU[p]; gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } setRandN(W); // in den folgenden zwei Schritten werden Höhenwerte und Gewichte nach der multiple flow methode in der Matrix H aufsummiert, wobei lokale Maxima im Einzugsgebiet am stärksten in H eingehen. Der w-Parameter steuert die Stärke der Maximumgewichtung // foreach p in H do {H[p] = M[p] * (1/C[p])^w;} foreach ploop in Loop do { ploop.x = 1; l = l +1; gefunden = 0; foreach p in H do { if (R[p] == l) {H[p] = H[p] + H[p+pul] * UL[p] + H[p+pl] * LL[p] + H[p+pol] * OL[p] + H[p+po] * OO[p] + H[p+por] * OR[p] + H[p+pr] * RR[p] + H[p+pur] * UR[p] + H[p+pu] * UU[p]; gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } setRandN(H); // im folgenden Schritt wird eine relative Höhe H über dem gewichteten arithmetischen Mittel der Einzugsgebietsgröße bestimmt // foreach p in H do { if (isRand(p, M) == 0) {H[p] = -1 * (M[p] - H[p]/W[p]);} } setRandN(H); // in den folgenden drei Schritten werden Maxima der relativen Höhe H in Abhängigkeit der Neigung gesaugt. Der e-Parameter steuert die stärke der Maximum-Streckung // foreach p in X do {X[p] = H[p]^e;} foreach ploop in Loop do { ploop.x = 1; m = m +1; gefunden = 0; foreach p in X do { if ((((1/t^N[p])^exp(t^N[p])) * max9(p, X)) > X[p]) {X[p] = (((1/t^N[p])^exp(t^N[p])) * max9(p, X)); gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } foreach p in HU do { if (isRand(p, M) == 0) { if(H[p]^e < X[p] || H[p+pul]^e < X[p+pul] || H[p+pl]^e < X[p+pl] || H[p+pol]^e < X[p+pol] || H[p+po]^e < X[p+po] || H[p+por]^e < X[p+por] || H[p+pr]^e < X[p+pr] || H[p+pur]^e < X[p+pur] || H[p+pu]^e < X[p+pu]) {HU[p] = (((X[p] + X[p+pul] + X[p+pu] + X[p+pur] + X[p+pl] + X[p+pr] + X[p+pol] + X[p+po] + X[p+por])/9)^(1/e));} else {HU[p] = (X[p]^(1/e));} } } setRandN (HU); showMatrix(HO); showMatrix(HU); // auf Grundlage von HO und HU wird die Normierte Höhe (NH) mit Höhenwerten zwischen minimal 0 (=unten) und maximal 1 (= oben) wie beim NDVI bestimmt. Die Standardisierte Höhe SH streckt das Relief auf ein Höhenspektrum zwischen theoretisch 0 (=unten) und dem Maximum der jeweiligen Scheitelbereiche, so dass die ursprüngliche Reliefenergie erhalten bleibt. Selbstverständlich muss für Anwendungen überprüft werden, ob und welche relativen Höhen (HU, HO, SH) logarithmiert dargestellt werden. Als Beispiel ist die Standardisierte Höhe logarithmiert berechnet (SHL) // foreach p in NH do {NH[p] = 0.5 * (1 + ((HO[p] - HU[p])/(HO[p] + HU[p])));} showMatrix(NH); foreach p in SH do {SH[p] = NH[p] * O[p];} showMatrix(SH); foreach p in SHL do {SHL[p] = ln(SH[p]);} showMatrix(SHL); /**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Curvature_Classification.h0000664000175000017500000001113412565125415031620 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Curvature_Classification.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Curvature_Classification.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Curvature_Classification_H #define HEADER_INCLUDED__Curvature_Classification_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_morphometry_EXPORT CCurvature_Classification : public CSG_Module_Grid { public: CCurvature_Classification(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Terrain Classification" )); } protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM; bool Get_Curvature (int x, int y, double &Plan, double &Profile); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Curvature_Classification_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/ruggedness.cpp0000664000175000017500000002400112565125415027323 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ruggedness.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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. " "online.\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; yis_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 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):1419–1426.\n" "online.\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; yGet_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; yis_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 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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/MLB_Interface.cpp0000664000175000017500000001427412605406442027557 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Morphometry") ); case MLB_INFO_Category: return( _TL("Terrain Analysis") ); case MLB_INFO_Author: return( SG_T("Various Authors") ); case MLB_INFO_Description: return( _TL("Tools for (grid based) digital terrain analysis.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Terrain Analysis|Morphometry") ); } } //--------------------------------------------------------- #include "Morphometry.h" #include "Convergence.h" #include "Convergence_Radius.h" #include "SurfaceSpecificPoints.h" #include "Curvature_Classification.h" #include "Hypsometry.h" #include "RealArea.h" #include "ProtectionIndex.h" #include "mrvbf.h" #include "distance_gradient.h" #include "mass_balance_index.h" #include "air_flow_height.h" #include "anisotropic_heating.h" #include "land_surface_temperature.h" #include "relative_heights.h" #include "wind_effect.h" #include "ruggedness.h" #include "tpi.h" #include "tc_iwahashi_pike.h" #include "param_scale.h" #include "top_hat.h" #include "fuzzy_landform_elements.h" #include "Curvature_UpDownSlope.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CMorphometry ); case 1: return( new CConvergence ); case 2: return( new CConvergence_Radius ); case 3: return( new CSurfaceSpecificPoints ); case 4: return( new CCurvature_Classification ); case 5: return( new CHypsometry ); case 6: return( new CRealArea ); case 7: return( new CProtectionIndex ); case 8: return( new CMRVBF ); case 9: return( new CDistance_Gradient ); case 10: return( new CMass_Balance_Index ); case 11: return( new CAir_Flow_Height ); case 12: return( new CAnisotropic_Heating ); 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 ); case 18: return( new CTPI ); case 19: return( new CTPI_Classification ); case 20: return( new CTC_Texture ); case 21: return( new CTC_Convexity ); case 22: return( new CTC_Classification ); case 23: return( new CParam_Scale ); case 24: return( new CTop_Hat ); case 25: return( new CFuzzy_Landform_Elements ); case 26: return( new CCurvature_UpDownSlope ); case 27: return( new CWind_Exposition ); case 30: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Makefile.am0000664000175000017500000000272212565125415026513 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1619 2013-03-05 16:07:00Z oconrad $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_morphometry.la libta_morphometry_la_SOURCES =\ Convergence.cpp\ Convergence_Radius.cpp\ Curvature_Classification.cpp\ Curvature_UpDownSlope.cpp\ Hypsometry.cpp\ MLB_Interface.cpp\ Morphometry.cpp\ ProtectionIndex.cpp\ RealArea.cpp\ SurfaceSpecificPoints.cpp\ air_flow_height.cpp\ anisotropic_heating.cpp\ distance_gradient.cpp\ fuzzy_landform_elements.cpp\ land_surface_temperature.cpp\ mass_balance_index.cpp\ mrvbf.cpp\ param_scale.cpp\ relative_heights.cpp\ ruggedness.cpp\ tc_iwahashi_pike.cpp\ top_hat.cpp\ tpi.cpp\ wind_effect.cpp\ Convergence.h\ Convergence_Radius.h\ Curvature_Classification.h\ Curvature_UpDownSlope.h\ Hypsometry.h\ MLB_Interface.h\ Morphometry.h\ ProtectionIndex.h\ RealArea.h\ SurfaceSpecificPoints.h\ air_flow_height.h\ anisotropic_heating.h\ distance_gradient.h\ fuzzy_landform_elements.h\ land_surface_temperature.h\ mass_balance_index.h\ mrvbf.h\ param_scale.h\ relative_heights.h\ ruggedness.h\ tc_iwahashi_pike.h\ top_hat.h\ tpi.h\ wind_effect.h libta_morphometry_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/tpi.cpp0000664000175000017500000003610712565125415025763 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: tpi.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // tpi.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "tpi.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTPI::CTPI(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Topographic Position Index (TPI)")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Topographic Position Index (TPI) calculation as proposed by Guisan et al. (1999). " "This is literally the same as the difference to the mean calculation (residual analysis) " "proposed by Wilson & Gallant (2000).\n" "The bandwidth parameter for distance weighting is given as percentage of the (outer) radius.\n" "\n" "References:\n" "- Guisan, A., Weiss, S.B., Weiss, A.D. (1999): GLM versus CCA spatial modeling of plant species distribution. Plant Ecology 143: 107-122.\n" "- Weiss, A.D. (2000): Topographic Position and Landforms Analysis. poster.\n" "- Wilson, J.P. & Gallant, J.C. (2000): Terrain Analysis - Principles and Applications.\n" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); pNode = Parameters.Add_Grid( NULL , "TPI" , _TL("Topographic Position Index"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "STANDARD" , _TL("Standardize"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Range( NULL , "RADIUS" , _TL("Radius"), _TL("radius in map units"), 0.0, 100.0, 0.0, true ); m_Cells.Get_Weighting().Set_BandWidth(75.0); // 75% m_Cells.Get_Weighting().Create_Parameters(&Parameters, false); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTPI::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Cells.Get_Weighting().Enable_Parameters(pParameters); return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTPI::On_Execute(void) { m_pDEM = Parameters("DEM")->asGrid(); m_pTPI = Parameters("TPI")->asGrid(); DataObject_Set_Colors(m_pTPI, 100, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- double r_inner = Parameters("RADIUS")->asRange()->Get_LoVal() / Get_Cellsize(); double r_outer = Parameters("RADIUS")->asRange()->Get_HiVal() / Get_Cellsize(); m_Cells.Get_Weighting().Set_Parameters(&Parameters); m_Cells.Get_Weighting().Set_BandWidth(r_outer * m_Cells.Get_Weighting().Get_BandWidth() / 100.0); if( !m_Cells.Set_Annulus(r_inner, r_outer) ) { return( false ); } //----------------------------------------------------- for(int y=0; yasBool() ) { m_pTPI->Standardise(); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTPI::Get_Statistics(int x, int y) { if( m_pDEM->is_InGrid(x, y) ) { int i, ix, iy; double z, id, iw; CSG_Simple_Statistics Statistics; for(i=0, z=m_pDEM->asDouble(x, y); i= 0.0 && m_pDEM->is_InGrid(ix, iy) ) { Statistics.Add_Value(m_pDEM->asDouble(ix, iy), iw); } } //------------------------------------------------- if( Statistics.Get_Weights() > 0.0 ) { m_pTPI->Set_Value(x, y, z - Statistics.Get_Mean()); return( true ); } } //----------------------------------------------------- m_pTPI->Set_NoData(x, y); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTPI_Classification::CTPI_Classification(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("TPI Based Landform Classification")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Topographic Position Index (TPI) calculation as proposed by Guisan et al. (1999). " "This is literally the same as the difference to the mean calculation (residual analysis) " "proposed by Wilson & Gallant (2000).\n" "The bandwidth parameter for distance weighting is given as percentage of the (outer) radius.\n" "\n" "References:\n" "- Guisan, A., Weiss, S.B., Weiss, A.D. (1999): GLM versus CCA spatial modeling of plant species distribution. Plant Ecology 143: 107-122.\n" "- Weiss, A.D. (2000): Topographic Position and Landforms Analysis. poster.\n" "- Wilson, J.P. & Gallant, J.C. (2000): Terrain Analysis - Principles and Applications.\n" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); pNode = Parameters.Add_Grid( NULL , "LANDFORMS" , _TL("Landforms"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Range( NULL , "RADIUS_A" , _TL("Radius"), _TL("radius in map units"), 0.0, 100.0, 0.0, true ); Parameters.Add_Range( NULL , "RADIUS_B" , _TL("Radius"), _TL("radius in map units"), 0.0, 1000.0, 0.0, true ); m_Weighting.Set_BandWidth(75.0); // 75% m_Weighting.Create_Parameters(&Parameters, false); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { LF_CANYON = 0, LF_MID_SLOPE, LF_UPLAND, LF_VALLEY, LF_PLAIN, LF_OPEN_SLOPE, LF_UPPER_SLOPE, LF_LOCAL_RIDGE, LF_MIDSLOPE_RIDGE, LF_HIGH_RIDGE, LF_COUNT }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTPI_Classification::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Weighting.Enable_Parameters(pParameters); return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTPI_Classification::On_Execute(void) { //----------------------------------------------------- CSG_Grid *pDEM = Parameters("DEM" )->asGrid(); CSG_Grid *pLandforms = Parameters("LANDFORMS")->asGrid(); CTPI TPI; TPI.Set_Manager(NULL); TPI.Get_Parameters()->Assign_Values(&Parameters); // set DEM and Weighting scheme TPI.Get_Parameters()->Get_Parameter("STANDARD")->Set_Value(true); //----------------------------------------------------- CSG_Grid gA(*Get_System()); TPI.Get_Parameters()->Get_Parameter("TPI")->Set_Value(&gA); TPI.Get_Parameters()->Set_Parameter("RADIUS", Parameters("RADIUS_A")); if( !TPI.Execute() ) { return( false ); } //----------------------------------------------------- CSG_Grid gB(*Get_System()); TPI.Get_Parameters()->Get_Parameter("TPI")->Set_Value(&gB); TPI.Get_Parameters()->Set_Parameter("RADIUS", Parameters("RADIUS_B")); if( !TPI.Execute() ) { return( false ); } //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { pLandforms->Set_Value(x, y, -1.0); } else { double A = gA.asDouble(x, y); double B = gB.asDouble(x, y); if( A <= -1.0 ) { if( B <= -1.0 ) { // Canyons, Deeply Incised Streams pLandforms->Set_Value(x, y, LF_CANYON); } else if( B < 1.0 ) { // Midslope Drainages, Shallow Valleys pLandforms->Set_Value(x, y, LF_MID_SLOPE); } else // if( B >= 1.0 ) { // Upland Drainages, Headwaters pLandforms->Set_Value(x, y, LF_UPLAND); } } else if( A < 1.0 ) { if( B <= -1.0 ) { // U-shaped Valleys pLandforms->Set_Value(x, y, LF_VALLEY); } else if( B < 1.0 ) { double Slope, Aspect; pDEM->Get_Gradient(x, y, Slope, Aspect); if( Slope <= 5.0 * M_DEG_TO_RAD ) { // Plains pLandforms->Set_Value(x, y, LF_PLAIN); } else { // Open Slopes pLandforms->Set_Value(x, y, LF_OPEN_SLOPE); } } else // if( B >= 1.0 ) { // Upper Slopes, Mesas pLandforms->Set_Value(x, y, LF_UPPER_SLOPE); } } else // if( A >= 1.0 ) { if( B <= -1.0 ) { // Local Ridges, Hills in Valleys pLandforms->Set_Value(x, y, LF_LOCAL_RIDGE); } else if( B < 1.0 ) { // Midslope Ridges, Small Hills in Plains pLandforms->Set_Value(x, y, LF_MIDSLOPE_RIDGE); } else // if( B >= 1.0 ) { // Mountain Tops, High Ridges pLandforms->Set_Value(x, y, LF_HIGH_RIDGE); } } } } } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pLandforms, P) && P("COLORS_TYPE") && P("LUT") ) { int LF_Colors[LF_COUNT] = { SG_GET_RGB( 0, 0, 127), // LF_CANYON SG_GET_RGB(200, 200, 255), // LF_MID_SLOPE SG_GET_RGB( 0, 200, 255), // LF_UPLAND SG_GET_RGB(127, 127, 255), // LF_VALLEY SG_GET_RGB(255, 255, 128), // LF_PLAIN SG_GET_RGB(128, 255, 0), // LF_OPEN_SLOPE SG_GET_RGB( 0, 255, 0), // LF_UPPER_SLOPE SG_GET_RGB(255, 200, 127), // LF_LOCAL_RIDGE SG_GET_RGB(255, 127, 0), // LF_MIDSLOPE_RIDGE SG_GET_RGB(255, 0, 0) // LF_HIGH_RIDGE }; //------------------------------------------------- CSG_Strings Name, Desc; Name += _TL("Streams"); Desc += _TL("Canyons, Deeply Incised Streams"); Name += _TL("Midslope Drainages"); Desc += _TL("Midslope Drainages, Shallow Valleys"); Name += _TL("Upland Drainages"); Desc += _TL("Upland Drainages, Headwaters"); Name += _TL("Valleys"); Desc += _TL("U-shaped Valleys"); Name += _TL("Plains"); Desc += _TL("Plains"); Name += _TL("Open Slopes"); Desc += _TL("Open Slopes"); Name += _TL("Upper Slopes"); Desc += _TL("Upper Slopes, Mesas"); Name += _TL("Local Ridges"); Desc += _TL("Local Ridges, Hills in Valleys"); Name += _TL("Midslope Ridges"); Desc += _TL("Midslope Ridges, Small Hills in Plains"); Name += _TL("High Ridges"); Desc += _TL("Mountain Tops, High Ridges"); //------------------------------------------------- CSG_Table *pTable = P("LUT")->asTable(); pTable->Del_Records(); for(int i=0; iAdd_Record(); pRecord->Set_Value(0, LF_Colors[i]); pRecord->Set_Value(1, Name[i].c_str()); pRecord->Set_Value(2, Desc[i].c_str()); pRecord->Set_Value(3, i); pRecord->Set_Value(4, i); } P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table DataObject_Set_Parameters(pLandforms, P); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/wind_effect.h0000664000175000017500000001267412605406442027111 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wind_effect.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // wind_effect.h // // // // Copyright (C) 2008 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringeler@saga-gis.org // // // // contact: Andre Ringeler // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__LeeLuv_B_H #define HEADER_INCLUDED__LeeLuv_B_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWind_Effect : public CSG_Module_Grid { public: CWind_Effect(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Climate and Weather") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool m_bTrace; double m_maxDistance, m_Acceleration; TSG_Point m_Dir_Const; CSG_Grid *m_pDEM, m_DX, m_DY; CSG_Grid_Pyramid m_DEM; bool Get_Next (TSG_Point &Position, double Distance, bool bReverse); bool Get_Z (const TSG_Point &Position, double Distance, double &z); void Get_Luv (int x, int y, double &Sum_A); void Get_Lee (int x, int y, double &Sum_A, double &Sum_B); void Get_Luv_Old (int x, int y, double dx, double dy, double &Sum_A); void Get_Lee_Old (int x, int y, double dx, double dy, double &Sum_A, double &Sum_B); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWind_Exposition : public CSG_Module_Grid { public: CWind_Exposition(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Climate and Weather") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__LeeLuv_B_Hsaga-2.2.3/src/modules/terrain_analysis/ta_morphometry/MLB_Interface.h0000664000175000017500000000773712565125415027235 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_morphometry_H #define HEADER_INCLUDED__ta_morphometry_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef ta_morphometry_EXPORTS #define ta_morphometry_EXPORT _SAGA_DLL_EXPORT #else #define ta_morphometry_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ta_morphometry_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Convergence.cpp0000664000175000017500000002373412565125415027427 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Convergence.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Convergence.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Convergence.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CConvergence::CConvergence(void) { Set_Name (_TL("Convergence Index")); Set_Author (SG_T("O.Conrad (c) 2001")); Set_Description (_TW( "Reference:\n" "Koethe, R. & Lehmeier, F. (1996): SARA - System zur Automatischen Relief-Analyse. " "User Manual, 2. Edition [Dept. of Geography, University of Goettingen, unpublished]\n\n" )); Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "RESULT" , _TL("Convergence Index"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Aspect"), _TL("Gradient") ),0 ); Parameters.Add_Choice( NULL , "NEIGHBOURS" , _TL("Gradient Calculation"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("2 x 2"), _TL("3 x 3") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CConvergence::On_Execute(void) { bool bGradient; int Neighbours; CSG_Grid *pConvergence; m_pDTM = Parameters("ELEVATION") ->asGrid(); pConvergence = Parameters("RESULT") ->asGrid(); Neighbours = Parameters("NEIGHBOURS") ->asInt(); bGradient = Parameters("METHOD") ->asInt() == 1; DataObject_Set_Colors(pConvergence, 100, SG_COLORS_RED_GREY_BLUE, true); for(int y=0; yis_InGrid(x, y) ) { switch( Neighbours ) { case 0: default: pConvergence->Set_Value(x, y, Get_2x2(x, y, bGradient)); break; case 1: pConvergence->Set_Value(x, y, Get_9x9(x, y, bGradient)); break; } } else { pConvergence->Set_NoData(x, y); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CConvergence::Get_2x2_Gradient(int x, int y, int i, double &Slope, double &Aspect, double &Height) { double z[4]; switch( i % 4 ) { case 0: z[0] = m_pDTM->is_InGrid(x , y + 1) ? m_pDTM->asDouble(x , y + 1) : m_pDTM->asDouble(x, y); z[1] = m_pDTM->is_InGrid(x + 1, y + 1) ? m_pDTM->asDouble(x + 1, y + 1) : m_pDTM->asDouble(x, y); z[2] = m_pDTM->is_InGrid(x , y ) ? m_pDTM->asDouble(x , y ) : m_pDTM->asDouble(x, y); z[3] = m_pDTM->is_InGrid(x + 1, y ) ? m_pDTM->asDouble(x + 1, y ) : m_pDTM->asDouble(x, y); break; case 1: z[0] = m_pDTM->is_InGrid(x , y ) ? m_pDTM->asDouble(x , y ) : m_pDTM->asDouble(x, y); z[1] = m_pDTM->is_InGrid(x + 1, y ) ? m_pDTM->asDouble(x + 1, y ) : m_pDTM->asDouble(x, y); z[2] = m_pDTM->is_InGrid(x , y - 1) ? m_pDTM->asDouble(x , y - 1) : m_pDTM->asDouble(x, y); z[3] = m_pDTM->is_InGrid(x + 1, y - 1) ? m_pDTM->asDouble(x + 1, y - 1) : m_pDTM->asDouble(x, y); break; case 2: z[0] = m_pDTM->is_InGrid(x - 1, y ) ? m_pDTM->asDouble(x - 1, y ) : m_pDTM->asDouble(x, y); z[1] = m_pDTM->is_InGrid(x , y ) ? m_pDTM->asDouble(x , y ) : m_pDTM->asDouble(x, y); z[2] = m_pDTM->is_InGrid(x - 1, y - 1) ? m_pDTM->asDouble(x - 1, y - 1) : m_pDTM->asDouble(x, y); z[3] = m_pDTM->is_InGrid(x , y - 1) ? m_pDTM->asDouble(x , y - 1) : m_pDTM->asDouble(x, y); break; case 3: z[0] = m_pDTM->is_InGrid(x - 1, y + 1) ? m_pDTM->asDouble(x - 1, y + 1) : m_pDTM->asDouble(x, y); z[1] = m_pDTM->is_InGrid(x , y + 1) ? m_pDTM->asDouble(x , y + 1) : m_pDTM->asDouble(x, y); z[2] = m_pDTM->is_InGrid(x - 1, y ) ? m_pDTM->asDouble(x - 1, y ) : m_pDTM->asDouble(x, y); z[3] = m_pDTM->is_InGrid(x , y ) ? m_pDTM->asDouble(x , y ) : m_pDTM->asDouble(x, y); break; } double a = ((z[1] + z[0]) - (z[3] + z[2])) / (2.0 * Get_Cellsize()); double b = ((z[3] + z[1]) - (z[2] + z[0])) / (2.0 * Get_Cellsize()); Height = (z[0] + z[1] + z[2] + z[3]) / 4.0; Slope = atan(sqrt(a*a + b*b)); if( a != 0.0 ) { Aspect = M_PI_180 + atan2(b, a); } else if( b > 0.0 ) { Aspect = M_PI_270; } else if( b < 0.0 ) { Aspect = M_PI_090; } else { return( false ); } return( true ); } //--------------------------------------------------------- double CConvergence::Get_2x2(int x, int y, bool bGradient) { int i, n; double Height, Slope, Aspect, iSlope, iAspect, d, dSum; for(i=0, n=0, dSum=0.0, iAspect=-M_PI_135; i<4; i++, iAspect+=M_PI_090) { if( Get_2x2_Gradient(x, y, i, Slope, Aspect, Height) ) { d = Aspect - iAspect; if( bGradient ) { iSlope = atan((Height - m_pDTM->asDouble(x, y)) / Get_Length(1)); d = acos(sin(Slope) * sin(iSlope) + cos(Slope) * cos(iSlope) * cos(d)); // Nach dem Seiten-Kosinus-Satz... } d = fmod(d, M_PI_360); if( d < -M_PI_180 ) { d += M_PI_360; } else if( d > M_PI_180 ) { d -= M_PI_360; } dSum += fabs(d); n++; } } return( n > 0 ? (dSum / (double)n - M_PI_090) * 100.0 / M_PI_090 : 0.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CConvergence::Get_9x9(int x, int y, bool bGradient) { int i, ix, iy, n; double Slope, Aspect, iSlope, iAspect, d, dSum; for(i=0, n=0, dSum=0.0, iAspect=-M_PI_180; i<8; i++, iAspect+=M_PI_045) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy) && m_pDTM->Get_Gradient(ix, iy, Slope, Aspect) && Aspect >= 0.0 ) { d = Aspect - iAspect; if( bGradient ) { iSlope = atan((m_pDTM->asDouble(ix, iy) - m_pDTM->asDouble(x, y)) / Get_Length(i)); d = acos(sin(Slope) * sin(iSlope) + cos(Slope) * cos(iSlope) * cos(d)); // Nach dem Seiten-Kosinus-Satz... } d = fmod(d, M_PI_360); if( d < -M_PI_180 ) { d += M_PI_360; } else if( d > M_PI_180 ) { d -= M_PI_360; } dSum += fabs(d); n++; } } return( n > 0 ? (dSum / (double)n - M_PI_090) * 100.0 / M_PI_090 : 0.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Curvature_UpDownSlope.cpp0000664000175000017500000002526312565125415031447 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Curvature_UpDownSlope.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Curvature_UpDownSlope.cpp // // // // Copyright (C) 2015 by // // Paolo Gandelli // // // //-------------------------------------------------------// // // // 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: gandelli.paolo@gmail.com // // // // contact: Paolo Gandelli // // Engineering Geology and Geomorphology // // Department of Earth Sciences // // University of Firenze // // Italy // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Curvature_UpDownSlope.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCurvature_UpDownSlope::CCurvature_UpDownSlope(void) { Set_Name (_TL("Upslope and Downslope Curvature")); Set_Author ("P.Gandelli, O.Conrad (c) 2015"); Set_Description (_TW( "Calculates the local curvature of a cell as sum of the gradients to its neighbour cells. " "Upslope curvature is the distance weighted average local curvature in a cell's upslope " "contributing area based on multiple flow direction after Freeman 1994. " "\nReferences:\n" "- Freeman, G.T. (1991): Calculating catchment area with divergent flow based on a regular grid. " " Computers and Geosciences, 17:413-22\n" )); Parameters.Add_Grid(NULL, "DEM" , _TL("Elevation" ), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid(NULL, "C_LOCAL" , _TL("Local Curvature" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "C_UP" , _TL("Upslope Curvature" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "C_UP_LOCAL" , _TL("Local Upslope Curvature" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "C_DOWN" , _TL("Downslope Curvature" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "C_DOWN_LOCAL", _TL("Local Downslope Curvature"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Value( NULL , "WEIGHTING" , _TL("Upslope Weighting"), _TL(""), PARAMETER_TYPE_Double, 0.5, 0.0, true, 1.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCurvature_UpDownSlope::On_Execute(void) { m_pDEM = Parameters("DEM" )->asGrid(); m_pC_Local = Parameters("C_LOCAL" )->asGrid(); m_pC_Up = Parameters("C_UP" )->asGrid(); m_pC_Up_Local = Parameters("C_UP_LOCAL" )->asGrid(); m_pC_Down = Parameters("C_DOWN" )->asGrid(); m_pC_Down_Local = Parameters("C_DOWN_LOCAL")->asGrid(); m_Weighting = Parameters("WEIGHTING")->asDouble(); m_pC_Up ->Assign(0.0); m_pC_Up_Local ->Assign(0.0); m_pC_Down ->Assign(0.0); m_pC_Down_Local->Assign(0.0); DataObject_Set_Colors(m_pC_Local , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Up , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Up_Local , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Down , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(m_pC_Down_Local, 11, SG_COLORS_RED_GREY_BLUE, true); if( !m_Weights.Create(*Get_System()) ) { Error_Set(_TL("could not allocate memory for temporary grid.")); return( false ); } //----------------------------------------------------- int x, y; for(y=0; yis_NoData(x, y) ) { m_pC_Local ->Set_NoData(x, y); m_pC_Up ->Set_NoData(x, y); m_pC_Up_Local ->Set_NoData(x, y); m_pC_Down ->Set_NoData(x, y); m_pC_Down_Local->Set_NoData(x, y); } else { m_pC_Local ->Set_Value(x, y, Get_Local(x, y)); } } } //----------------------------------------------------- for(sLong i=0; iGet_Sorted(i, x, y, true) ) { Get_Upslope(x, y); } if( m_pDEM->Get_Sorted(i, x, y, false) ) { Get_Downslope(x, y); } } //----------------------------------------------------- m_Weights.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CCurvature_UpDownSlope::Get_Local(int x, int y) { double Sum = 0.0; for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) ) { Sum += ((m_pDEM->asDouble(x, y) - m_pDEM->asDouble(ix, iy)) / Get_Length(i)); } } return( Sum ); } //--------------------------------------------------------- bool CCurvature_UpDownSlope::Get_Upslope(int x, int y) { double cLocal = m_pC_Local->asDouble(x, y); //----------------------------------------------------- double cUp, cUp_Local, Weights; if( (Weights = m_Weights.asDouble(x, y)) > 0.0 ) { cUp = (m_pC_Up->asDouble(x, y) + m_Weighting * cLocal) / (Weights + m_Weighting); cUp_Local = m_pC_Up_Local->asDouble(x, y) / Weights; } else { cUp = cLocal; cUp_Local = cLocal; } m_pC_Up ->Set_Value(x, y, cUp ); m_pC_Up_Local->Set_Value(x, y, cUp_Local); //----------------------------------------------------- double Proportion[8]; if( Get_Flow_Proportions(x, y, Proportion) ) { for(int i=0; i<8; i++) { if( Proportion[i] > 0.0 ) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); m_pC_Up ->Add_Value(ix, iy, Proportion[i] * cUp); m_pC_Up_Local->Add_Value(ix, iy, Proportion[i] * cLocal); m_Weights .Add_Value(ix, iy, Proportion[i]); } } } return( true ); } //--------------------------------------------------------- bool CCurvature_UpDownSlope::Get_Downslope(int x, int y) { //----------------------------------------------------- double Proportion[8]; if( Get_Flow_Proportions(x, y, Proportion) ) { double Weights = 0.0, cDown = 0.0, cDown_Local = 0.0; for(int i=0; i<8; i++) { if( Proportion[i] > 0.0 ) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pC_Local->is_InGrid(ix, iy) ) { cDown_Local += Proportion[i] * m_pC_Local->asDouble(ix, iy); cDown += Proportion[i] * m_pC_Down ->asDouble(ix, iy); Weights += Proportion[i]; } } } if( Weights > 0.0 ) { m_pC_Down_Local->Set_Value(x, y, cDown_Local / Weights); m_pC_Down ->Set_Value(x, y, (m_Weighting * m_pC_Local->asDouble(x, y) + cDown) / (m_Weighting + Weights)); } return( true ); } m_pC_Down_Local->Set_Value(x, y, m_pC_Local->asDouble(x, y)); m_pC_Down ->Set_Value(x, y, m_pC_Local->asDouble(x, y)); return( false ); } //--------------------------------------------------------- bool CCurvature_UpDownSlope::Get_Flow_Proportions(int x, int y, double Proportion[8]) { if( m_pDEM->is_InGrid(x, y) ) { double Sum = 0.0; for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && m_pDEM->asDouble(x, y) > m_pDEM->asDouble(ix, iy) ) { Sum += (Proportion[i] = ((m_pDEM->asDouble(x, y) - m_pDEM->asDouble(ix, iy)) / Get_Length(i))); } else { Proportion[i] = 0.0; } } if( Sum > 0.0 ) { for(int i=0; i<8; i++) { Proportion[i] /= Sum; } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/mrvbf.h0000664000175000017500000001160412565125415025743 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: mrvbf.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // MRVBF.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__MRVBF_H #define HEADER_INCLUDED__MRVBF_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMRVBF : public CSG_Module_Grid { public: CMRVBF(void); virtual ~CMRVBF(void); protected: virtual bool On_Execute (void); private: double m_P_Slope, m_P_Pctl, m_T_Pctl_V, m_T_Pctl_R; CSG_Grid_Radius m_Radius; double Get_Transformation (double x, double t, double p); bool Get_Percentile (CSG_Grid *pDEM, int x, int y, double &Percentile); bool Get_Percentiles (CSG_Grid *pDEM, CSG_Grid *pPercentile, int Radius); bool Get_Slopes (CSG_Grid *pDEM, CSG_Grid *pSlope); bool Get_Smoothed (CSG_Grid *pDEM, CSG_Grid *pSmoothed, int Radius, double Smoothing); bool Get_Values (CSG_Grid *pDEM, CSG_Grid *pSlope, CSG_Grid *pPercentiles, double Resolution); bool Get_Flatness (CSG_Grid *pSlope, CSG_Grid *pPctl, CSG_Grid *pF, CSG_Grid *pVB, CSG_Grid *pRT, double T_Slope); bool Get_MRVBF (int Level, CSG_Grid *pMRVBF, CSG_Grid *pVF, CSG_Grid *pMRRTF, CSG_Grid *pRF); bool Get_Classified (CSG_Grid *pMRF); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__MRVBF_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/fuzzy_landform_elements.cpp0000664000175000017500000004405012565125415032130 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: felement.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // fuzzy_landform_elements.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "fuzzy_landform_elements.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { SLOPE = 0, MAXCURV, MINCURV, PCURV, TCURV, IN_COUNT }; //--------------------------------------------------------- const CSG_String IN_Type[IN_COUNT][2] = { { "SLOPE" , _TL("Slope" ) }, { "MINCURV" , _TL("Minimum Curvature" ) }, { "MAXCURV" , _TL("Maximum Curvature" ) }, { "PCURV" , _TL("Profile Curvature" ) }, { "TCURV" , _TL("Tangential Curvature") } }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- struct SForm_Def { CSG_String ID, Name; long Color; int Value; }; //--------------------------------------------------------- enum { PLAIN = 0, PIT, PEAK, RIDGE, CHANNEL, SADDLE, BSLOPE, FSLOPE, SSLOPE, HOLLOW, FHOLLOW, SHOLLOW, SPUR, FSPUR, SSPUR, FE_COUNT }; //--------------------------------------------------------- #define MAKE_RGB(r, g, b) SG_GET_RGB((int)(r * 255.0), (int)(g * 255.0), (int)(b * 255.0)) //--------------------------------------------------------- const struct SForm_Def Form_Def[FE_COUNT] = { { "PLAIN" , _TL("Plain" ), MAKE_RGB(0.820, 0.820, 0.820), 100 }, { "PIT" , _TL("Pit" ), MAKE_RGB(0.824, 0.706, 0.549), 111 }, { "PEAK" , _TL("Peak" ), MAKE_RGB(0.647, 0.165, 0.165), 122 }, { "RIDGE" , _TL("Ridge" ), MAKE_RGB(0.627, 0.125, 0.941), 120 }, { "CHANNEL" , _TL("Channel" ), MAKE_RGB(0.933, 0.510, 0.933), 101 }, { "SADDLE" , _TL("Saddle" ), MAKE_RGB(0.000, 0.000, 0.000), 121 }, { "BSLOPE" , _TL("Back Slope" ), MAKE_RGB(0.000, 1.000, 0.000), 0 }, { "FSLOPE" , _TL("Foot Slope" ), MAKE_RGB(0.596, 0.984, 0.596), 10 }, { "SSLOPE" , _TL("Shoulder Slope" ), MAKE_RGB(0.000, 0.392, 0.000), 20 }, { "HOLLOW" , _TL("Hollow" ), MAKE_RGB(0.000, 0.000, 1.000), 1 }, { "FHOLLOW" , _TL("Foot Hollow" ), MAKE_RGB(0.000, 1.000, 1.000), 11 }, { "SHOLLOW" , _TL("Shoulder Hollow"), MAKE_RGB(0.000, 0.000, 0.392), 21 }, { "SPUR" , _TL("Spur" ), MAKE_RGB(1.000, 0.000, 0.000), 2 }, { "FSPUR" , _TL("Foot Spur" ), MAKE_RGB(1.000, 0.714, 0.757), 12 }, { "SSPUR" , _TL("Shoulder Spur" ), MAKE_RGB(0.392, 0.000, 0.000), 22 } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFuzzy_Landform_Elements::CFuzzy_Landform_Elements(void) { //----------------------------------------------------- Set_Name (_TL("Fuzzy Landform Element Classification")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Algorithm for derivation of form elements according to slope, maximum curvature, " "minimum curvature, profile curvature, tangential curvature, " "based on a linear semantic import model for slope and curvature and a fuzzy classification " "Based on the AML script \'felementf\' by Jochen Schmidt, Landcare Research. " "\n" )); //----------------------------------------------------- int i; for(i=0; iasGrid(); pMem = Parameters("MEM" )->asGrid(); pEntropy = Parameters("ENTROPY")->asGrid(); pCI = Parameters("CI" )->asGrid(); m_loSlope = Parameters("T_SLOPE")->asRange()->Get_LoVal();// * M_DEG_TO_RAD; m_hiSlope = Parameters("T_SLOPE")->asRange()->Get_HiVal();// * M_DEG_TO_RAD; m_loCurve = Parameters("T_CURVE")->asRange()->Get_LoVal(); m_hiCurve = Parameters("T_CURVE")->asRange()->Get_HiVal(); m_bSlopeToDeg = Parameters("BSLOPE" )->asInt() == 1; for(i=0; iasGrid(); } for(i=0; iasGrid(); DataObject_Set_Colors(pMembership[i], 11, SG_COLORS_WHITE_RED); } //----------------------------------------------------- CSG_Parameter *pLUT = DataObject_Get_Parameter(pForm, "LUT"); if( pLUT && pLUT->asTable() ) { pLUT->asTable()->Del_Records(); for(i=0; iasTable()->Add_Record(); pRecord->Set_Value(0, Form_Def[i].Color); pRecord->Set_Value(1, Form_Def[i].Name); pRecord->Set_Value(3, Form_Def[i].Value); pRecord->Set_Value(4, Form_Def[i].Value); } DataObject_Set_Parameter(pForm, pLUT); DataObject_Set_Parameter(pForm, "COLORS_TYPE", 1); // Color Classification Type: Lookup Table } //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { bOkay = false; } else { Input[i] = pInput[i]->asDouble(x, y); } } if( bOkay && Get_Memberships(Input, Membership, Element, MaxMem, Entropy, CI) ) { for(i=0; iSet_Value(x, y, Membership[i]); } } pForm ->Set_Value(x, y, Element); // hard classification according to highest membership value pMem ->Set_Value(x, y, MaxMem ); pEntropy->Set_Value(x, y, Entropy); pCI ->Set_Value(x, y, CI ); // confusion index } else { for(i=0; iSet_NoData(x, y); } } pForm ->Set_NoData(x, y); pMem ->Set_NoData(x, y); pEntropy->Set_NoData(x, y); pCI ->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_MINIMUM(a, b, c) M_GET_MIN(a, M_GET_MIN(b, c)) //--------------------------------------------------------- bool CFuzzy_Landform_Elements::Get_Memberships(double Input[], double M[], int &Element, double &MaxMem, double &Entropy, double &CI) { double bFlat, bSlope, MaxMem2, bPCurve , bPCurveX , bPCurveV, bTCurve , bTCurveX , bTCurveV, bMaxCurve, bMaxCurveX, bMaxCurveV, bMinCurve, bMinCurveX, bMinCurveV; //----------------------------------------------------- if( m_bSlopeToDeg ) { Input[SLOPE] *= M_RAD_TO_DEG; } //----------------------------------------------------- // membership slope flat bFlat = Input[SLOPE] <= m_loSlope ? 1.0 : (Input[SLOPE] >= m_hiSlope ? 0.0 : (m_hiSlope - Input[SLOPE]) / (m_hiSlope - m_loSlope)); // linear membership fct bSlope = 1 - bFlat; // membership pcurv straight bPCurve = fabs(Input[PCURV]) <= m_loCurve ? 1.0 : (fabs(Input[PCURV]) >= m_hiCurve ? 0.0 : (m_hiCurve - fabs(Input[PCURV])) / (m_hiCurve - m_loCurve)); // linear membership fct bPCurveX = Input[PCURV] >= 0.0 ? 1.0 - bPCurve : 0.0; bPCurveV = Input[PCURV] <= 0.0 ? 1.0 - bPCurve : 0.0; // membership tcurv straight bTCurve = fabs(Input[TCURV]) <= m_loCurve ? 1.0 : (fabs(Input[TCURV]) >= m_hiCurve ? 0.0 : (m_hiCurve - fabs(Input[TCURV])) / (m_hiCurve - m_loCurve)); // linear membership fct bTCurveX = Input[TCURV] >= 0.0 ? 1.0 - bTCurve : 0.0; bTCurveV = Input[TCURV] <= 0.0 ? 1.0 - bTCurve : 0.0; // membership maxcurv straight bMaxCurve = fabs(Input[MAXCURV]) <= m_loCurve ? 1.0 : (fabs(Input[MAXCURV]) >= m_hiCurve ? 0.0 : (m_hiCurve - fabs(Input[MAXCURV])) / (m_hiCurve - m_loCurve)); // linear membership fct bMaxCurveX = Input[MAXCURV] >= 0.0 ? 1.0 - bMaxCurve : 0.0; bMaxCurveV = Input[MAXCURV] <= 0.0 ? 1.0 - bMaxCurve : 0.0; // membership mincurv straight bMinCurve = fabs(Input[MINCURV]) <= m_loCurve ? 1.0 : (fabs(Input[MINCURV]) >= m_hiCurve ? 0.0 : (m_hiCurve - fabs(Input[MINCURV])) / (m_hiCurve - m_loCurve)); // linear membership fct bMinCurveX = Input[MINCURV] >= 0.0 ? 1.0 - bMinCurve : 0.0; bMinCurveV = Input[MINCURV] <= 0.0 ? 1.0 - bMinCurve : 0.0; //----------------------------------------------------- M[PLAIN] = GET_MINIMUM(bFlat, bMaxCurve, bMinCurve); Element = Form_Def[PLAIN].Value; MaxMem = M[PLAIN]; M[PIT] = GET_MINIMUM(bFlat, bMaxCurveV, bMinCurveV); if( M[PIT] > MaxMem ) { Element = Form_Def[PIT].Value; MaxMem = M[PIT]; MaxMem2 = M[PLAIN]; } else { MaxMem2 = M[PIT]; } M[PEAK] = GET_MINIMUM(bFlat, bMaxCurveX, bMinCurveX); if( M[PEAK] > MaxMem ) { Element = Form_Def[PEAK].Value; MaxMem = M[PEAK]; } else if( M[PEAK] > MaxMem2 ) { MaxMem2 = M[PEAK]; } M[RIDGE] = GET_MINIMUM(bFlat, bMaxCurveX, bMinCurve); if( M[RIDGE] > MaxMem ) { Element = Form_Def[RIDGE].Value; MaxMem = M[RIDGE]; } else if( M[RIDGE] > MaxMem2 ) { MaxMem2 = M[RIDGE]; } M[CHANNEL] = GET_MINIMUM(bFlat, bMaxCurve, bMinCurveV); if( M[CHANNEL] > MaxMem ) { Element = Form_Def[CHANNEL].Value; MaxMem = M[CHANNEL]; } else if( M[CHANNEL] > MaxMem2 ) { MaxMem2 = M[CHANNEL]; } M[SADDLE] = GET_MINIMUM(bFlat, bMaxCurveX, bMinCurveV); if( M[SADDLE] > MaxMem ) { Element = Form_Def[SADDLE].Value; MaxMem = M[SADDLE]; } else if( M[SADDLE] > MaxMem2 ) { MaxMem2 = M[SADDLE]; } M[BSLOPE] = GET_MINIMUM(bSlope, bPCurve, bTCurve); if( M[BSLOPE] > MaxMem ) { Element = Form_Def[BSLOPE].Value; MaxMem = M[BSLOPE]; } else if( M[BSLOPE] > MaxMem2 ) { MaxMem2 = M[BSLOPE]; } M[FSLOPE] = GET_MINIMUM(bSlope, bPCurveV, bTCurve); if( M[FSLOPE] > MaxMem ) { Element = Form_Def[FSLOPE].Value; MaxMem = M[FSLOPE]; } else if( M[FSLOPE] > MaxMem2 ) { MaxMem2 = M[FSLOPE]; } M[SSLOPE] = GET_MINIMUM(bSlope, bPCurveX, bTCurve); if( M[SSLOPE] > MaxMem ) { Element = Form_Def[SSLOPE].Value; MaxMem = M[SSLOPE]; } else if( M[SSLOPE] > MaxMem2 ) { MaxMem2 = M[SSLOPE]; } M[HOLLOW] = GET_MINIMUM(bSlope, bPCurve, bTCurveV); if( M[HOLLOW] > MaxMem ) { Element = Form_Def[HOLLOW].Value; MaxMem = M[HOLLOW]; } else if( M[HOLLOW] > MaxMem2 ) { MaxMem2 = M[HOLLOW]; } M[FHOLLOW] = GET_MINIMUM(bSlope, bPCurveV, bTCurveV); if( M[FHOLLOW] > MaxMem ) { Element = Form_Def[FHOLLOW].Value; MaxMem = M[FHOLLOW]; } else if( M[FHOLLOW] > MaxMem2 ) { MaxMem2 = M[FHOLLOW]; } M[SHOLLOW] = GET_MINIMUM(bSlope, bPCurveX, bTCurveV); if( M[SHOLLOW] > MaxMem ) { Element = Form_Def[SHOLLOW].Value; MaxMem = M[SHOLLOW]; } else if( M[SHOLLOW] > MaxMem2 ) { MaxMem2 = M[SHOLLOW]; } M[SPUR] = GET_MINIMUM(bSlope, bPCurve, bTCurveX); if( M[SPUR] > MaxMem ) { Element = Form_Def[SPUR].Value; MaxMem = M[SPUR]; } else if( M[SPUR] > MaxMem2 ) { MaxMem2 = M[SPUR]; } M[FSPUR] = GET_MINIMUM(bSlope, bPCurveV, bTCurveX); if( M[FSPUR] > MaxMem ) { Element = Form_Def[FSPUR].Value; MaxMem = M[FSPUR]; } else if( M[FSPUR] > MaxMem2 ) { MaxMem2 = M[FSPUR]; } M[SSPUR] = GET_MINIMUM(bSlope, bPCurveX, bTCurveX); if( M[SSPUR] > MaxMem ) { Element = Form_Def[SSPUR].Value; MaxMem = M[SSPUR]; } else if( M[SSPUR] > MaxMem2 ) { MaxMem2 = M[SSPUR]; } //----------------------------------------------------- double summem = 0.0; // = %PLAIN% + %PIT% + %PEAK% + %RIDGE% + %CHANNEL% + %SADDLE% + %BSLOPE% + %FSLOPE% + %SSLOPE% + %HOLLOW% + %FHOLLOW% + %SHOLLOW% + %SPUR% + %FSPUR% + %SSPUR% for(int i=0; iasGrid(); pTable = Parameters("TABLE" )->asTable(); bDown = Parameters("SORTING" )->asInt() == 1; nClasses = Parameters("COUNT" )->asInt(); zMin = Parameters("BZRANGE" )->asBool() ? Parameters("ZRANGE")->asRange()->Get_LoVal() : 0.0; zMax = Parameters("BZRANGE" )->asBool() ? Parameters("ZRANGE")->asRange()->Get_HiVal() : 0.0; if( !bDown && Parameters("BZRANGE")->asBool() && Parameters("METHOD")->asInt() == 1 ) { SG_UI_Msg_Add_Error(_TW( "The selected module parameter configuration (classification constant area, " "upward sorting and use of an user-specified elevation range) is not supported." )); return( false ); } if( !pDEM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } pTable->Destroy(); pTable->Set_Name(CSG_String::Format(SG_T("%s: %s"), _TL("Hypsometric Curve"), pDEM->Get_Name())); pTable->Add_Field(_TL("Relative Height"), SG_DATATYPE_Double); pTable->Add_Field(_TL("Relative Area") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Absolute Height"), SG_DATATYPE_Double); pTable->Add_Field(_TL("Absolute Area") , SG_DATATYPE_Double); switch( Parameters("METHOD")->asInt() ) { case 0: return( Calculate_A(pDEM, pTable, bDown, nClasses) ); case 1: default: return( Calculate_B(pDEM, pTable, bDown, nClasses, zMin, zMax) ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CHypsometry::Calculate_A(CSG_Grid *pDEM, CSG_Table *pTable, bool bDown, int nClasses) { int i; sLong n, *Cells_Count; double z, dz, A, a, Min, Max, za, zb; CSG_Table_Record *pRecord; //----------------------------------------------------- // 1. Min, Max, Area... A = 0; for(n=0; nGet_NCells() && Set_Progress_NCells(n); n++) { if( !pDEM->is_NoData(n) ) { if( A <= 0 ) { Min = Max = pDEM->asDouble(n); } else { z = pDEM->asDouble(n); if( Min > z ) { Min = z; } else if( Max < z ) { Max = z; } } A++; } } //----------------------------------------------------- // 2. Hypsometric Curve... if( A > 0 && Min < Max ) { Cells_Count = (sLong *)SG_Calloc(nClasses + 1, sizeof(sLong)); for(n=0; nGet_NCells() && Set_Progress_NCells(n); n++) { if( !pDEM->is_NoData(n) ) { i = (int)(nClasses * (Max - pDEM->asDouble(n)) / (Max - Min)); Cells_Count[i]++; } } dz = (Max - Min) / nClasses; a = A; for(i=nClasses; i>=0; i--) { za = a / A; a -= Cells_Count[bDown ? i : nClasses - i]; zb = a / A; pRecord = pTable->Add_Record(); pRecord->Set_Value(0, 100.0 * i * dz / (Max - Min)); // Relative Height pRecord->Set_Value(1, 100.0 * za); // Relative Area pRecord->Set_Value(2, Min + i * dz); // Absolute Height pRecord->Set_Value(3, a * pDEM->Get_Cellarea()); // Absolute Area } SG_Free(Cells_Count); return( true ); } SG_UI_Msg_Add_Error(_TL("Total area is zero or minimum elevation is equal or lower than maximum elevation!")); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CHypsometry::Calculate_B(CSG_Grid *pDEM, CSG_Table *pTable, bool bDown, int nClasses, double zMin, double zMax) { int x, y, i; sLong n, nMin, nMax, nStep, nRange; double z, zRange; //----------------------------------------------------- if( zMin < zMax && zMin < pDEM->Get_ZMax() && zMax > pDEM->Get_ZMin() ) { for(nMin=0; nMinGet_NCells() && Set_Progress_NCells(nMin); nMin++) { if( pDEM->Get_Sorted(nMin, x, y, !bDown) && zMin <= pDEM->asDouble(x, y) ) { zMin = pDEM->asDouble(x, y); break; } } for(nMax=pDEM->Get_NCells() - 1; nMax > nMin && Set_Progress_NCells(nMax); nMax--) { if( pDEM->Get_Sorted(nMax, x, y, !bDown) && zMax >= pDEM->asDouble(x, y) ) { zMax = pDEM->asDouble(x, y); break; } } } else { zMin = pDEM->Get_ZMin(); zMax = pDEM->Get_ZMax(); nMin = 0; nMax = pDEM->Get_NCells() - 1; } //----------------------------------------------------- if( (nRange = nMax - nMin) > 0 && (zRange = zMax - zMin) > 0 ) { CSG_Table_Record *pRecord; pTable->Destroy(); pTable->Add_Field(_TL("Relative Height"), SG_DATATYPE_Double); pTable->Add_Field(_TL("Relative Area") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Absolute Height"), SG_DATATYPE_Double); pTable->Add_Field(_TL("Absolute Area") , SG_DATATYPE_Double); pTable->Set_Name(CSG_String::Format(SG_T("%s: %s"), _TL("Hypsometric Curve"), pDEM->Get_Name())); //------------------------------------------------- nStep = nRange / nClasses; for(i=0, n=nMax; i<=nClasses; i++, n-=nStep) { if( pDEM->Get_Sorted(n, x, y, !bDown) ) { z = pDEM->asDouble(x, y); pRecord = pTable->Add_Record(); pRecord->Set_Value(0, 100.0 * i / nClasses); // Relative Area pRecord->Set_Value(1, 100.0 * (z - zMin) / zRange); // Relative Height pRecord->Set_Value(2, z); // Absolute Height pRecord->Set_Value(3, i * nStep * pDEM->Get_Cellarea()); // Absolute Area } } return( true ); } SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Elevation range (zMax (%.2f) - zMin (%.2f)) is equal or lower than zero!"), zMax, zMin)); return( false ); } //--------------------------------------------------------- int CHypsometry::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("METHOD")) ) { pParameters->Get_Parameter("BZRANGE")->Set_Enabled(pParameter->asInt() == 1); pParameters->Get_Parameter("ZRANGE")->Set_Enabled(pParameter->asInt() == 1); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("BZRANGE")) ) { pParameters->Get_Parameter("ZRANGE")->Set_Enabled(pParameter->asBool()); } //----------------------------------------------------- return (1); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Convergence.h0000664000175000017500000001104512565125415027064 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Convergence.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Convergence.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Convergence_H #define HEADER_INCLUDED__Convergence_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_morphometry_EXPORT CConvergence : public CSG_Module_Grid { public: CConvergence(void); protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDTM; bool Get_2x2_Gradient(int x, int y, int i, double &Slope, double &Aspect, double &Height); double Get_2x2 (int x, int y, bool bGradient); double Get_9x9 (int x, int y, bool bGradient); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Convergence_H saga-2.2.3/src/modules/terrain_analysis/ta_morphometry/Curvature_Classification.cpp0000664000175000017500000002111012565125415032146 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Curvature_Classification.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_morphometry // // // //-------------------------------------------------------// // // // Curvature_Classification.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Curvature_Classification.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCurvature_Classification::CCurvature_Classification(void) { Set_Name (_TL("Curvature Classification")); Set_Author ("O.Conrad (c) 2001"); Set_Description (_TW( "Surface curvature based terrain classification.\n" "Reference:\n" "Dikau, R. (1988):\n'Entwurf einer geomorphographisch-analytischen Systematik von Reliefeinheiten',\n" "Heidelberger Geographische Bausteine, Heft 5\n\n" "0 - V / V\n" "1 - GE / V\n" "2 - X / V\n" "3 - V / GR\n" "4 - GE / GR\n" "5 - X / GR\n" "6 - V / X\n" "7 - GE / X\n" "8 - X / X\n" )); Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CLASS" , _TL("Curvature Classification"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Char ); Parameters.Add_Value( NULL , "THRESHOLD" , _TL("Threshold for plane"), _TL(""), PARAMETER_TYPE_Double, 0.0005, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCurvature_Classification::On_Execute(void) { //----------------------------------------------------- double Threshold; CSG_Grid *pClass; m_pDEM = Parameters("DEM" )->asGrid(); pClass = Parameters("CLASS" )->asGrid(); Threshold = Parameters("THRESHOLD")->asDouble(); //----------------------------------------------------- for(int y=0; ySet_Value(x, y, (fabs(Plan) < Threshold ? 3 : Plan < 0 ? 0 : 6) + (fabs(Prof) < Threshold ? 1 : Prof < 0 ? 0 : 2) ); } else { pClass->Set_NoData(x, y); } } } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pClass, P) && P("COLORS_TYPE") && P("LUT") ) { int Color[9] = { SG_GET_RGB( 0, 0, 127), // V / V SG_GET_RGB( 0, 63, 200), // G / V SG_GET_RGB( 0, 127, 255), // X / V SG_GET_RGB(127, 200, 255), // V / G SG_GET_RGB(245, 245, 245), // G / G SG_GET_RGB(255, 200, 127), // X / G SG_GET_RGB(255, 127, 0), // V / X SG_GET_RGB(200, 63, 0), // G / X SG_GET_RGB(127, 0, 0), // X / X }; //------------------------------------------------- CSG_Strings Name, Desc; Name += _TL( "V / V" ); Desc += _TL( "V / V" ); Name += _TL("GE / V" ); Desc += _TL("GE / V" ); Name += _TL( "X / V" ); Desc += _TL( "X / V" ); Name += _TL( "V / GR"); Desc += _TL( "V / GR"); Name += _TL("GE / GR"); Desc += _TL("GE / GR"); Name += _TL( "X / GR"); Desc += _TL( "X / GR"); Name += _TL( "V / X" ); Desc += _TL( "V / X" ); Name += _TL("GE / X" ); Desc += _TL("GE / X" ); Name += _TL( "X / X" ); Desc += _TL( "X / X" ); //------------------------------------------------- CSG_Table *pTable = P("LUT")->asTable(); pTable->Del_Records(); for(int i=0; i<9; i++) { CSG_Table_Record *pRecord = pTable->Add_Record(); pRecord->Set_Value(0, Color[i]); pRecord->Set_Value(1, Name [i].c_str()); pRecord->Set_Value(2, Desc [i].c_str()); pRecord->Set_Value(3, i); pRecord->Set_Value(4, i); } P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table DataObject_Set_Parameters(pClass, P); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCurvature_Classification::Get_Curvature(int x, int y, double &Plan, double &Profile) { static const int Index[8] = { 5, 8, 7, 6, 3, 0, 1, 2 }; if( !m_pDEM->is_InGrid(x, y) ) { return( false ); } double z = m_pDEM->asDouble(x, y), Z[9]; Z[4] = 0.0; for(int i=0, ix, iy; i<8; i++) { if( m_pDEM->is_InGrid(ix = Get_xTo(i, x), iy = Get_yTo(i, y)) ) { Z[Index[i]] = m_pDEM->asDouble(ix, iy) - z; } else if( m_pDEM->is_InGrid(ix = Get_xFrom(i, x), iy = Get_yFrom(i, y)) ) { Z[Index[i]] = z - m_pDEM->asDouble(ix, iy); } else { Z[Index[i]] = 0.0; } } double D = ((Z[3] + Z[5]) / 2.0 - Z[4]) * 2.00 / Get_Cellarea(); double E = ((Z[1] + Z[7]) / 2.0 - Z[4]) * 2.00 / Get_Cellarea(); double F = (Z[0] - Z[2] - Z[6] + Z[8]) * 0.25 / Get_Cellarea(); double G = (Z[5] - Z[3]) * 0.50 / Get_Cellsize(); double H = (Z[7] - Z[1]) * 0.50 / Get_Cellsize(); Profile = -2.0 * (D * G*G + E * H*H + F*G*H) / (G*G + H*H); Plan = -2.0 * (E * G*G + D * H*H - F*G*H) / (G*G + H*H); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/0000775000175000017500000000000012634325751024617 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/FillSinks_WL.h0000664000175000017500000001173512565125415027275 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: FillSinks_WL.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // FillSinks_WL.h // // // // Copyright (C) 2007 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: reklovw@web.de // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__FillSinks_WL_H #define HEADER_INCLUDED__FillSinks_WL_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include #include #include using namespace std; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFillSinks_WL_Node { public: CFillSinks_WL_Node() : spill( 0 ) {} ~CFillSinks_WL_Node(){} struct Greater : public binary_function< CFillSinks_WL_Node, CFillSinks_WL_Node, bool > { bool operator()(const CFillSinks_WL_Node n1, const CFillSinks_WL_Node n2) const { return n1.spill > n2.spill; } }; int x; int y; double spill; }; //--------------------------------------------------------- class ta_preprocessor_EXPORT CFillSinks_WL : public CSG_Module_Grid { public: CFillSinks_WL(void); virtual ~CFillSinks_WL(void); protected: virtual bool On_Execute(void); private: typedef vector< CFillSinks_WL_Node > nodeVector; typedef priority_queue< CFillSinks_WL_Node, nodeVector, CFillSinks_WL_Node::Greater > PriorityQ; CSG_Grid *pFilled; int Get_Dir(int x, int y, double z); }; //--------------------------------------------------------- class ta_preprocessor_EXPORT CFillSinks_WL_XXL : public CSG_Module_Grid { public: CFillSinks_WL_XXL(void); virtual ~CFillSinks_WL_XXL(void); protected: virtual bool On_Execute(void); private: typedef vector< CFillSinks_WL_Node > nodeVector; typedef priority_queue< CFillSinks_WL_Node, nodeVector, CFillSinks_WL_Node::Greater > PriorityQ; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__FillSinks_WL_H saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/FillSinks_WL.cpp0000664000175000017500000002103212565125415027617 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: FillSinks_WL.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // FillSinks_WL.cpp // // // // Copyright (C) 2007 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: reklovw@web.de // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "FillSinks_WL.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// CFillSinks_WL::CFillSinks_WL(void) { Set_Name (_TL("Fill Sinks (Wang & Liu)")); Set_Author (_TL("Copyrights (c) 2007 by Volker Wichmann")); Set_Description (_TW( "This module uses an algorithm proposed by Wang & Liu to identify and fill surface depressions in " "digital elevation models.\n" "The method was enhanced to allow the creation of hydrologic sound elevation models, i.e. not only to " "fill the depression(s) but also to preserve a downward slope along the flow path. If desired, this is accomplished " "by preserving a minimum slope gradient (and thus elevation difference) between cells.\n" "This is the fully featured version of the module creating a depression less DEM, a flow path grid and " "a grid with watershed basins. If you encounter problems processing large data sets " "(e.g. LIDAR data) with this module try the basic version (Fill Sinks XXL).\n\n\n" "References:\n" "Wang, L. & H. Liu (2006): An efficient method for identifying and filling surface depressions in " "digital elevation models for hydrologic analysis and modelling. International Journal of Geographical " "Information Science, Vol. 20, No. 2: 193-213.\n" )); Parameters.Add_Grid( NULL, "ELEV", _TL("DEM"), _TL("Digital elevation model"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "FILLED", _TL("Filled DEM"), _TL("Depression-free digital elevation model"), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "FDIR", _TL("Flow Directions"), _TL("Computed flow directions, 0=N, 1=NE, 2=E, ... 7=NW"), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "WSHED", _TL("Watershed Basins"), _TL("Delineated watershed basins"), PARAMETER_OUTPUT ); Parameters.Add_Value( 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.1, 0.0, true ); } //--------------------------------------------------------- CFillSinks_WL::~CFillSinks_WL(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// bool CFillSinks_WL::On_Execute(void) { CSG_Grid *pElev, *pSeed, *pFdir, *pWshed; PriorityQ theQueue; CFillSinks_WL_Node tempNode; int x, y, ix, iy, i; int inverse[8] = { 4, 5, 6, 7, 0, 1, 2, 3 }; double z, iz, progress; double minslope, mindiff[8]; bool preserve; sLong id; pElev = Parameters("ELEV")->asGrid(); pFilled = Parameters("FILLED")->asGrid(); pFdir = Parameters("FDIR")->asGrid(); pWshed = Parameters("WSHED")->asGrid(); minslope = Parameters("MINSLOPE")->asDouble(); pFilled->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pElev->Get_Name(), _TL("no sinks"))); if( minslope > 0.0 ) { minslope = tan(minslope * M_DEG_TO_RAD); for(i=0; i<8; i++) mindiff[i] = minslope * Get_Length(i); preserve = true; } else preserve = false; pSeed = (CSG_Grid *) new CSG_Grid(SG_DATATYPE_Bit, pElev->Get_NX(), pElev->Get_NY(), pElev->Get_Cellsize(), pElev->Get_XMin(), pElev->Get_YMin()); pFilled->Assign_NoData(); pWshed->Assign_NoData(); pFdir->Assign_NoData(); pSeed->Assign(0.0); // fill priority queue with boundary, i.e. seed cells id = 0; for(y=0; yis_NoData(x, y) ) { for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( !is_InGrid(ix, iy) || pElev->is_NoData(ix, iy) ) { z = pElev->asDouble(x, y); pFilled->Set_Value(x, y, z); pSeed->Set_Value(x, y, 1.0); pWshed->Set_Value(x, y, id); id += 1; tempNode.x = x; tempNode.y = y; tempNode.spill = z; theQueue.push( tempNode ); break; } } } } } // work through least cost path progress = 0.0; while( !theQueue.empty() ) { PriorityQ::value_type tempNode = theQueue.top(); x = tempNode.x; y = tempNode.y; theQueue.pop(); id = (sLong) pWshed->asDouble(x, y); z = pFilled->asDouble(x, y); for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !pElev->is_NoData(ix, iy) ) { if( pFilled->is_NoData(ix, iy) ) { iz = pElev->asDouble(ix, iy); if( preserve ) { if( iz < (z + mindiff[i]) ) iz = z + mindiff[i]; } else if( iz <= z ) { iz = z; pFdir->Set_Value(ix, iy, inverse[i]); } tempNode.x = ix; tempNode.y = iy; tempNode.spill = iz; theQueue.push( tempNode ); pFilled->Set_Value(ix, iy, iz); pWshed->Set_Value(ix, iy, id); } else if( pSeed->asInt(ix, iy) == 1 ) pWshed->Set_Value(ix, iy, id); } } if( pFdir->is_NoData(x, y) ) pFdir->Set_Value(x, y, Get_Dir(x, y, z)); progress += 1.0; if( ((int)progress) % 10000 == 0 ) Set_Progress(progress, (double)pElev->Get_NCells()); //DataObject_Update(pFilled, pElev->Get_ZMin(), pElev->Get_ZMax(), true); } delete (pSeed); return (true); } int CFillSinks_WL::Get_Dir(int x, int y, double z) { int ix, iy, i, steepestn; double iz, max, gradient; max = 0.0; steepestn = -1; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !pFilled->is_NoData(ix, iy) && (iz = pFilled->asDouble(ix, iy)) < z) { gradient = (z - iz) / Get_Length(i); if( max < gradient ) { max = gradient; steepestn = i; } } } return (steepestn); }saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/burn_in_streams.cpp0000664000175000017500000002327212565125415030521 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: burn_in_streams.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // burn_in_streams.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "burn_in_streams.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CBurnIn_Streams::CBurnIn_Streams(void) { Set_Name (_TL("Burn Stream Network into DEM")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Burns a stream network into a Digital Elevation Model (DEM). " "Stream cells have to be coded with valid data values, all other " "cells should be set to no data value. " "First two methods decrease . " "The third method ensures a steady downstream gradient. An elevation " "decrease is only applied, if a downstream cell is equally high or higher. " "You should provide a grid with flow directions for determination of " "downstream cells. The 'Sink Drainage Route Detection' module offers " "such flow directions. " )); Parameters.Add_Grid( NULL, "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "BURN" , _TL("Processed DEM"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "STREAM" , _TL("Streams"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "FLOWDIR" , _TL("Flow Direction"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Choice( NULL, "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("simply decrease cell's value by epsilon"), _TL("lower cell's value to neighbours minimum value minus epsilon"), _TL("trace stream network downstream") ), 0 ); Parameters.Add_Value( NULL, "EPSILON" , _TL("Epsilon"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CBurnIn_Streams::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Get_Parameter("FLOWDIR")->Set_Enabled(pParameter->asInt() == 2); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CBurnIn_Streams::On_Execute(void) { //----------------------------------------------------- m_pDEM = Parameters("BURN" )->asGrid(); m_pStream = Parameters("STREAM" )->asGrid(); m_Epsilon = Parameters("EPSILON")->asDouble(); int Method = Parameters("METHOD" )->asInt(); //----------------------------------------------------- if( !m_pDEM ) { m_pDEM = Parameters("DEM")->asGrid(); } else { m_pDEM->Assign(Parameters("DEM")->asGrid()); m_pDEM->Set_Name(CSG_String::Format(SG_T("%s [%s]"), Parameters("DEM")->asGrid()->Get_Name(), _TL("Burned Streams"))); } //----------------------------------------------------- bool bResult = false; switch( Method ) { case 0: bResult = Burn_Simple(false); break; // simply decrease cell's value by epsilon case 1: bResult = Burn_Simple( true); break; // lower cell's value to neighbours minimum value minus epsilon case 2: bResult = Burn_Trace(); break; // trace stream network downstream } //----------------------------------------------------- if( Parameters("BURN")->asGrid() == NULL ) { DataObject_Update(m_pDEM); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CBurnIn_Streams::Burn_Simple(bool bNeighbours) { for(int y=0; yis_NoData(x, y) && !m_pDEM->is_NoData(x, y) ) { double zMin = m_pDEM->asDouble(x, y); if( bNeighbours ) // assure lower than neighourhood { for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && m_pStream->is_NoData(ix, iy) && m_pDEM->asDouble(ix, iy) < zMin ) { zMin = m_pDEM->asDouble(ix, iy); } } } m_pDEM->Set_Value(x, y, zMin - m_Epsilon); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CBurnIn_Streams::Burn_Trace(void) { int y; //----------------------------------------------------- CSG_Grid Count (*Get_System(), SG_DATATYPE_Char); CSG_Grid Stream(*Get_System(), SG_DATATYPE_Char); CSG_Grid *pDir = Parameters("FLOWDIR")->asGrid(); //----------------------------------------------------- for(y=0; yis_NoData(x, y) && !m_pDEM->is_NoData(x, y) ) { int ix, iy, i = pDir->is_NoData(x, y) ? m_pDEM->Get_Gradient_NeighborDir(x, y) : pDir->asInt(x, y); Stream.Set_Value(x, y, i); if( i >= 0 && Get_System()->Get_Neighbor_Pos(i, x, y, ix, iy) ) { Count.Add_Value(ix, iy, 1); } } else { Stream.Set_NoData(x, y); } } } m_pStream = &Stream; //----------------------------------------------------- for(y=0; yis_NoData(x, y) && Count.asInt(x, y) == 0 ) { Lock_Create(); Burn_Trace(x, y); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- void CBurnIn_Streams::Burn_Trace(int x, int y) { if( !is_Locked(x, y) ) { Lock_Set(x, y); int ix, iy; if( Get_System()->Get_Neighbor_Pos(m_pStream->asInt(x, y), x, y, ix, iy) && !m_pStream->is_NoData(ix, iy) ) { if( m_pDEM->asDouble(ix, iy) >= m_pDEM->asDouble(x, y) ) { m_pDEM->Set_Value(ix, iy, m_pDEM->asDouble(x, y) - m_Epsilon); } Burn_Trace(ix, iy); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/FillSinks.h0000664000175000017500000001022212565125415026661 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: FillSinks.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // FillSinks.h // // // // Copyright (C) 2003 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: volker.wichmann@geographie.uni-muenchen.de // // // // contact: Volker Wichmann // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__FillSinks_H #define HEADER_INCLUDED__FillSinks_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_preprocessor_EXPORT CFillSinks : public CSG_Module_Grid { public: CFillSinks(void); virtual ~CFillSinks(void); protected: virtual bool On_Execute (void); private: int R, C, R0[8], C0[8], dR[8], dC[8], fR[8], fC[8]; double epsilon[8]; CSG_Grid *pDEM, *pResult, *pW, *pBorder; bool Next_Cell (int i); void Init_Altitude (void); void Dry_upward_cell (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__FillSinks_H saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/Makefile.in0000664000175000017500000005577712622651176026711 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/ta_preprocessor DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libta_preprocessor_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libta_preprocessor_la_OBJECTS = burn_in_streams.lo FillSinks.lo \ FillSinks_WL.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) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libta_preprocessor_la_SOURCES) DIST_SOURCES = $(libta_preprocessor_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_preprocessor.la libta_preprocessor_la_SOURCES = \ burn_in_streams.cpp\ FillSinks.cpp\ FillSinks_WL.cpp\ FillSinks_WL_XXL.cpp\ MLB_Interface.cpp\ Flat_Detection.cpp\ Pit_Eliminator.cpp\ Pit_Router.cpp\ burn_in_streams.h\ FillSinks.h\ FillSinks_WL.h\ MLB_Interface.h\ Flat_Detection.h\ Pit_Eliminator.h\ Pit_Router.h libta_preprocessor_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) --foreign src/modules/terrain_analysis/ta_preprocessor/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/terrain_analysis/ta_preprocessor/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libta_preprocessor.la: $(libta_preprocessor_la_OBJECTS) $(libta_preprocessor_la_DEPENDENCIES) $(EXTRA_libta_preprocessor_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libta_preprocessor_la_OBJECTS) $(libta_preprocessor_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FillSinks.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FillSinks_WL.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FillSinks_WL_XXL.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flat_Detection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Pit_Eliminator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Pit_Router.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/burn_in_streams.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/Pit_Router.h0000664000175000017500000001263112565125415027065 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Pit_Router.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // Pit_Router.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Pit_Router_H #define HEADER_INCLUDED__Pit_Router_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_preprocessor_EXPORT CPit_Router : public CSG_Module_Grid { public: CPit_Router(void); virtual ~CPit_Router(void); int Get_Routes (CSG_Grid *pDEM, CSG_Grid *pRoutes, double Threshold = -1.0); protected: virtual bool On_Execute (void); private: typedef struct { int xMin, yMin, xMax, yMax; } TGEO_iRect; typedef struct { bool bDrained; double z; } TPit; typedef struct TPit_Outlet { int x, y, Pit_ID[8]; struct TPit_Outlet *Prev, *Next; } TPit_Outlet; int **m_Junction, *m_nJunctions; double m_Threshold, m_zThr, m_zMax; CSG_Grid *m_pDEM, *m_pRoute, *m_pFlats, *m_pPits, m_Route; TGEO_iRect *m_Flat; TPit *m_Pit; TPit_Outlet *m_Outlets; bool Initialize (void); void Finalize (void); int Find_Pits (void); int Find_Outlets (int nPits); int Find_Route (TPit_Outlet *pOutlet); void Add_Junction (int iID, int jID); bool Get_Junction (int iID, int jID); void Drain_Pit (int x, int y, int Pit_ID); void Drain_Flat (int x, int y ); void Mark_Flat (int x, int y, TGEO_iRect *pFlat, int Flat_ID, int Pit_ID); int Process_Threshold (void); void Check_Threshold (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Pit_Router_H saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/FillSinks_WL_XXL.cpp0000664000175000017500000001574312565125415030366 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: FillSinks_WL_XXL.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // FillSinks_WL.cpp // // // // Copyright (C) 2007 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: reklovw@web.de // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "FillSinks_WL.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// CFillSinks_WL_XXL::CFillSinks_WL_XXL(void) { Set_Name (_TL("Fill Sinks XXL (Wang & Liu)")); Set_Author (_TL("Copyrights (c) 2007 by Volker Wichmann")); Set_Description (_TW( "This module uses an algorithm proposed by Wang & Liu to identify and fill surface depressions in " "digital elevation models.\n" "The method was enhanced to allow the creation of hydrologic sound elevation models, i.e. not only to " "fill the depression(s) but also to preserve a downward slope along the flow path. If desired, this is accomplished " "by preserving a minimum slope gradient (and thus elevation difference) between cells.\n" "This version of the module is designed to work on large data sets (e.g. LIDAR data), with smaller " "datasets you might like to check out the fully featured standard version of the module.\n\n\n" "References:\n" "Wang, L. & H. Liu (2006): An efficient method for identifying and filling surface depressions in " "digital elevation models for hydrologic analysis and modelling. International Journal of Geographical " "Information Science, Vol. 20, No. 2: 193-213.\n" )); Parameters.Add_Grid( NULL, "ELEV", _TL("DEM"), _TL("Digital elevation model"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "FILLED", _TL("Filled DEM"), _TL("Depression-free digital elevation model"), PARAMETER_OUTPUT ); Parameters.Add_Value( 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.1, 0.0, true ); } //--------------------------------------------------------- CFillSinks_WL_XXL::~CFillSinks_WL_XXL(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// bool CFillSinks_WL_XXL::On_Execute(void) { CSG_Grid *pElev, *pFilled; PriorityQ theQueue; CFillSinks_WL_Node tempNode; int x, y, ix, iy, i; double z, iz, progress; double minslope, mindiff[8]; bool preserve; pElev = Parameters("ELEV")->asGrid(); pFilled = Parameters("FILLED")->asGrid(); minslope = Parameters("MINSLOPE")->asDouble(); pFilled->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pElev->Get_Name(), _TL("no sinks"))); if( minslope > 0.0 ) { minslope = tan(minslope * M_DEG_TO_RAD); for(i=0; i<8; i++) mindiff[i] = minslope * Get_Length(i); preserve = true; } else preserve = false; pFilled->Assign_NoData(); // fill priority queue with boundary cells, i.e. seed cells for(y=0; yis_NoData(x, y) ) { for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( !is_InGrid(ix, iy) || pElev->is_NoData(ix, iy) ) { z = pElev->asDouble(x, y); tempNode.x = x; tempNode.y = y; tempNode.spill = z; theQueue.push( tempNode ); pFilled->Set_Value(x, y, z); break; } } } } } // process queue progress = 0.0; while( !theQueue.empty() ) { PriorityQ::value_type tempNode = theQueue.top(); x = tempNode.x; y = tempNode.y; theQueue.pop(); z = pFilled->asDouble(x, y); for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !pElev->is_NoData(ix, iy) && pFilled->is_NoData(ix, iy) ) { iz = pElev->asDouble(ix, iy); if( preserve ) { if( iz < (z + mindiff[i]) ) iz = z + mindiff[i]; } else if( iz < z ) iz = z; tempNode.x = ix; tempNode.y = iy; tempNode.spill = iz; theQueue.push( tempNode ); pFilled->Set_Value(ix, iy, iz); } } progress += 1.0; if( ((int)progress) % 10000 == 0 ) Set_Progress(progress, (double)pElev->Get_NCells()); //DataObject_Update(pFilled, pElev->Get_ZMin(), pElev->Get_ZMax(), true); } return (true); } saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/Pit_Eliminator.cpp0000664000175000017500000002446612565125415030254 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Pit_Eliminator.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // Pit_Eliminator.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Pit_Eliminator.h" #include "Pit_Router.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPit_Eliminator::CPit_Eliminator(void) { Set_Name (_TL("Sink Removal")); Set_Author (SG_T("O. Conrad (c) 2001")); Set_Description (_TW( "" )); Parameters.Add_Grid( NULL, "DEM" , _TL("DEM"), _TL("Digital Elevation Model that has to be processed"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "SINKROUTE" , _TL("Sink Route"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "DEM_PREPROC", _TL("Preprocessed DEM"), _TL("Preprocessed DEM. If this is not set changes will be stored in the original DEM grid."), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL, "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Deepen Drainage Routes"), _TL("Fill Sinks") ), 1 ); Parameters.Add_Value( NULL , "THRESHOLD" , _TL("Threshold"), _TL(""), PARAMETER_TYPE_Bool ); Parameters.Add_Value( NULL , "THRSHEIGHT" , _TL("Threshold Height"), _TW("The parameter describes the maximum depth of a sink to be considered for removal [map units]. " "This allows to exclude deeper sinks from filling."), PARAMETER_TYPE_Double , 100 ); } //--------------------------------------------------------- CPit_Eliminator::~CPit_Eliminator(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPit_Eliminator::On_Execute(void) { bool bResult, bKillRoute; int Method, nPits; CPit_Router Router; //----------------------------------------------------- bResult = true; pRoute = Parameters("SINKROUTE") ->asGrid(); Method = Parameters("METHOD") ->asInt(); pDTM = Parameters("DEM_PREPROC") ->asGrid(); if( pDTM == NULL ) { pDTM = Parameters("DEM")->asGrid(); } else if( pDTM != Parameters("DEM")->asGrid() ) { pDTM->Assign(Parameters("DEM")->asGrid()); pDTM->Set_Name(CSG_String::Format(SG_T("%s [%s]"), Parameters("DEM")->asGrid()->Get_Name(), _TL("no sinks"))); } //----------------------------------------------------- bKillRoute = pRoute == NULL; if( bKillRoute ) { pRoute = SG_Create_Grid(pDTM); nPits = Router.Get_Routes(pDTM, pRoute, Parameters("THRESHOLD")->asBool() ? Parameters("THRSHEIGHT")->asDouble() : -1.0); } else { nPits = 1; } //----------------------------------------------------- if( nPits > 0 ) { Process_Set_Text(_TL("Initializing direction matrix...")); Create_goRoute(); //------------------------------------------------- switch( Method ) { case 0: Process_Set_Text(_TL("I'm diggin'...")); bResult = Dig_Channels(); break; case 1: Process_Set_Text(_TL("I'm fillin'...")); bResult = Fill_Sinks(); break; default: bResult = false; break; } delete( goRoute ); } //----------------------------------------------------- if( bKillRoute ) { delete(pRoute); } Lock_Destroy(); return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPit_Eliminator::Create_goRoute(void) { int x, y; goRoute = SG_Create_Grid(pRoute); for(y=0; ySet_NoData(x, y); } else if( pRoute->asChar(x, y) > 0 ) { goRoute->Set_Value(x, y, pRoute->asChar(x, y) % 8 ); } else { goRoute->Set_Value(x, y, pDTM->Get_Gradient_NeighborDir(x, y)); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPit_Eliminator::Dig_Channels(void) { bool bPit; int x, y, i, ix, iy; double z; for(y=0; yasDouble(x, y); for(i=0, bPit=true; i<8 && bPit; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( !is_InGrid(ix, iy) || z > pDTM->asDouble(ix, iy) ) { bPit = false; } } if( bPit ) { Dig_Channel(x, y); } } } return( is_Progress() ); } //--------------------------------------------------------- void CPit_Eliminator::Dig_Channel(int x, int y) { bool bContinue; int goDir; double z; z = pDTM->asDouble(x, y); bContinue = true; do { z -= M_ALMOST_ZERO; goDir = goRoute->asChar(x, y); if( goDir < 0 ) { bContinue = false; } else { x = Get_xTo(goDir, x); y = Get_yTo(goDir, y); if( !is_InGrid(x, y) || z > pDTM->asDouble(x, y) ) { bContinue = false; } else { pDTM->Set_Value(x, y, z); } } } while( bContinue ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPit_Eliminator::Fill_Sinks(void) { int x, y; for(y=0; yasDouble (x, y); i = goRoute ->asChar (x, y); ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( !is_InGrid(ix, iy) || z > pDTM->asDouble(ix, iy) ) { for(i=0, j=4, bOutlet=false; i<8 && !bOutlet; i++, j=(j+1)%8) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && goRoute->asChar(ix, iy) == j && z > pDTM->asDouble(ix, iy) ) { bOutlet = true; } } if( bOutlet ) { Lock_Create(); Lock_Set(x, y); for(i=0, j=4; i<8; i++, j=(j+1)%8) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); Fill_Sink(ix, iy, j, z); } } } } //--------------------------------------------------------- void CPit_Eliminator::Fill_Sink(int x, int y, int j, double z) { int i, ix, iy; if( is_InGrid(x, y) && !is_Locked(x, y) && goRoute->asChar(x, y) == j ) { Lock_Set(x, y); z += M_ALMOST_ZERO * Get_UnitLength(j); if( pDTM->asDouble(x, y) < z ) { pDTM->Set_Value(x, y, z); for(i=0, j=4; i<8; i++, j=(j+1)%8) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); Fill_Sink(ix, iy, j, z); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/burn_in_streams.h0000664000175000017500000001117612565125415030166 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: burn_in_streams.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // burn_in_streams.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__burn_in_streams_H #define HEADER_INCLUDED__burn_in_streams_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CBurnIn_Streams : public CSG_Module_Grid { public: CBurnIn_Streams(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: double m_Epsilon; CSG_Grid *m_pDEM, *m_pStream; bool Burn_Simple (bool bNeighbours); bool Burn_Trace (void); void Burn_Trace (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__burn_in_streams_H saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/Flat_Detection.cpp0000664000175000017500000001676312565125415030222 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flat_Detection.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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; yis_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)); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/MLB_Interface.cpp0000664000175000017500000001146012565125415027715 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Preprocessing" )); case MLB_INFO_Category: return( _TL("Terrain Analysis") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2001, V. Wichmann (c) 2003") ); case MLB_INFO_Description: return( _TL("Tools for the preprocessing of digital terrain models." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Terrain Analysis|Preprocessing" )); } } //--------------------------------------------------------- #include "Flat_Detection.h" #include "Pit_Router.h" #include "Pit_Eliminator.h" #include "FillSinks.h" #include "FillSinks_WL.h" #include "burn_in_streams.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CFlat_Detection ); case 1: return( new CPit_Router ); case 2: return( new CPit_Eliminator ); case 3: return( new CFillSinks ); case 4: return( new CFillSinks_WL ); case 5: return( new CFillSinks_WL_XXL ); case 6: return( new CBurnIn_Streams ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/Makefile.am0000664000175000017500000000147312565125415026656 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_preprocessor.la libta_preprocessor_la_SOURCES =\ burn_in_streams.cpp\ FillSinks.cpp\ FillSinks_WL.cpp\ FillSinks_WL_XXL.cpp\ MLB_Interface.cpp\ Flat_Detection.cpp\ Pit_Eliminator.cpp\ Pit_Router.cpp\ burn_in_streams.h\ FillSinks.h\ FillSinks_WL.h\ MLB_Interface.h\ Flat_Detection.h\ Pit_Eliminator.h\ Pit_Router.h libta_preprocessor_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/MLB_Interface.h0000664000175000017500000000774512565125415027375 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Terrain_Analysis // // // //-------------------------------------------------------// // // // ta_preprocessor // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_preprocessor_H #define HEADER_INCLUDED__ta_preprocessor_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef ta_preprocessor_EXPORTS #define ta_preprocessor_EXPORT _SAGA_DLL_EXPORT #else #define ta_preprocessor_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ta_preprocessor_H saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/Pit_Eliminator.h0000664000175000017500000001144212565125415027707 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Pit_Eliminator.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // Pit_Eliminator.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Pit_Eliminator_H #define HEADER_INCLUDED__Pit_Eliminator_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_preprocessor_EXPORT CPit_Eliminator : public CSG_Module_Grid { public: CPit_Eliminator(void); virtual ~CPit_Eliminator(void); protected: virtual bool On_Execute (void); private: CSG_Grid *pDTM, *pRoute, *goRoute; void Create_goRoute (void); bool Dig_Channels (void); void Dig_Channel (int x, int y); bool Fill_Sinks (void); void Fill_Check (int x, int y); void Fill_Sink (int x, int y, int j, double z); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Pit_Eliminator_H saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/Pit_Router.cpp0000664000175000017500000005640212565125415027424 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Pit_Router.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // Pit_Router.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Pit_Router.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define IS_Flat(a,b) (a==b) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPit_Router::CPit_Router(void) { Set_Name (_TL("Sink Drainage Route Detection")); Set_Author (SG_T("O. Conrad (c) 2001")); Set_Description (_TW( "" )); Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SINKROUTE" , _TL("Sink Route"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "THRESHOLD" , _TL("Threshold"), _TL(""), PARAMETER_TYPE_Bool ); Parameters.Add_Value( NULL , "THRSHEIGHT" , _TL("Threshold Height"), _TL(""), PARAMETER_TYPE_Double , 100 ); } //--------------------------------------------------------- CPit_Router::~CPit_Router(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPit_Router::On_Execute(void) { return( Get_Routes( Parameters("ELEVATION")->asGrid(), Parameters("SINKROUTE")->asGrid(), Parameters("THRESHOLD")->asBool() ? Parameters("THRSHEIGHT")->asDouble() : -1.0 ) >= 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPit_Router::Get_Routes(CSG_Grid *pDEM, CSG_Grid *pRoute, double Threshold) { int iPit, nPits, n; TPit_Outlet *pOutlet, *pNext; //----------------------------------------------------- m_pDEM = pDEM; m_pRoute = pRoute; m_Threshold = Threshold; //----------------------------------------------------- m_pPits = NULL; m_Pit = NULL; m_pFlats = NULL; m_Flat = NULL; m_Outlets = NULL; //----------------------------------------------------- Get_System()->Assign(m_pDEM->Get_System()); //----------------------------------------------------- if( Initialize() ) { //------------------------------------------------- // 1. Pits/Flats finden... SG_UI_Process_Set_Text(_TL("Find Pits")); nPits = Find_Pits(); if( nPits > 0 ) { //--------------------------------------------- // 2. Pit/Flat-Zugehoerigkeiten u. pot. m_Outlets finden... SG_UI_Process_Set_Text(_TL("Find Outlets")); Find_Outlets(nPits); //--------------------------------------------- // 3. Routing vornehmen... SG_UI_Process_Set_Text(_TL("Routing")); iPit = 0; do { pOutlet = m_Outlets; while( pOutlet && SG_UI_Process_Get_Okay(false) ) { pNext = pOutlet->Next; n = Find_Route(pOutlet); if( n > 0 ) { pOutlet = m_Outlets; iPit += n; SG_UI_Process_Set_Progress(iPit, nPits); } else { pOutlet = pNext; } } if( iPit < nPits ) // Thresholding may have prevented total removal of pits... { for(n=0; n 0.0 ) { nPits -= Process_Threshold(); } } //----------------------------------------------------- Process_Set_Text(_TL("Finalize")); Finalize(); if( Process_Get_Okay(false) ) { if( nPits > 0 ) { Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("number of processed sinks"), nPits)); return( nPits ); } else { Message_Add(_TL("No sinks have been detected.")); } } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPit_Router::Initialize(void) { if( m_pDEM && m_pDEM->is_Valid() && m_pDEM->Set_Index() && m_pRoute && m_pRoute->is_Valid() && m_pDEM->Get_System() == m_pRoute->Get_System() ) { m_pRoute->Assign(); m_pPits = SG_Create_Grid(m_pDEM, SG_DATATYPE_Int); m_pPits->Assign(); m_Pit = NULL; m_pFlats = NULL; m_Flat = NULL; m_Outlets = NULL; return( true ); } return( false ); } //--------------------------------------------------------- void CPit_Router::Finalize(void) { TPit_Outlet *pOutlet; if( m_pPits ) { delete( m_pPits ); m_pPits = NULL; } if( m_Pit ) { SG_Free(m_Pit); m_Pit = NULL; } if( m_pFlats ) { delete( m_pFlats ); m_pFlats = NULL; } if( m_Flat ) { SG_Free(m_Flat); m_Flat = NULL; } while( m_Outlets ) { pOutlet = m_Outlets->Next; SG_Free(m_Outlets); m_Outlets = pOutlet; } m_Outlets = NULL; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPit_Router::Find_Pits(void) { bool bLower, bFlat; int x, y, i, ix, iy, nFlats, nPits; sLong n; double z; TPit *pPit; //----------------------------------------------------- nFlats = 0; nPits = 0; for(n=0; nGet_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_pPits->asInt(x, y) == 0 ) // ...oder schon als m_Flat markiert sein... { z = m_pDEM->asDouble(x,y); bLower = false; bFlat = false; for(i=0; i<8 && !bLower; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( !m_pDEM->is_InGrid(ix, iy) || z > m_pDEM->asDouble(ix, iy) ) { bLower = true; } else if( IS_Flat(z, m_pDEM->asDouble(ix,iy)) ) { bFlat = true; } } //----------------------------------------- if( !bLower ) // Pit or Flat... { nPits++; m_pPits->Set_Value(x,y, nPits); m_Pit = (TPit *)SG_Realloc(m_Pit, nPits * sizeof(TPit)); pPit = m_Pit + nPits - 1; pPit->bDrained = false; pPit->z = z; if( bFlat ) { nFlats++; m_Flat = (TGEO_iRect *)SG_Realloc(m_Flat, nFlats * sizeof(TGEO_iRect)); Mark_Flat(x, y, m_Flat + nFlats - 1, nFlats, nPits); } } } } return( nPits ); } //--------------------------------------------------------- int CPit_Router::Find_Outlets(int nPits) { bool bOutlet, bExArea, bGoExArea; int x, y, i, ix, iy, iMin, iID, j, jID, Pit_ID[8]; sLong n; double z, dz, dzMin; TPit_Outlet *pOutlet; //----------------------------------------------------- if( nPits > 0 && SG_UI_Process_Get_Okay(false) ) { pOutlet = NULL; m_nJunctions = (int *)SG_Calloc(nPits, sizeof(int )); m_Junction = (int **)SG_Calloc(nPits, sizeof(int *)); //------------------------------------------------- for(n=0; nGet_Sorted(n, x, y, false) && m_pPits->asInt(x,y) == 0 ) { z = m_pDEM->asDouble(x,y); iMin = -1; bOutlet = false; bGoExArea = false; //----------------------------------------- for(i=0; i<8; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); bExArea = !m_pDEM->is_InGrid(ix, iy); if( bExArea || z > m_pDEM->asDouble(ix,iy) ) { Pit_ID[i] = iID = bExArea ? 0 : m_pPits->asInt(ix,iy); if( iID >= 0 ) { for(j=0; j= 0 && !Get_Junction(iID, jID) ) { bOutlet = true; } } } //--------------------------------- if( !bGoExArea ) { if( bExArea ) { bGoExArea = true; iMin = i; } else { dz = (z - m_pDEM->asDouble(ix,iy)) / Get_Length(i); if( iMin < 0 || dzMin < dz ) { iMin = i; dzMin = dz; } } } } else { Pit_ID[i] = -1; } } //----------------------------------------- if( bOutlet ) { if( pOutlet ) { pOutlet->Next = (TPit_Outlet *)SG_Malloc(sizeof(TPit_Outlet)); pOutlet->Next->Prev = pOutlet; pOutlet = pOutlet->Next; } else { m_Outlets = pOutlet = (TPit_Outlet *)SG_Malloc(sizeof(TPit_Outlet)); m_Outlets->Prev = NULL; } pOutlet->Next = NULL; pOutlet->x = x; pOutlet->y = y; memcpy(pOutlet->Pit_ID, Pit_ID, 8 * sizeof(int)); //------------------------------------- for(i=1; i<8; i++) { iID = Pit_ID[i]; if( iID >= 0 ) { for(j=0; j= 0 && !Get_Junction(iID, jID) ) { Add_Junction(iID, jID); } } } } } //----------------------------------------- if( iMin >= 0 ) { m_pPits->Set_Value(x,y, Pit_ID[iMin] ); } } } //------------------------------------------------- for(i=0; iPit_ID[i]; if( Pit_ID == 0 ) { bDrained = true; } else if( Pit_ID > 0 ) { if( m_Pit[Pit_ID - 1].bDrained ) { bDrained = true; } else { bNotDrained = true; } } } //----------------------------------------------------- nPitsDrained = 0; if( bDrained ) { if( bNotDrained ) { x = pOutlet->x; y = pOutlet->y; z = m_pDEM->asDouble(x,y); //--------------------------------------------- // 2. Threshold ??!!... /* if( m_Threshold > 0.0 ) { for(i=0; i<8; i++) { Pit_ID = pOutlet->Pit_ID[i]; if( Pit_ID > 0 && !m_Pit[Pit_ID - 1].bDrained && m_Threshold < z - m_Pit[Pit_ID - 1].z ) { pOutlet->Pit_ID[i] = -1; } } }/**/ //--------------------------------------------- // 3.a) nach außen entwaessern... if( !m_pRoute->asChar(x,y) ) { iMin = -1; for(i=0; i<8; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( !m_pDEM->is_InGrid(ix, iy) || m_pRoute->asChar(ix, iy) > 0 ) { iMin = i; break; } else { Pit_ID = pOutlet->Pit_ID[i]; if( Pit_ID == 0 || (Pit_ID > 0 && m_Pit[Pit_ID - 1].bDrained) ) { dz = (z - m_pDEM->asDouble(ix,iy)) / Get_Length(i); if( iMin < 0 || dzMin < dz ) { iMin = i; dzMin = dz; } } } } if( iMin >= 0 ) { m_pRoute->Set_Value(x,y, iMin > 0 ? iMin : 8 ); } else { SG_UI_Msg_Add_Error(_TL("Routing Error")); } } //--------------------------------------------- // 3.b) Pit(s)/Flat(s) drainieren... for(i=0; i<8; i++) { Pit_ID = pOutlet->Pit_ID[i]; if( Pit_ID > 0 && !m_Pit[Pit_ID - 1].bDrained ) { m_Pit[Pit_ID - 1].bDrained = true; Drain_Pit(x,y,Pit_ID); nPitsDrained++; } } } //------------------------------------------------- // 4. pOutlet entfernen... if( pOutlet->Prev ) { pOutlet->Prev->Next = pOutlet->Next; } else { m_Outlets = pOutlet->Next; } if( pOutlet->Next ) { pOutlet->Next->Prev = pOutlet->Prev; } SG_Free(pOutlet); } return( nPitsDrained ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPit_Router::Add_Junction(int iID, int jID) { int i; if( iID != jID ) { if( iID > jID ) { i = iID; iID = jID; jID = i; } m_nJunctions[iID]++; i = m_nJunctions[iID]; m_Junction[iID] = (int *)SG_Realloc(m_Junction[iID], i * sizeof(int)); m_Junction[iID][i-1] = jID; } } //--------------------------------------------------------- bool CPit_Router::Get_Junction(int iID, int jID) { int i; if( iID == jID ) { return( true ); } else { if( iID > jID ) { i = iID; iID = jID; jID = i; } for(i=0; iasInt(x,y) > 0 ) { Drain_Flat(x,y); } else { z = m_pDEM->asDouble(x,y); dzMin = 0; for(i=0; i<8; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( m_pDEM->is_InGrid(ix,iy) && m_pPits->asInt(ix,iy) == Pit_ID && !m_pRoute->asChar(ix,iy) ) { dz = (z - m_pDEM->asDouble(ix,iy)) / Get_Length(i); if( dzMin < dz ) { iMin = i; dzMin = dz; } } } if( iMin >= 0 ) { x += Get_xTo(iMin); y += Get_yTo(iMin); i = (iMin + 4) % 8; m_pRoute->Set_Value(x,y, i > 0 ? i : 8 ); } } } while( iMin >= 0 ); } //--------------------------------------------------------- void CPit_Router::Drain_Flat(int x, int y) { bool bContinue; int i, ix, iy, j, n, nPlus, Flat_ID; TGEO_iRect *pFlat; //----------------------------------------------------- Flat_ID = m_pFlats->asInt(x,y); if( Flat_ID > 0 ) { pFlat = m_Flat + Flat_ID - 1; nPlus = -1; m_pFlats->Set_Value(x,y, nPlus ); //------------------------------------------------- do { bContinue = false; n = nPlus--; for(y=pFlat->yMin; y<=pFlat->yMax; y++) { for(x=pFlat->xMin; x<=pFlat->xMax; x++) { if( m_pFlats->asInt(x,y) == n ) { for(i=0; i<8; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( m_pDEM->is_InGrid(ix, iy) && Flat_ID == m_pFlats->asInt(ix, iy) ) { bContinue = true; j = (i + 4) % 8; m_pRoute->Set_Value(ix,iy, j ? j : 8 ); m_pFlats->Set_Value(ix,iy, nPlus ); } } } } } } while( bContinue ); //------------------------------------------------- for(y=pFlat->yMin; y<=pFlat->yMax; y++) { for(x=pFlat->xMin; x<=pFlat->xMax; x++) { if( m_pFlats->asInt(x,y) < 0 ) { m_pFlats->Set_Value(x,y, 0 ); } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPit_Router::Mark_Flat(int x, int y, TGEO_iRect *pFlat, int Flat_ID, int Pit_ID) { bool goStackDown; int i, ix, iy, iStart, iStack, nStack, *xMem, *yMem, *iMem; double z; //----------------------------------------------------- if( !m_pFlats ) { m_pFlats = SG_Create_Grid(m_pDEM, SG_DATATYPE_Int); //m_pFlats->Set_Cache(false); } z = m_pDEM->asDouble(x,y); xMem = NULL; yMem = NULL; iMem = NULL; iStart = 0; iStack = 0; nStack = 0; pFlat->xMin = pFlat->xMax = x; pFlat->yMin = pFlat->yMax = y; m_pPits->Set_Value( x, y, Pit_ID ); m_pFlats->Set_Value( x, y, Flat_ID ); //----------------------------------------------------- do { goStackDown = true; for(i=iStart; i<8 && goStackDown; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( m_pDEM->is_InGrid(ix, iy) && !m_pPits->asInt(ix, iy) && IS_Flat(z, m_pDEM->asDouble(ix, iy)) ) { goStackDown = false; m_pPits->Set_Value( ix, iy, Pit_ID ); m_pFlats->Set_Value( ix, iy, Flat_ID ); } } //------------------------------------------------- if( goStackDown ) { iStack--; if( iStack >= 0 ) { x = xMem[iStack]; y = yMem[iStack]; iStart = iMem[iStack]; } } else { if( nStack <= iStack ) { nStack = iStack + 32; xMem = (int *)SG_Realloc(xMem, nStack * sizeof(int )); yMem = (int *)SG_Realloc(yMem, nStack * sizeof(int )); iMem = (int *)SG_Realloc(iMem, nStack * sizeof(int )); } xMem[iStack] = x; yMem[iStack] = y; iMem[iStack] = i + 1; x = ix; y = iy; iStart = 0; if( x < pFlat->xMin ) pFlat->xMin = x; else if( x > pFlat->xMax ) pFlat->xMax = x; if( y < pFlat->yMin ) pFlat->yMin = y; else if( y > pFlat->yMax ) pFlat->yMax = y; iStack++; } } while( iStack >= 0 ); //----------------------------------------------------- if( nStack > 0 ) { SG_Free(xMem); SG_Free(yMem); SG_Free(iMem); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPit_Router::Process_Threshold(void) { int x, y, n, i; m_Route.Create(*Get_System(), SG_DATATYPE_Char); //----------------------------------------------------- for(y=0; yis_NoData(x, y) ) { m_Route.Set_Value(x, y, -1); } else if( (i = m_pRoute->asInt(x, y)) > 0 ) { m_Route.Set_Value(x, y, i % 8); } else { m_Route.Set_Value(x, y, m_pDEM->Get_Gradient_NeighborDir(x, y)); } } } //----------------------------------------------------- Lock_Create(); for(i=0, n=0; iGet_Sorted(i, x, y, false) && m_pPits->asInt(x, y) ) { m_zThr = m_pDEM->asDouble(x, y) + m_Threshold; m_zMax = m_pDEM->asDouble(x, y); Check_Threshold(x, y); if( m_zMax > m_zThr ) n++; } } Lock_Destroy(); //----------------------------------------------------- for(y=0; yGet_Gradient_NeighborDir(x, y) ) { m_pRoute->Set_Value(x, y, 0); } else { m_pRoute->Set_Value(x, y, i == 0 ? 8 : i); } } } //----------------------------------------------------- Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("number of pits above threshold level"), n)); m_Route.Destroy(); return( n ); } //--------------------------------------------------------- void CPit_Router::Check_Threshold(int x, int y) { if( Lock_Get(x, y) ) return; Lock_Set(x, y); if( m_pDEM->asDouble(x, y) > m_zMax ) { m_zMax = m_pDEM->asDouble(x, y); } int i = m_Route.asInt(x, y); int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) ) { if( m_pDEM->asDouble(x, y) < m_pDEM->asDouble(ix, iy) || m_zMax < m_zThr ) { Check_Threshold(ix, iy); } } if( m_zMax > m_zThr ) { m_Route.Set_Value(x, y, (i + 4) % 8); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/Flat_Detection.h0000664000175000017500000001114612565125415027655 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flat_Detection.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 saga-2.2.3/src/modules/terrain_analysis/ta_preprocessor/FillSinks.cpp0000664000175000017500000002062212565125415027221 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: FillSinks.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_preprocessor // // // //-------------------------------------------------------// // // // FillSinks.cpp // // // // Copyright (C) 2003 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: reklovw@web.de // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "FillSinks.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFillSinks::CFillSinks(void) { Set_Name(_TL("Fill Sinks (Planchon/Darboux, 2001)")); Set_Author(_TL("Copyrights (c) 2003 by Volker Wichmann")); Set_Description (_TW( "Depression filling algorithm after Olivier Planchon & Frederic Darboux (2001)\n\n\n" "References:\n" "Planchon, O. & F. Darboux (2001): " "A fast, simple and versatile algorithm to fill the depressions of digital elevation models. " "Catena 46: 159-176\n\n") ); Parameters.Add_Grid( NULL, "DEM" , _TL("DEM"), _TL("digital elevation model [m]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "RESULT" , _TL("Filled DEM"), _TL("processed DEM"), PARAMETER_OUTPUT ); Parameters.Add_Value( 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, 0.0, true ); } //--------------------------------------------------------- CFillSinks::~CFillSinks(void) {} /////////////////////////////////////////////////////////// // // // Sink filling algorithm after: // // Planchon, O. & F. Darboux (2001): A fast, simple and // // versatile algorithm to fill the depressions of // // digital elevation models. Catena 46: 159-176 // // // /////////////////////////////////////////////////////////// bool CFillSinks::On_Execute(void) { bool something_done; int x, y, scan, ix, iy, i, it; double z, wz, wzn, minslope; pDEM = Parameters("DEM")->asGrid(); pResult = Parameters("RESULT")->asGrid(); pResult->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pDEM->Get_Name(), _TL("no sinks"))); minslope = tan(Parameters("MINSLOPE")->asDouble() * M_DEG_TO_RAD); pW = new CSG_Grid(SG_DATATYPE_Double, pDEM->Get_NX(), pDEM->Get_NY(), pDEM->Get_Cellsize(), pDEM->Get_XMin(), pDEM->Get_YMin()); pBorder = new CSG_Grid(SG_DATATYPE_Int , pDEM->Get_NX(), pDEM->Get_NY(), pDEM->Get_Cellsize(), pDEM->Get_XMin(), pDEM->Get_YMin()); pW->Assign_NoData(); pBorder->Assign_NoData(); for(i=0; i<8; i++) epsilon[i] = minslope * Get_Length(i); R0[0] = 0; R0[1] = Get_NY()-1; R0[2] = 0; R0[3] = Get_NY()-1; R0[4] = 0; R0[5] = Get_NY()-1; R0[6] = 0; R0[7] = Get_NY()-1; C0[0] = 0; C0[1] = Get_NX()-1; C0[2] = Get_NX()-1; C0[3] = 0; C0[4] = Get_NX()-1; C0[5] = 0; C0[6] = 0; C0[7] = Get_NX()-1; dR[0] = 0; dR[1] = 0; dR[2] = 1; dR[3] = -1; dR[4] = 0; dR[5] = 0; dR[6] = 1; dR[7] = -1; dC[0] = 1; dC[1] = -1; dC[2] = 0; dC[3] = 0; dC[4] = -1; dC[5] = 1; dC[6] = 0; dC[7] = 0; fR[0] = 1; fR[1] = -1; fR[2] = -Get_NY()+1; fR[3] = Get_NY()-1; fR[4] = 1; fR[5] = -1; fR[6] = -Get_NY()+1; fR[7] = Get_NY()-1; fC[0] = -Get_NX()+1, fC[1] = Get_NX()-1; fC[2] = -1; fC[3] = 1; fC[4] = Get_NX()-1; fC[5] = -Get_NX()+1; fC[6] = 1; fC[7] = -1; Init_Altitude(); // Stage 1 for(x=0; xasInt(x, y) == 1 ) Dry_upward_cell(x, y); } } for(it=0; it<1000; it++) { for(scan=0; scan<8 && Set_Progress(scan,8); scan++) // Stage 2, Section 2 { R = R0[scan]; C = C0[scan]; something_done = false; do { if( !pDEM->is_NoData(C, R) && ((wz = pW->asDouble(C, R)) > (z = pDEM->asDouble(C, R))) ) { for(i=0; i<8; i++) { ix = Get_xTo(i, C); iy = Get_yTo(i, R); if( pDEM->is_InGrid(ix, iy) ) { if( z >= (wzn = (pW->asDouble(ix, iy) + epsilon[i])) ) // operation 1 { pW->Set_Value(C, R, z); something_done = true; Dry_upward_cell(C, R); break; } if( wz > wzn ) // operation 2 { pW->Set_Value(C, R, wzn); something_done = true; } } } } }while( Next_Cell(scan) ); if( something_done == false ) break; } if( something_done == false ) break; } pResult->Assign(pW); //----------------------------------------------------- delete pW; delete pBorder; return( true ); } void CFillSinks::Dry_upward_cell(int x, int y) { int const MAX_DEPTH = 32000; // recursion stack, maybe not needed?? int depth = 0; int ix, iy, i; double zn; depth += 1; if( depth <= MAX_DEPTH ) { for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && pW->asDouble(ix, iy) == 50000 ) { if( (zn = pDEM->asDouble(ix , iy)) >= (pW->asDouble(x, y) + epsilon[i]) ) { pW->Set_Value(ix, iy, zn); Dry_upward_cell(ix, iy); } } } } depth -= 1; } void CFillSinks::Init_Altitude() { bool border; int x, y, i, ix, iy; for(x=0; xis_NoData(x, y) ) { for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( !pDEM->is_InGrid(ix, iy) ) { border = true; break; } } if( border == true ) { pBorder->Set_Value(x, y, 1); pW->Set_Value(x, y, pDEM->asDouble(x, y)); } else pW->Set_Value(x, y, 50000.0); } } } } bool CFillSinks::Next_Cell(int i) { R = R + dR[i]; C = C + dC[i]; if( R < 0 || C < 0 || R >= Get_NY() || C >= Get_NX() ) { R = R + fR[i]; C = C + fC[i]; if( R < 0 || C < 0 || R >= Get_NY() || C >= Get_NX() ) return (false); } return (true); } saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/0000775000175000017500000000000012634325752024112 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/CellBalance.h0000664000175000017500000000304612565125415026410 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CellBalance.h 1616 2013-02-27 16:23:56Z oconrad $ *********************************************************/ /******************************************************************************* CellBalance.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CCellBalance : public CSG_Module_Grid { public: CCellBalance(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Miscellaneous") ); } protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pBalance; void Set_D8 (int x, int y, double Weight); void Set_MFD (int x, int y, double Weight); }; saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_BRM.h0000664000175000017500000003411012565125415025666 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_BRM.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_BRM.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Flow_BRM_H #define HEADER_INCLUDED__Flow_BRM_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const int BRM_BitMtrx[][8] = { { 0, 0, 0, 0, 1, 1, 1, 1 }, { 0, 0, 1, 1, 0, 0, 1, 1 }, { 0, 1, 0, 1, 0, 1, 0, 1 } }; //--------------------------------------------------------- const double BRM_g[][6][9][9] = { { { {0.345491,0.330817,0.308609,0.280762,0.250000,0.219238,0.191391,0.169183,0.154509,}, {0.264419,0.258082,0.250888,0.238153,0.219238,0.196386,0.172987,0.152978,0.140142,}, {0.187701,0.191733,0.200746,0.201406,0.191391,0.172987,0.149627,0.126499,0.112621,}, {0.104968,0.129630,0.160199,0.172795,0.169183,0.152978,0.126499,0.092593,0.069122,}, {0.000000,0.078549,0.109329,0.119501,0.118034,0.108228,0.090155,0.059574,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,} }, { {0.345491,0.330817,0.308609,0.280762,0.250000,0.219238,0.191391,0.169183,0.154509,}, {0.440699,0.416145,0.374720,0.327309,0.280762,0.238153,0.201406,0.172795,0.154740,}, {0.563105,0.521569,0.448881,0.374720,0.308609,0.250888,0.200746,0.160199,0.136573,}, {0.734773,0.648148,0.521569,0.416145,0.330817,0.258082,0.191733,0.129630,0.091137,}, {1.000000,0.633284,0.450774,0.340339,0.263932,0.204204,0.150258,0.090469,0.000000,}, {0.734773,0.648148,0.521569,0.416145,0.330817,0.258082,0.191733,0.129630,0.091137,}, {0.563105,0.521569,0.448881,0.374720,0.308609,0.250888,0.200746,0.160199,0.136573,}, {0.440699,0.416145,0.374720,0.327309,0.280762,0.238153,0.201406,0.172795,0.154740,}, {0.345491,0.330817,0.308609,0.280762,0.250000,0.219238,0.191391,0.169183,0.154509,} }, { {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.078549,0.109329,0.119501,0.118034,0.108228,0.090155,0.059574,0.000000,}, {0.104968,0.129630,0.160199,0.172795,0.169183,0.152978,0.126499,0.092593,0.069122,}, {0.187701,0.191733,0.200746,0.201406,0.191391,0.172987,0.149627,0.126499,0.112621,}, {0.264419,0.258082,0.250888,0.238153,0.219238,0.196386,0.172987,0.152978,0.140142,}, {0.345491,0.330817,0.308609,0.280762,0.250000,0.219238,0.191391,0.169183,0.154509,} }, { {0.154509,0.169183,0.191391,0.219238,0.250000,0.280762,0.308609,0.330817,0.345491,}, {0.140142,0.152978,0.172987,0.196386,0.219238,0.238153,0.250888,0.258082,0.264419,}, {0.112621,0.126499,0.149627,0.172987,0.191391,0.201406,0.200746,0.191733,0.187701,}, {0.069122,0.092593,0.126499,0.152978,0.169183,0.172795,0.160199,0.129630,0.104968,}, {0.000000,0.059574,0.090155,0.108228,0.118034,0.119501,0.109329,0.078549,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,} }, { {0.154509,0.169183,0.191391,0.219238,0.250000,0.280762,0.308609,0.330817,0.345491,}, {0.154740,0.172795,0.201406,0.238153,0.280762,0.327309,0.374720,0.416145,0.440699,}, {0.136573,0.160199,0.200746,0.250888,0.308609,0.374720,0.448881,0.521569,0.563105,}, {0.091137,0.129630,0.191733,0.258082,0.330817,0.416145,0.521569,0.648148,0.734773,}, {0.000000,0.090469,0.150258,0.204204,0.263932,0.340339,0.450774,0.633284,1.000000,}, {0.091137,0.129630,0.191733,0.258082,0.330817,0.416145,0.521569,0.648148,0.734773,}, {0.136573,0.160199,0.200746,0.250888,0.308609,0.374720,0.448881,0.521569,0.563105,}, {0.154740,0.172795,0.201406,0.238153,0.280762,0.327309,0.374720,0.416145,0.440699,}, {0.154509,0.169183,0.191391,0.219238,0.250000,0.280762,0.308609,0.330817,0.345491,} }, { {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,}, {0.000000,0.059574,0.090155,0.108228,0.118034,0.119501,0.109329,0.078549,0.000000,}, {0.069122,0.092593,0.126499,0.152978,0.169183,0.172795,0.160199,0.129630,0.104968,}, {0.112621,0.126499,0.149627,0.172987,0.191391,0.201406,0.200746,0.191733,0.187701,}, {0.140142,0.152978,0.172987,0.196386,0.219238,0.238153,0.250888,0.258082,0.264419,}, {0.154509,0.169183,0.191391,0.219238,0.250000,0.280762,0.308609,0.330817,0.345491,} } }, { { {0.184954, 0.195678, 0.206211, 0.218885, 0.237326, 0.264926, 0.302961, 0.350137, 0.403465, }, {0.187304, 0.205676, 0.224237, 0.244886, 0.270252, 0.302863, 0.344245, 0.394455, 0.452059, }, {0.187375, 0.212801, 0.238204, 0.265388, 0.296596, 0.334049, 0.379489, 0.433875, 0.497181, }, {0.187123, 0.218448, 0.249297, 0.281563, 0.317339, 0.358716, 0.407592, 0.465548, 0.533783, }, {0.151145, 0.174340, 0.197249, 0.221815, 0.250000, 0.283866, 0.325671, 0.378026, 0.444182, }, {0.186204, 0.217967, 0.249127, 0.281652, 0.317687, 0.359370, 0.408659, 0.467227, 0.536440, }, {0.185979, 0.212089, 0.238006, 0.265632, 0.297289, 0.335277, 0.381436, 0.436861, 0.501737, }, {0.185904, 0.205012, 0.224165, 0.245341, 0.271250, 0.304513, 0.346764, 0.398187, 0.457497, }, {0.183850, 0.195258, 0.206368, 0.219565, 0.238548, 0.266808, 0.305723, 0.354090, 0.408980, } }, { {0.407523, 0.450476, 0.487960, 0.514650, 0.525349, 0.517453, 0.492761, 0.456235, 0.413422, }, {0.357530, 0.397162, 0.429535, 0.451236, 0.459496, 0.453069, 0.432803, 0.401272, 0.361916, }, {0.313086, 0.351332, 0.380898, 0.399862, 0.406807, 0.401119, 0.383189, 0.354296, 0.316329, }, {0.277300, 0.314518, 0.342082, 0.359218, 0.365322, 0.360114, 0.343738, 0.316699, 0.279720, }, {0.201455, 0.223136, 0.238093, 0.246948, 0.250000, 0.247324, 0.238810, 0.224130, 0.202635, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, } }, { {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.201455, 0.223136, 0.238093, 0.246948, 0.250000, 0.247324, 0.238810, 0.224130, 0.202635, }, {0.275564, 0.313320, 0.341185, 0.358475, 0.364626, 0.359370, 0.342839, 0.315497, 0.277975, }, {0.309928, 0.349057, 0.379149, 0.398390, 0.405421, 0.399645, 0.381436, 0.352013, 0.313152, }, {0.353491, 0.394089, 0.427084, 0.449129, 0.457500, 0.450961, 0.430347, 0.398187, 0.357854, }, {0.403100, 0.446932, 0.485032, 0.512085, 0.522904, 0.514889, 0.489833, 0.452683, 0.408980, } }, { {0.407523, 0.353846, 0.305829, 0.266465, 0.237326, 0.217621, 0.204277, 0.193627, 0.183113, }, {0.455166, 0.397162, 0.346228, 0.303878, 0.270252, 0.244068, 0.222952, 0.204274, 0.186025, }, {0.499538, 0.435867, 0.380898, 0.334749, 0.296596, 0.264832, 0.237322, 0.211829, 0.186491, }, {0.535577, 0.467034, 0.408621, 0.359218, 0.317339, 0.281170, 0.248670, 0.217753, 0.186496, }, {0.445945, 0.379388, 0.326565, 0.284288, 0.250000, 0.221487, 0.196709, 0.173714, 0.150548, }, {0.538232, 0.468713, 0.409688, 0.359872, 0.317687, 0.281259, 0.248501, 0.217276, 0.185584, }, {0.504093, 0.438854, 0.382846, 0.335978, 0.297289, 0.265078, 0.237129, 0.211126, 0.185110, }, {0.460605, 0.400899, 0.348751, 0.305529, 0.271250, 0.244525, 0.222889, 0.203625, 0.184649, }, {0.413049, 0.357811, 0.308599, 0.268350, 0.238548, 0.218303, 0.204444, 0.193227, 0.182039, } }, { {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, } }, { {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, }, {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, } } } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Flow_BRM_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Sinuosity.cpp0000664000175000017500000001030012565125415026613 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Sinuosity.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Sinuosity.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "Sinuosity.h" #include "Helper.h" CSinuosity::CSinuosity(void){ Parameters.Set_Name(_TL("Flow Sinuosity")); Parameters.Set_Description(_TW( "(c) 2004 by Victor Olaya. Flow sinuosity calculation\r\n" "References:\r\n 1. Olaya, V. Hidrologia computacional y modelos digitales del terreno. Alqua. 536 pp. 2004")); Parameters.Add_Grid(NULL, "DEM", _TL("Elevation Grid"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "SINUOS", _TL("Sinuosity"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Double); }//constructor CSinuosity::~CSinuosity(void) {} void CSinuosity::writeDistOut( int iX1, int iY1, int iX2, int iY2) { int iNextX, iNextY; double dDist = 1; if (iX1 < 0 || iX1 >= m_pDEM->Get_NX() || iY1 < 0 || iY1 >= m_pDEM->Get_NY() || m_pDEM->asFloat(iX1,iY1) == m_pDEM->Get_NoData_Value()) { }// if else { dDist = sqrt(pow((double)iX1-iX2,2)+pow((double)iY1-iY2,2))*m_pSinuosity->Get_Cellsize(); m_pSinuosity->Set_Value(iX1,iY1,m_pSinuosity->asDouble(iX2,iY2) + dDist); for (int i = -1; i<2; i++){ for (int j = -1; j<2; j++){ if (!(i == 0) || !(j == 0)) { getNextCell(m_pDEM, iX1 + i, iY1 + j, iNextX, iNextY); if (iNextY == iY1 && iNextX == iX1) { writeDistOut(iX1 + i, iY1 + j, iX1, iY1); }// if }//if }//for }//for }// else }// method void CSinuosity::ZeroToNoData(void){ for(int y=0; yasDouble(x,y) == 0){ m_pSinuosity->Set_Value(x,y,m_pSinuosity->Get_NoData_Value()); }//if }// for }// for }//method void CSinuosity::calculateSinuosity(void){ double dDist; for(int y=0; yasDouble(x,y) != m_pSinuosity->Get_NoData_Value()){ dDist = sqrt(pow((double)x-m_iX,2)+pow((double)y-m_iY,2))*m_pSinuosity->Get_Cellsize(); if (dDist!=0){ m_pSinuosity->Set_Value(x,y,m_pSinuosity->asDouble(x,y)/dDist); }//if }//if }// for }// for }//method bool CSinuosity::On_Execute(void){ m_pDEM = Parameters("DEM")->asGrid(); m_pSinuosity = Parameters("SINUOS")->asGrid(); DataObject_Update(m_pSinuosity, true); return true; }//method bool CSinuosity::On_Execute_Finish(){ return( true ); } bool CSinuosity::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode){ int iX, iY; if( Mode != MODULE_INTERACTIVE_LDOWN || !Get_Grid_Pos(iX, iY) ) { return( false ); } // if( !m_pDEM->is_InGrid_byPos(ptWorld.Get_X(), ptWorld.Get_Y()) ){ // return false; // }//if // iX = (int) ((ptWorld.Get_X() - m_pDEM->Get_XMin()) / m_pDEM->Get_Cellsize()); // iY = (int) ((ptWorld.Get_Y() - m_pDEM->Get_YMin()) / m_pDEM->Get_Cellsize()); m_iX = iX; m_iY = iY; m_pSinuosity->Assign((double)0); writeDistOut(iX, iY, iX, iY); ZeroToNoData(); calculateSinuosity(); DataObject_Update(m_pSinuosity); return true; }//method saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/LakeFlood.cpp0000664000175000017500000001542212565125415026457 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: LakeFlood.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // LakeFlood.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: reklovw@web.de // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "LakeFlood.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// CLakeFlood::CLakeFlood(void) { Set_Name (_TL("Lake Flood")); Set_Author (SG_T("Volker Wichmann (c) 2005-2010")); Set_Description (_TW("This module can be used to flood a digital elevation model from seed points. " "Seed points have to be coded either with local water depth or absolute water level.\r\n" )); Parameters.Add_Grid( NULL, "ELEV", _TL("DEM"), _TL("digital elevation model"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "SEEDS", _TL("Seeds"), _TL("seed cells coded with local water depth or absolute water level, all other cells NoData"), PARAMETER_INPUT ); Parameters.Add_Value( NULL, "LEVEL", _TL("Absolute Water Levels"), _TL("check this in case seed cells are coded with absolute water level"), PARAMETER_TYPE_Bool, false ); Parameters.Add_Grid( NULL, "OUTDEPTH", _TL("Lake"), _TL("extent of lake, coded with water depth"), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "OUTLEVEL", _TL("Surface"), _TL("Flooded digital elevation model"), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CLakeFlood::~CLakeFlood(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLakeFlood::On_Execute(void) { CSG_Grid *pElev, *pSeeds, *pOdepth, *pOlevel; CTraceOrder *newCell, *firstCell, *iterCell, *lastCell; int x, y, ix, iy, i; bool bLevel; SEED thisSeed; std::list seeds; std::list::iterator it; //--------------------------------------------------------- pElev = Parameters("ELEV")->asGrid(); pSeeds = Parameters("SEEDS")->asGrid(); bLevel = Parameters("LEVEL")->asBool(); pOdepth = Parameters("OUTDEPTH")->asGrid(); pOlevel = Parameters("OUTLEVEL")->asGrid(); //--------------------------------------------------------- // Initialize pOdepth->Assign(0.0); pOlevel->Assign(pElev); for( y=0; yis_NoData(x, y) && !pElev->is_NoData(x, y) ) { thisSeed.x = x; thisSeed.y = y; if( bLevel ) thisSeed.z = pSeeds->asDouble(x, y); else thisSeed.z = pSeeds->asDouble(x, y) + pElev->asDouble(x, y); seeds.push_back(thisSeed); } } } //----------------------------------------------------- // Flood for( it=seeds.begin(); it!=seeds.end(); it++ ) { if( it->z <= pOlevel->asDouble(it->x, it->y) ) continue; newCell = new CTraceOrder(); newCell->x = it->x; newCell->y = it->y; firstCell = newCell; pOdepth->Set_Value(it->x, it->y, it->z - pElev->asDouble(it->x, it->y)); pOlevel->Set_Value(it->x, it->y, it->z); iterCell = firstCell; lastCell = firstCell; while( iterCell != NULL ) { x = iterCell->x; y = iterCell->y; for( i=0; i<8; i++ ) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !pElev->is_NoData(ix, iy) && pOlevel->asDouble(ix, iy) < it->z ) { pOdepth->Set_Value(ix, iy, it->z - pElev->asDouble(ix, iy)); pOlevel->Set_Value(ix, iy, it->z); newCell = new CTraceOrder(); newCell->x = ix; newCell->y = iy; newCell->prev = lastCell; lastCell->next = newCell; lastCell = newCell; } } newCell = firstCell; if( newCell->next == NULL ) { firstCell = lastCell = NULL; delete (newCell); newCell = NULL; } else { newCell->next->prev = NULL; firstCell = newCell->next; newCell->next = NULL; delete (newCell); newCell = NULL; } iterCell = firstCell; } } //----------------------------------------------------- return( true ); } saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow.cpp0000664000175000017500000006530312565125415025531 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SET_GRID_TO(grd, val) if( grd ) { grd->Assign(val); } #define SET_GRID_CELL_VAL(x, y, grid, val) if( grid ) { grid->Set_Value(x, y, val); } #define ADD_GRID_CELL_VAL(x, y, grid, val) if( grid ) { grid->Add_Value(x, y, val); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow::CFlow(void) { m_bPoint = false; //----------------------------------------------------- Parameters.Add_Grid(NULL, "ELEVATION" , _TL("Elevation" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "SINKROUTE" , _TL("Sink Routes" ), _TL(""), PARAMETER_INPUT_OPTIONAL); Parameters.Add_Grid(NULL, "WEIGHT" , _TL("Weight" ), _TL(""), PARAMETER_INPUT_OPTIONAL); Parameters.Add_Grid(NULL, "CAREA" , _TL("Flow Accumulation" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "VAL_INPUT" , _TL("Input for Mean over Catchment Calculation"), _TL(""), PARAMETER_INPUT_OPTIONAL); Parameters.Add_Grid(NULL, "VAL_MEAN" , _TL("Mean over Catchment" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "MATERIAL" , _TL("Material" ), _TL(""), PARAMETER_INPUT_OPTIONAL); Parameters.Add_Grid(NULL, "TARGET" , _TL("Accumulation Target" ), _TL(""), PARAMETER_INPUT_OPTIONAL); Parameters.Add_Grid(NULL, "ACCU_TOT" , _TL("Total accumulated Material" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "ACCU_LEFT" , _TL("Accumulated Material from Left Side" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Grid(NULL, "ACCU_RIGHT", _TL("Accumulated Material from Right Side" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); //----------------------------------------------------- Parameters.Add_Value( NULL , "STEP" , _TL("Step"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Choice( NULL , "CAREA_UNIT" , _TL("Flow Accumulation Unit"), _TL(""), CSG_String::Format("%s|%s|", _TL("number of cells"), _TL("cell area") ), 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow::Set_Point(int x, int y) { m_bPoint = true; m_xPoint = x; m_yPoint = y; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CFlow::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "VAL_INPUT") ) { pParameters->Set_Enabled("VAL_MEAN", pParameter->asGrid() != NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "WEIGHT") ) { pParameters->Set_Enabled("WEIGHT_GT_0", pParameter->asGrid() != NULL); } return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow::On_Execute(void) { //------------------------------------------------- m_pDTM = Parameters("ELEVATION")->asGrid(); m_pRoute = Parameters("SINKROUTE")->asGrid(); m_pWeight = Parameters("WEIGHT" )->asGrid(); m_pMaterial = Parameters("MATERIAL" )->asGrid(); m_pTarget = Parameters("TARGET" )->asGrid(); m_pCatch = Parameters("CAREA" )->asGrid(); m_pFlowPath = NULL; if( (m_pVal_Input = Parameters("VAL_INPUT")->asGrid()) != NULL && (m_pVal_Mean = Parameters("VAL_MEAN" )->asGrid()) != NULL ) { m_pVal_Mean->Set_Name(CSG_String::Format("%s [%s]", m_pVal_Input->Get_Name(), _TL("Mean over Catchment"))); m_pVal_Mean->Set_Unit(m_pVal_Input->Get_Unit()); } else { m_pVal_Mean = NULL; } m_pAccu_Tot = NULL; m_pAccu_Left = NULL; m_pAccu_Right = NULL; m_Step = Parameters("STEP")->asInt(); m_bGT_Zero = false; //----------------------------------------------------- On_Initialize(); SET_GRID_TO(m_pCatch , 0.0); SET_GRID_TO(m_pFlowPath , 0.0); SET_GRID_TO(m_pVal_Mean , 0.0); SET_GRID_TO(m_pAccu_Tot , 1.0); SET_GRID_TO(m_pAccu_Left , 1.0); SET_GRID_TO(m_pAccu_Right, 1.0); DataObject_Set_Colors(m_pCatch, 11, SG_COLORS_WHITE_BLUE); //----------------------------------------------------- if( m_bPoint ) { m_bPoint = false; if( is_InGrid(m_xPoint, m_yPoint) ) { Calculate(m_xPoint, m_yPoint); On_Finalize(); m_pCatch->Multiply(100.0); // output as percentage return( true ); } } //----------------------------------------------------- else { m_pAccu_Tot = Parameters("ACCU_TOT" )->asGrid(); m_pAccu_Left = Parameters("ACCU_LEFT" )->asGrid(); m_pAccu_Right = Parameters("ACCU_RIGHT")->asGrid(); DataObject_Set_Colors(m_pFlowPath, 11, SG_COLORS_RED_GREY_BLUE); Calculate(); On_Finalize(); _Finalize(); return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow::Init_Cell(int x, int y) { double Weight = m_pWeight ? m_pWeight->asDouble(x, y) : 1.0; ADD_GRID_CELL_VAL(x, y, m_pCatch, Weight); if( m_pVal_Mean && !m_pVal_Input->is_NoData(x, y) ) { ADD_GRID_CELL_VAL(x, y, m_pVal_Mean, Weight * m_pVal_Input->asDouble(x, y)); } Weight *= m_pMaterial ? m_pMaterial->asDouble(x, y) : 1.0; SET_GRID_CELL_VAL(x, y, m_pAccu_Tot , Weight); SET_GRID_CELL_VAL(x, y, m_pAccu_Left , Weight); SET_GRID_CELL_VAL(x, y, m_pAccu_Right, Weight); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow::_Finalize(void) { bool bCellsToArea = Parameters("CAREA_UNIT")->asInt() == 1; #pragma omp parallel for for(sLong n=0; nis_NoData(n) ) { if( m_pCatch ) { m_pCatch ->Set_NoData(n); } if( m_pFlowPath ) { m_pFlowPath ->Set_NoData(n); } if( m_pVal_Mean ) { m_pVal_Mean ->Set_NoData(n); } if( m_pAccu_Tot ) { m_pAccu_Tot ->Set_NoData(n); } if( m_pAccu_Left ) { m_pAccu_Left ->Set_NoData(n); } if( m_pAccu_Right ) { m_pAccu_Right->Set_NoData(n); } } else { //--------------------------------------------- double Catch = m_pCatch->asDouble(n); if( m_pCatch && bCellsToArea ) { m_pCatch->Set_Value(n, Catch * Get_System()->Get_Cellarea()); } if( Catch > 0.0 ) { if( m_pFlowPath ) { m_pFlowPath->Mul_Value(n, 1.0 / Catch); } if( m_pVal_Mean ) { m_pVal_Mean->Mul_Value(n, 1.0 / Catch); } } else { if( m_pFlowPath ) { m_pFlowPath->Set_Value(n, 0.0); } if( m_pVal_Mean ) { m_pVal_Mean->Set_Value(n, 0.0); } } //--------------------------------------------- if( m_pTarget ) { if( m_pTarget->is_NoData(n) ) { if( m_pAccu_Left ) { m_pAccu_Left ->Set_NoData(n); } if( m_pAccu_Right ) { m_pAccu_Right->Set_NoData(n); } } else { double Material = m_pMaterial ? m_pMaterial->asDouble(n) : 1.0; double Weight = m_pWeight ? m_pWeight ->asDouble(n) : 1.0; if( m_pAccu_Left ) { m_pAccu_Left ->Add_Value(n, - 0.5 * Weight * Material); } if( m_pAccu_Right ) { m_pAccu_Right->Add_Value(n, - 0.5 * Weight * Material); } } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow::Get_Gradient(int x, int y, double &Slope, double &Aspect) { m_pDTM->Get_Gradient(x, y, Slope, Aspect); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow::Add_Fraction(int x, int y, int Direction, double Fraction) { if( !is_InGrid(x, y) || Direction < 0 ) { return; } int ix = Get_xTo(Direction, x); int iy = Get_yTo(Direction, y); if( !is_InGrid(ix, iy) ) { return; } ADD_GRID_CELL_VAL(ix, iy, m_pCatch , Fraction * m_pCatch ->asDouble(x, y)); ADD_GRID_CELL_VAL(ix, iy, m_pFlowPath, Fraction * (m_pFlowPath->asDouble(x, y) + Get_Length(Direction))); ADD_GRID_CELL_VAL(ix, iy, m_pVal_Mean, Fraction * m_pVal_Mean->asDouble(x, y)); if( !m_pTarget ) { ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Tot , Fraction * m_pAccu_Tot ->asDouble(x, y)); ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Left , Fraction * m_pAccu_Left ->asDouble(x, y)); ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Right, Fraction * m_pAccu_Right ->asDouble(x, y)); } else if( m_pTarget->is_NoData(ix, iy) && m_pTarget->is_NoData(x, y) ) { ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Tot , Fraction * m_pAccu_Tot ->asDouble(x, y)); ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Left , Fraction * m_pAccu_Left ->asDouble(x, y)); ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Right, Fraction * m_pAccu_Right ->asDouble(x, y)); } else if( !m_pTarget->is_NoData(ix, iy) && m_pTarget->is_NoData(x, y) ) { bool left, right; Find_Sides(x, y, Direction, left, right); ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Tot , Fraction * m_pAccu_Tot ->asDouble(x, y)); if( left && right ) { ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Right, Fraction * m_pAccu_Right->asDouble(x, y) * 0.5); ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Left , Fraction * m_pAccu_Left ->asDouble(x, y) * 0.5); } else if( right && !left ) { ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Right, Fraction * m_pAccu_Right->asDouble(x, y)); } else if( left && !right ) { ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Left , Fraction * m_pAccu_Left ->asDouble(x, y)); } } } //--------------------------------------------------------- void CFlow::Add_Portion(int x, int y, int ix, int iy, int Direction) { if( !is_InGrid(x, y) || !is_InGrid(ix, iy) ) { return; } ADD_GRID_CELL_VAL(ix, iy, m_pCatch , m_pCatch ->asDouble(x, y)); ADD_GRID_CELL_VAL(ix, iy, m_pFlowPath, m_pFlowPath->asDouble(x, y)); ADD_GRID_CELL_VAL(ix, iy, m_pVal_Mean, m_pVal_Mean->asDouble(x, y)); if( m_pTarget ) { if( m_pTarget->is_NoData(ix, iy) && m_pTarget->is_NoData(x, y) ) { ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Tot , m_pAccu_Tot ->asDouble(x, y)); ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Left , m_pAccu_Left ->asDouble(x, y)); ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Right, m_pAccu_Right->asDouble(x, y)); } else if( !m_pTarget->is_NoData(ix, iy) && m_pTarget->is_NoData(x, y)) { bool left, right; Find_Sides(x, y, Direction, left, right); ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Tot, m_pAccu_Tot->asDouble(x, y)); if( left && right ) { ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Right, m_pAccu_Right->asDouble(x, y) * 0.5); ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Left , m_pAccu_Left ->asDouble(x, y) * 0.5); } else if( right && !left ) { ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Right, m_pAccu_Right->asDouble(x, y)); } else if( left && !right ) { ADD_GRID_CELL_VAL(ix, iy, m_pAccu_Left , m_pAccu_Left ->asDouble(x, y)); } } } } /////////////////////////////////////////////////////////// // SIDE-Algorithm // // // // Copyright (c) 2010 by // // // // Thomas J. Grabs // // // // // // website: www.thomasgrabs.com // // // // Updates and compiled versions of // // this algorithm can be found on the // // author's website // // // // Purpose: // // ======== // // Determine the side of a flow line relative to the // // (stream) flow direction in an adjacent grid cell // // // //-------------------------------------------------------// // !!! PLEASE CITE !!! // // the associated scientific article when redistributing // // and/or using and/or modifying this source code or // // parts of it: // // // // "Calculating terrain indices along streams - a new // // method for separating stream sides, // // Grabs, T. J. et al., published in Water Resources // // Research (WRR), please search the complete reference // // on the internet or on "http://www.agu.org/journals/wr"// //-------------------------------------------------------// // // // This source code is part of 'SAGA - System for // // Automated Geoscientific Analyses'. You can // // redistribute this source code 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. // // // // The source code 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // List of variables: // // // // x,y : Coordinates of the grid cell containing // // the flow line. // // Direction : Direction of the flow line // // left : TRUE/FALSE depending on the location of // // the flow line. // // right : TRUE/FALSE depending on the location of // // the flow line. // // FL_Dir : Direction of the flow line // // stream1_Dir : Streamflow direction // // stream2_Dir : Streamflow direction (upstream) // // stream1_X : X-coord. of stream grid cell // // stream1_Y : Y-coord. of stream grid cell // // stream2_X : X-coord. of (upstr.) stream grid cell // // stream2_X : Y-coord. of (upstr.) stream grid cell // // FL_Vec : Direction of flow line (as vector) // // stream1_Vec : Streamflow direction (as vector) // // stream2_Vec : Streamflow direction (as vector, upstr)// // SP : Scalar product of 2 vectors // // CP_A : Cross product "A" of 2 vectors // // CP_B : Cross product "B" of 2 vectors // // CP_C : Cross product "C" of 2 vectors // // Zcp_a : Z component of the cross product "A" // // Zcp_b : Z component of the cross product "B" // // Zcp_c : Z component of the cross product "C" // // a-z : auxiliary variables // // NTributaries: Number of tributaries to a junction // // prev_right : auxiliary variable (true/false) // // prev_left : auxiliary variable (true/false) // // is_upstream : auxiliary variable (true/false) // //-------------------------------------------------------// // // // Conventions // //-------------------------------------------------------// // left==true & right==false: Flow line is on the left // // left==false & right==true: Flow line is on the right // // left==true & right==true: The side of the flow line is// // not determined (channel head)// // or lies between // // tributaries to a junction // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow::Find_Sides(int x, int y, int Direction, bool &left, bool &right) { int FL_Dir, stream1_Dir, stream2_Dir; int stream1_X, stream1_Y; int stream2_X, stream2_Y; CSG_Vector FL_Vec(3), stream1_Vec(3), stream2_Vec(3); CSG_Vector CP_A(3), CP_B(3), CP_C(3); double SP; double Zcp_a, Zcp_b, Zcp_c; // Initialize the stream side variables to their default. // Default: The side of the flow line is not determined. left = right = true; // Determine the coordinates and stream direction the adjacent // grid cell, to which the flow line points. FL_Dir = Direction; stream1_X = Get_xTo( FL_Dir, x ); stream1_Y = Get_yTo( FL_Dir, y ); stream1_Dir = m_pTarget->asInt(stream1_X, stream1_Y); /*--Note: At this point it is already assumed that FL_Dir points to a grid cell that belongs to the stream network. Thus, stream1_X, stream1_Y and stream1_Dir have all non-missing values. If the code is to be used elsewhere, one should verify that FL_Dir points to a grid cell that belongs to the stream network.--*/ // Write the direction of the flow line as vector: FL_Vec[0] = Get_xTo( FL_Dir ); FL_Vec[1] = Get_yTo( FL_Dir ); FL_Vec[2] = 0.0; //z-component is normally 0 // Write the streamflow directon as vector: stream1_Vec[0] = Get_xTo( stream1_Dir ); stream1_Vec[1] = Get_yTo( stream1_Dir ); stream1_Vec[2] = 0.0;//z-component is normally 0 // Initialize the upstream streamflow direction vector // and set all components to zero stream2_Vec[0] = 0.0; stream2_Vec[1] = 0.0; stream2_Vec[2] = 0.0; // Calculate the scalar product SP = FL_Vec[0] * stream1_Vec[0] + FL_Vec[1] * stream1_Vec[1]; // Adjust the scalar product by dividing it by the lengths of FL_Vec and stream1_Vec SP = SP /sqrt( FL_Vec[0]*FL_Vec[0] + FL_Vec[1]*FL_Vec[1]) /sqrt(stream1_Vec[0]*stream1_Vec[0] + stream1_Vec[1]*stream1_Vec[1]); if( fabs(SP - (-1)) < 0.00001) { // SP is (approximately) equal to -1! // The flow line is hence oriented opposite to the streamflow direction. // Further calculations are skipped: The side of the flow line remains the default. // This can occur if an endpoint of the streamflow direction map does *not* // point to a missing value. In other words, the stream outlet lies 'inside' the // DEM and not right on the border of the DEM. // Since this can be intentional, a user notification is only optional. /*-- (optional) Notification of the user --*/ } else { /*-- Core of the SIDE-Algorithm --*/ int NTributaries; bool prev_right, prev_left; bool is_upstream; // Initialize the number of tributaries and other auxiliary variables NTributaries = 0; //default: channel head prev_right = prev_left = true; is_upstream= false; // The full vector-cross-product of the streamflow direction and the flow line direction // CP_A = FL_Vec * stream1_Vec; // is not calculated because it is more efficient to calculate only the z-component // of the cross-product: Zcp_a = FL_Vec[0]*stream1_Vec[1] - FL_Vec[1]*stream1_Vec[0]; // Look for upstream tributaries / stream grid cells for(int i=0; i<8; i++) { // find adjacent grid cell coordinates stream2_X = Get_xTo(i, stream1_X); stream2_Y = Get_yTo(i, stream1_Y); // Make sure it is within the map domain if( is_InGrid(stream2_X, stream2_Y) ) { // Make sure it is not a missing-value if ( ! m_pTarget->is_NoData( stream2_X, stream2_Y ) ) { // Is the stream cell an upstream tributary? stream2_Dir = m_pTarget->asInt(stream2_X, stream2_Y); is_upstream = stream1_X == Get_xTo(stream2_Dir, stream2_X) && stream1_Y == Get_yTo(stream2_Dir, stream2_Y); if( is_upstream ) { // The stream cell is an upstream tributary! NTributaries++; // Convert the upstream streamflow direction to a vector stream2_Vec[0] = Get_xTo( stream2_Dir ); stream2_Vec[1] = Get_yTo( stream2_Dir ); stream2_Vec[2] = 0.0; //Calculate only z-component of the vector-cross-product Zcp_b = FL_Vec[0]*stream2_Vec[1] - FL_Vec[1]*stream2_Vec[0]; //store the previous position of the flow line prev_right = right; prev_left = left; // Test if Z components have the same sign // Note that posing the condition "( Zcp_a * Zcp_b >= 0 && Zcp_b != 0)" // and evaluating the sign of *only* Zcp_b // is *equivalent* but presumably a tiny bit more efficient // than testing "( Zcp_a * Zcp_b > 0)" // and evaluating the sign of Zcp_a *or* Zcp_b // If you prefer to follow exactly the description in the WRR-article, simply // replace "( Zcp_a * Zcp_b >= 0 && Zcp_b != 0)" by "(Zcp_a * Zcp_b > 0)" // and it'll still work. if ( Zcp_a * Zcp_b >= 0 && Zcp_b != 0) { //Case1: Zcp_a and Zcp_b have the same sign, thus the position of the flow //line is the same for both stream grid cells //Case2: Zcp_a is zero but Zcp_b is not zero, the position of the flow line //can simply be determined from the sign of Zcp_b right = (Zcp_b < 0); left = !right; } else { //Since Zcp_a and Zcp_b have opposite signs (or Zcp_b is zero), the flow line //is located at a sharp bend. //Calculate only z-component of the vector-cross-product Zcp_c = stream1_Vec[0]*stream2_Vec[1] - stream1_Vec[1]*stream2_Vec[0]; right = (Zcp_c < 0); left = !right; } if ( NTributaries > 1 && (right != prev_right) ) { //It is a junction (NTributaries > 1) and the flow line lies between //two tributaries left = right = true; //Set i to 9 in order to exit the loop (there is no use in checking //for more potential tributaries since the flow line will always lie //between two tributaries i = 9; } } } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/flow_by_slope.h0000664000175000017500000001252412565125415027127 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: flow_by_slope.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // flow_by_slope.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__flow_by_slope_H #define HEADER_INCLUDED__flow_by_slope_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFlow_by_Slope : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CFlow_by_Slope(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Flow Accumulation" )); } protected: /// protected members and functions: /////////// virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: ///// private members and functions: ///////////// double m_Slope_Min, m_Slope_Max, m_Flow_Min, m_Flow_Max; CSG_Grid *m_pDEM, *m_pFlow; double Get_Fuzzy (double Value, double Minimum, double Maximum); bool Get_Decay (int x, int y, double &Decay); void Set_Area (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__flow_by_slope_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_Parallel.h0000664000175000017500000001276512565125415027016 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_Parallel.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_Parallel.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Flow_Parallel_H #define HEADER_INCLUDED__Flow_Parallel_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_hydrology_EXPORT CFlow_Parallel : public CFlow { public: CFlow_Parallel(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual void On_Initialize (void); virtual bool Calculate (void); virtual bool Calculate (int x, int y); private: bool Set_Flow (void); void Check_Route (int x, int y); void Set_D8 (int x, int y, int Direction = -1); void Set_Rho8 (int x, int y ); void Set_DInf (int x, int y ); void Set_MFD (int x, int y ); void Set_MMDGFD (int x, int y ); void Set_MDInf (int x, int y ); void Set_BRM (int x, int y ); //----------------------------------------------------- int BRM_kgexp[8], BRM_idreh[8]; void BRM_Init (void); int BRM_InitRZ (int x, int y, int ix[3], int iy[3]); void BRM_GetOrtho (int Dir, int x, int y, int ix[3], int iy[3], double nnei[6], int nexp[6]); void BRM_GetDiago (int Dir, int x, int y, int ix[3], int iy[3], double nnei[6], int nexp[6]); void BRM_QStreuung (int i64, int g64, double nnei[6], int nexp[6], int &QBinaer, double &QLinks, double &QMitte, double &QRecht); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Flow_Parallel_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_RecursiveUp.cpp0000664000175000017500000003026012565125415030057 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_RecursiveUp.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_RecursiveUp.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow_RecursiveUp.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_RecursiveUp::CFlow_RecursiveUp(void) { Set_Name (_TL("Flow Accumulation (Recursive)")); Set_Author ("O.Conrad (c) 2001"); Set_Description (_TW( "Recursive upward processing of cells for calculation of flow accumulation and related parameters. " "This set of algorithms processes recursively all upwards connected cells until each cell of the DEM has been processed.\n\n" "References:\n\n" "Deterministic 8\n" "- O'Callaghan, J.F. / Mark, D.M. (1984):\n" " 'The extraction of drainage networks from digital elevation data',\n" " Computer Vision, Graphics and Image Processing, 28:323-344\n\n" "Rho 8:\n" "- Fairfield, J. / Leymarie, P. (1991):\n" " 'Drainage networks from grid digital elevation models',\n" " Water Resources Research, 27:709-717\n\n" "Deterministic Infinity:\n" "- Tarboton, D.G. (1997):\n" " 'A new method for the determination of flow directions and upslope areas in grid digital elevation models',\n" " Water Resources Research, Vol.33, No.2, p.309-319\n\n" "Multiple m_Flow Direction:\n" "- Freeman, G.T. (1991):\n" " 'Calculating catchment area with divergent flow based on a regular grid',\n" " Computers and Geosciences, 17:413-22\n\n" "- Quinn, P.F. / Beven, K.J. / Chevallier, P. / Planchon, O. (1991):\n" " 'The prediction of hillslope flow paths for distributed hydrological modelling using digital terrain models',\n" " Hydrological Processes, 5:59-79\n\n") ); //----------------------------------------------------- // Input... Parameters.Add_Grid( NULL , "TARGETS" , _TL("Target Areas"), _TL(""), PARAMETER_INPUT_OPTIONAL ); //----------------------------------------------------- // Output... Parameters.Add_Grid( NULL , "FLOWLEN" , _TL("Flow Path Length"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); //----------------------------------------------------- // Method... Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Deterministic 8"), _TL("Rho 8"), _TL("Deterministic Infinity"), _TL("Multiple m_Flow Direction") ), 3 ); //----------------------------------------------------- // Options... Parameters.Add_Value( NULL , "CONVERGENCE" , _TL("Convergence"), _TL("Convergence factor for Multiple m_Flow Direction Algorithm (Freeman 1991)"), PARAMETER_TYPE_Double , 1.1 ); Parameters.Add_Value( NULL , "WEIGHT_GT_0" , _TL("Suppress Negative Flow Accumulation Values"), _TL("keep accumulated weights above zero; useful e.g. when accumulating measures of water balance."), PARAMETER_TYPE_Bool, true ); //----------------------------------------------------- // Initialisations... m_Flow = NULL; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveUp::On_Create(void) { int x, y; //----------------------------------------------------- On_Destroy(); m_Flow = (double ***)SG_Malloc( Get_NY () * sizeof(double **)); double *p = (double *)SG_Malloc(8 * Get_NCells() * sizeof(double )); for(y=0; yasInt(); memset(m_Flow[0][0], 0, 8 * Get_NCells() * sizeof(double) ); for(y=0; yasChar(x, y) > 0 ) { m_Flow[y][x][m_pRoute->asChar(x, y) % 8] = 1.0; } else switch( Method ) { case 0: Set_D8 (x, y); break; case 1: Set_Rho8(x, y); break; case 2: Set_DInf(x, y); break; case 3: Set_MFD (x, y); break; } } } } //--------------------------------------------------------- void CFlow_RecursiveUp::On_Destroy(void) { if( m_Flow ) { SG_Free(m_Flow[0][0]); for(int y=0; yasGrid(); m_Converge = Parameters("CONVERGENCE")->asDouble(); m_bGT_Zero = m_pWeight ? Parameters("WEIGHT_GT_0")->asBool() : false; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_RecursiveUp::Calculate(void) { CSG_Grid *pTargets = Parameters("TARGETS")->asGrid(); On_Create(); for(int y=0; yis_NoData(x, y) ) { Get_Flow(x, y); } } } On_Destroy(); return( true ); } //--------------------------------------------------------- bool CFlow_RecursiveUp::Calculate(int x, int y) { On_Create(); Get_Flow(x,y); On_Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveUp::Get_Flow(int x, int y) { if( is_Locked(x, y) == false ) { Lock_Set (x, y); Init_Cell(x, y); for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( is_InGrid(ix, iy) ) { int iDir = (i + 4) % 8; double iFlow = m_Flow[iy][ix][iDir]; if( iFlow > 0.0 ) { Get_Flow (ix, iy); Add_Fraction(ix, iy, iDir, iFlow); } } } if( m_bGT_Zero && m_pCatch->asDouble(x, y) < 0.0 ) { m_pCatch->Set_Value(x, y, 0.0); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveUp::Set_D8(int x, int y) { int Direction = m_pDTM->Get_Gradient_NeighborDir(x,y); if( Direction >= 0 ) { m_Flow[y][x][Direction % 8] = 1.0; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveUp::Set_Rho8(int x, int y) { int Direction; double Slope, Aspect; Get_Gradient(x, y, Slope, Aspect); Aspect *= M_RAD_TO_DEG; if( Aspect >= 0 ) { Direction = (int)(Aspect / 45.0); if( fmod(Aspect,45) / 45.0 > rand() / (double)RAND_MAX ) Direction++; Direction %= 8; m_Flow[y][x][Direction] = 1.0; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveUp::Set_DInf(int x, int y) { int Direction; double Slope, Aspect; Get_Gradient(x, y, Slope, Aspect); Aspect *= M_RAD_TO_DEG; if( Aspect >= 0 ) { Direction = (int)(Aspect / 45.0); Aspect = fmod(Aspect,45) / 45.0; m_Flow[y][x][(Direction ) % 8] = 1 - Aspect; m_Flow[y][x][(Direction + 1) % 8] = Aspect; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveUp::Set_MFD(int x, int y) { int i; double z, *dz, dzSum; for(i=0, dzSum=0.0, dz=m_Flow[y][x], z=m_pDTM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i,x); int iy = Get_yTo(i,y); if( is_InGrid(ix,iy) ) { double d = z - m_pDTM->asDouble(ix,iy); if( d > 0 ) { dzSum += dz[i] = pow(d / Get_Length(i), m_Converge); } } } if( dzSum ) { for(i=0; i<8; i++) { if( dz[i] > 0 ) { dz[i] /= dzSum; } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/FlowDepth.h0000664000175000017500000000363312565125415026161 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: FlowDepth.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /******************************************************************************* IsochronesConst.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CFlowDepth : public CSG_Module_Grid_Interactive { public: CFlowDepth(void); virtual ~CFlowDepth(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Dynamics" )); } bool isHeader(int,int); double CalculateFlowDepth(int,int); //void MarkBuffer(int,int,double); bool getWetAreaAndPerimeter(int,int,double,double&,double&); protected: virtual bool On_Execute(void); virtual bool On_Execute_Finish(); virtual bool On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CSG_Grid *m_pDEM; CSG_Grid *m_pFlowDepth; CSG_Grid *m_pCatchArea; CSG_Grid *m_pSlope; CSG_Grid *m_pAspect; CSG_Grid *m_pBasinGrid; double m_fMaxFlowAcc; double m_dThreshold; double m_dFlow; }; saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_Distance.cpp0000664000175000017500000002264112565125415027341 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_Distance.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_Distance.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow_Distance.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_Distance::CFlow_Distance(void) { //----------------------------------------------------- Set_Name(_TL("Flow Path Length")); Set_Author (SG_T("(c) 2005 by O.Conrad")); Set_Description (_TW( "This module calculates the average flow path length starting from the seeds, " "that are given by the optional \'Seeds\' grid and optionally from cells without upslope contributing areas " "(i.e. summits, ridges). Seeds will be all grid cells, that " "are not \'no data\' values. If seeds are not given, only summits and ridges as given by the flow routing will be taken into account. " "Available flow routing methods are based on the " "\'Deterministic 8 (D8)\' (Callaghan and Mark 1984) and the \'Multiple Flow Direction (FD8)\' " "(Freeman 1991, Quinn et al. 1991) algorithms.\n\n" "References:\n\n" "Deterministic 8\n" "- O'Callaghan, J.F. / Mark, D.M. (1984):\n" " 'The extraction of drainage networks from digital elevation data',\n" " Computer Vision, Graphics and Image Processing, 28:323-344\n\n" "- Freeman, G.T. (1991):\n" " 'Calculating catchment area with divergent flow based on a regular grid',\n" " Computers and Geosciences, 17:413-22\n\n" "- Quinn, P.F. / Beven, K.J. / Chevallier, P. / Planchon, O. (1991):\n" " 'The prediction of hillslope flow paths for distributed hydrological modelling using digital terrain models',\n" " Hydrological Processes, 5:59-79\n\n") ); //----------------------------------------------------- // Input... Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SEED" , _TL("Seeds"), _TL(""), PARAMETER_INPUT_OPTIONAL ); //----------------------------------------------------- // Output... Parameters.Add_Grid( NULL , "LENGTH" , _TL("Flow Path Length"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- // Options... Parameters.Add_Value( NULL , "SEEDS_ONLY" , _TL("Seeds Only"), _TL("Use only seed cells as starting points."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Flow Routing Algorithm"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Deterministic 8 (D8)"), _TL("Multiple Flow Direction (FD8)") ), 1 ); Parameters.Add_Value( NULL , "CONVERGENCE" , _TL("Convergence (FD8)"), _TL("Convergence factor for the \'Multiple Flow Direction\' algorithm (after Freeman 1991)"), PARAMETER_TYPE_Double , 1.1, 0.0, true ); } //--------------------------------------------------------- CFlow_Distance::~CFlow_Distance(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_Distance::On_Execute(void) { bool bSeeds; int x, y, Method; CSG_Grid *pSeed; //------------------------------------------------- m_pDTM = Parameters("ELEVATION" )->asGrid(); pSeed = Parameters("SEED" )->asGrid(); m_pLength = Parameters("LENGTH" )->asGrid(); m_Converge = Parameters("CONVERGENCE")->asDouble(); bSeeds = Parameters("SEEDS_ONLY" )->asBool(); Method = Parameters("METHOD" ) ->asInt(); m_pWeight = SG_Create_Grid(m_pLength, SG_DATATYPE_Float); m_pWeight ->Assign(0.0); m_pLength ->Assign(0.0); if( !m_pDTM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } //------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y, true, false); if( pSeed && !pSeed->is_NoData(x, y) ) { m_pLength->Set_Value(x, y, 0.0); m_pWeight->Set_Value(x, y, 0.0); } else if( m_pWeight->asDouble(x, y) > 0.0 ) { m_pLength->Set_Value(x, y, m_pLength->asDouble(x, y) / m_pWeight->asDouble(x, y)); } else if( bSeeds ) { m_pLength->Set_NoData(x, y); continue; } switch( Method ) { case 0: Set_Length_D8 (x, y); break; case 1: Set_Length_MFD (x, y); break; } } //------------------------------------------------- delete(m_pWeight); DataObject_Set_Colors(m_pLength, 100, SG_COLORS_WHITE_BLUE); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_Distance::Set_Length_D8(int x, int y) { int i, ix, iy; if( m_pDTM->is_InGrid(x, y) && (i = m_pDTM->Get_Gradient_NeighborDir(x, y, true)) >= 0 ) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy) ) { m_pLength->Add_Value(ix, iy, m_pLength->asDouble(x, y) + Get_Length(i)); m_pWeight->Add_Value(ix, iy, 1.0); } } } //--------------------------------------------------------- void CFlow_Distance::Set_Length_MFD(int x, int y) { int i, ix, iy; double z, d, dzSum, dz[8]; if( m_pDTM->is_InGrid(x, y) ) { z = m_pDTM->asDouble(x, y); dzSum = 0.0; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy) && (d = z - m_pDTM->asDouble(ix, iy)) > 0.0 ) { dz[i] = pow(d / Get_Length(i), m_Converge); dzSum += dz[i]; } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { d = m_pLength->asDouble(x, y); for(i=0; i<8; i++) { if( dz[i] > 0.0 ) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); dz[i] /= dzSum; m_pLength->Add_Value(ix, iy, dz[i] * (d + Get_Length(i))); m_pWeight->Add_Value(ix, iy, dz[i]); } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Sinuosity.h0000664000175000017500000000330712565125415026271 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Sinuosity.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /******************************************************************************* Sinuosity.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CSinuosity : public CSG_Module_Grid_Interactive { public: CSinuosity(void); virtual ~CSinuosity(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Dynamics" )); } protected: virtual bool On_Execute(void); virtual bool On_Execute_Finish(); virtual bool On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CSG_Grid *m_pDEM; CSG_Grid *m_pSinuosity; void writeDistOut(int,int,int,int); void ZeroToNoData(void); void calculateSinuosity(void); int m_iX, m_iY; }; saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/LakeFloodInteractive.cpp0000664000175000017500000001572712565125415030665 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: LakeFloodInteractive.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // LakeFloodInteractive.cpp // // // // Copyright (C) 2005-6 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: reklovw@web.de // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "LakeFlood.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// CLakeFloodInteractive::CLakeFloodInteractive(void) { Set_Name (_TL("Lake Flood")); Set_Author (SG_T("Volker Wichmann (c) 2005-2010")); Parameters.Set_Description(_TW( "This module works interactively and can be used to flood a digital elevation model for a given water depth or water level. " "Execute the module and use the action tool on a cell to flood the digital elevation model from this " "location. Execute the module again to terminate module operation.\r\n") ); Parameters.Add_Grid( NULL, "ELEV", _TL("DEM"), _TL("digital elevation model"), PARAMETER_INPUT ); Parameters.Add_Value( NULL, "WATER", _TL("Water"), _TL("local water depth or absolute water level at the user specified cell"), PARAMETER_TYPE_Double, 2.5 ); Parameters.Add_Value( NULL, "LEVEL", _TL("Absolute Water Level"), _TL("check this in case parameter 'water' is absolute water level"), PARAMETER_TYPE_Bool, false ); Parameters.Add_Grid( NULL, "OUTDEPTH", _TL("Lake"), _TL("extent of lake, coded with local water depth"), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "OUTLEVEL", _TL("Surface"), _TL("Flooded digital elevation model"), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CLakeFloodInteractive::~CLakeFloodInteractive(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// bool CLakeFloodInteractive::On_Execute(void) { pElev = Parameters("ELEV")->asGrid(); m_water = Parameters("WATER")->asDouble(); m_bLevel = Parameters("LEVEL")->asBool(); pOdepth = Parameters("OUTDEPTH")->asGrid(); pOlevel = Parameters("OUTLEVEL")->asGrid(); pOdepth->Assign(0.0); pOlevel->Assign(pElev); return (true); } //--------------------------------------------------------- bool CLakeFloodInteractive::On_Execute_Finish(void) { return( true ); } //--------------------------------------------------------- bool CLakeFloodInteractive::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { //----------------------------------------------------- if( Mode == MODULE_INTERACTIVE_LDOWN ) { int x, y, ix, iy, i; double level; x = Get_System()->Get_xWorld_to_Grid(ptWorld.Get_X()); y = Get_System()->Get_yWorld_to_Grid(ptWorld.Get_Y()); if( pElev->is_InGrid(x, y, true) ) { if( !m_bLevel ) level = m_water + pElev->asDouble(x, y); else level = m_water; if( level <= pOlevel->asDouble(x, y) ) return (true); newCell = new CTraceOrder(); newCell->x = x; newCell->y = y; firstCell = newCell; pOdepth->Set_Value(x, y, level - pElev->asDouble(x, y)); pOlevel->Set_Value(x, y, level); iterCell = firstCell; lastCell = firstCell; while( iterCell != NULL ) { x = iterCell->x; y = iterCell->y; for( i=0; i<8; i++ ) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !pElev->is_NoData(ix, iy) && pOlevel->asDouble(ix, iy) < level ) { pOdepth->Set_Value(ix, iy, level - pElev->asDouble(ix, iy)); pOlevel->Set_Value(ix, iy, level); newCell = new CTraceOrder(); newCell->x = ix; newCell->y = iy; newCell->prev = lastCell; lastCell->next = newCell; lastCell = newCell; } } newCell = firstCell; if( newCell->next == NULL ) { firstCell = lastCell = NULL; delete (newCell); newCell = NULL; } else { newCell->next->prev = NULL; firstCell = newCell->next; newCell->next = NULL; delete (newCell); newCell = NULL; } iterCell = firstCell; } SG_UI_Msg_Add(_TL("ready ..."), true); DataObject_Update(pOdepth, pOdepth->Get_ZMin(), pOdepth->Get_ZMax()); DataObject_Update(pOlevel, pOlevel->Get_ZMin(), pOlevel->Get_ZMax()); return( true ); } } return( false ); } saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/IsochronesVar.cpp0000664000175000017500000002323612565125415027406 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: IsochronesVar.cpp 2492 2015-05-18 12:37:39Z reklov_w $ *********************************************************/ /******************************************************************************* IsochronesVar.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "IsochronesVar.h" #include "Helper.h" #ifndef max #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif //----------------------------------------------------- CIsochronesVar::CIsochronesVar(void){ Parameters.Set_Name(_TL("Isochrones Variable Speed")); Set_Author(_TL("V.Olaya (c) 2004, V.Wichmann (c) 2015")); Parameters.Set_Description(_TW( "Calculation of isochrones with variable speed.\n" "In case a cell in an optional input grid is NoData, the corresponding parameter value will " "be used instead of skipping this cell.\n\n" "References:\n" "1. Al-Smadi, Mohammad: Incorporating spatial and temporal variation of " "watershed response in a gis-based hydrologic model. Faculty of the Virginia Polythecnic" "Insitute and State University. MsC Thesis. 1998\n" "Available at scholar.lib.vt.edu/theses/available/etd-121698-112858/unrestricted/smadi.pdf" "2. Martínez Álvarez, V.; Dal-Ré Tenreiro, R.; García García, A. I.; Ayuga Téllez, F. " "Modelación distribuida de la escorrentía superficial en pequeñas cuencas mediante SIG. Evaluación experimental.\n" "3. Olaya, V. Hidrologia computacional y modelos digitales del terreno. Alqua. 536 pp. 2004\n\n")); Parameters.Add_Grid(NULL, "DEM", _TL("Elevation"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "SLOPE", _TL("Slope"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "FLOWACC", _TL("Catchment Area"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "CN", _TL("Curve Number"), _TL(""), PARAMETER_INPUT_OPTIONAL); Parameters.Add_Grid(NULL, "MANNING", _TL("Manning's N"), _TL(""), PARAMETER_INPUT_OPTIONAL); Parameters.Add_Value(NULL, "AVGMANNING", _TL("Avg. Manning's N"), _TL(""), PARAMETER_TYPE_Double, 0.15); Parameters.Add_Value(NULL, "AVGCN", _TL("Avg. Curve Number"), _TL(""), PARAMETER_TYPE_Double, 75); Parameters.Add_Value(NULL, "THRSMIXED", _TL("Mixed Flow Threshold (ha)"), _TL(""), PARAMETER_TYPE_Double, 18); Parameters.Add_Value(NULL, "THRSCHANNEL", _TL("Channel Definition Threshold (ha)"), _TL(""), PARAMETER_TYPE_Double, 360); Parameters.Add_Value(NULL, "AVGRAINFALL", _TL("Avg. Rainfall Intensity (mm/h)"), _TL(""), PARAMETER_TYPE_Double, 1); Parameters.Add_Value(NULL, "CHANSLOPE", _TL("Channel side slope(m/m)"), _TL(""), PARAMETER_TYPE_Double, 0.5); Parameters.Add_Value(NULL, "MINSPEED", _TL("Min. Flow Speed (m/s)"), _TL(""), PARAMETER_TYPE_Double, 0.05); Parameters.Add_Grid(NULL, "TIME", _TL("Time Out(h)"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Double); Parameters.Add_Grid(NULL, "SPEED", _TL("Speed (m/s)"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Double); }//constructor //----------------------------------------------------- CIsochronesVar::~CIsochronesVar(void){ Execute_Finish(); } //----------------------------------------------------- void CIsochronesVar::_CalculateTime(int x, int y) { CSG_Grid_Stack Stack; double dDist = 1; double dD = 0; double dSlope; double dSpeed; double dQ = 0; double dH; double dSup; double dInf; double dAcc; double dArea = 0; double dPerim; double dDif; double dManning; double dCN; double dI = 0; int iIter = 0; int iDir; Stack.Push(x, y); //----------------------------------------------------- while( Stack.Get_Size() > 0 && Process_Get_Okay() ) { Stack.Pop(x, y); if (m_pCN != NULL && !m_pCN->is_NoData(x, y)) { dCN = m_pCN->asDouble(x, y); } else { dCN = m_dCN; } dI = Runoff(m_dRainfall, dCN); dI /= 3600.0; // in mm/s dI /= 1000.0; // m/s of runoff; iDir = m_Direction.asInt(x, y); dDist = Get_Length(iDir); // length to previous, i.e. successor cell dSlope = m_pSlope->asDouble(x, y); dSlope = fabs(tan(dSlope)); dSlope = max(0.001, dSlope); dAcc = m_pCatchArea->asDouble(x, y); if (dAcc < m_dMixedThresh) { dD = sqrt(2.0 * dAcc / 3.14159); if (m_pManning != NULL && !m_pManning->is_NoData(x, y)) { dManning = m_pManning->asDouble(x, y); } else { dManning = m_dManning; } dSpeed = max(m_dMinSpeed, pow(dI * dD, 0.4) * pow(dSlope, 0.3) / pow(dManning, 0.6)); } else { if (dAcc < m_dChannelThresh) { dManning = 0.06; } else { dManning= 0.05; } dQ = dI * dAcc; // Q m3/s dSup = 60; dInf = 0; dH = 2; dArea = dH * dH / m_dChannelSlope; dPerim = 2.0 * (dH / m_dChannelSlope + sqrt(dH * dH + pow(dH / m_dChannelSlope, 2.0))); dDif = (sqrt(dSlope) * pow(dArea, 5.0 / 3.0) / pow(dPerim, 2.0 / 3.0) / dManning) - dQ; iIter = 0; do { if (dDif > 0) { dSup = dH; dH = (dInf + dH) / 2.0; } else if (dDif < 0) { dInf = dH; dH = (dSup + dH) / 2.0; } dArea = dH * dH / m_dChannelSlope; dPerim = 2.0 * (dH / m_dChannelSlope + sqrt(dH * dH + pow(dH / m_dChannelSlope, 2.0))); dDif = (sqrt(dSlope) * pow(dArea, 5.0 / 3.0) / pow(dPerim, 2.0 / 3.0) / dManning) - dQ; iIter++; } while (fabs(dDif) > 0.1); dSpeed = max(m_dMinSpeed, dQ / dArea); } int ix = Get_xTo(iDir, x); int iy = Get_yTo(iDir, y); m_pTime->Set_Value(x, y, m_pTime->asDouble(ix, iy) + dDist / dSpeed); m_pSpeed->Set_Value(x, y, dSpeed); //------------------------------------------------- for(int i=0; i<8; i++) { ix = Get_xFrom(i, x); iy = Get_yFrom(i, y); if( m_pDEM->is_InGrid(ix, iy) && i == m_Direction.asInt(ix, iy) ) { Stack.Push(ix, iy); } } } return; } //----------------------------------------------------- double CIsochronesVar::Runoff( double dRainfall, double dCN) { double dS; double dRunoff; dS = (25400.0 / dCN) - 254; if (dRainfall < (0.2 * dS)) { return 0.1; //can´t be 0, because that would mean speed = 0 }// if dRunoff = pow(dRainfall - 0.2 * dS, 2) / (dRainfall + 0.8 * dS); return dRunoff; }// method //----------------------------------------------------- void CIsochronesVar::ZeroToNoData(void){ for(int y=0; yasDouble(x, y) == 0) { m_pTime->Set_NoData(x, y); } if (m_pSpeed->asDouble(x, y) == 0) { m_pSpeed->Set_NoData(x, y); } }// for }// for }//method //----------------------------------------------------- bool CIsochronesVar::On_Execute(void){ m_pDEM = Parameters("DEM")->asGrid(); m_pTime = Parameters("TIME")->asGrid(); m_pSpeed = Parameters("SPEED")->asGrid(); m_pManning = Parameters("MANNING")->asGrid(); m_pSlope = Parameters("SLOPE")->asGrid(); m_pCatchArea = Parameters("FLOWACC")->asGrid(); m_pCN = Parameters("CN")->asGrid(); m_dMixedThresh = Parameters("THRSMIXED")->asDouble() * 10000; m_dChannelThresh = Parameters("THRSCHANNEL")->asDouble() * 10000; m_dCN = Parameters("AVGCN")->asDouble(); m_dManning = Parameters("AVGMANNING")->asDouble(); m_dRainfall = Parameters("AVGRAINFALL")->asDouble(); m_dChannelSlope = Parameters("CHANSLOPE")->asDouble(); m_dMinSpeed = Parameters("MINSPEED")->asDouble(); m_pTime->Assign(0.0); m_Direction.Create(*Get_System(), SG_DATATYPE_Char); m_Direction.Set_NoData_Value(-1); Init_FlowDirectionsD8(m_pDEM, &m_Direction); return( true ); }//method //----------------------------------------------------- bool CIsochronesVar::On_Execute_Finish() { m_Direction.Destroy(); return( true ); } //----------------------------------------------------- bool CIsochronesVar::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { int iX, iY; if( Mode != MODULE_INTERACTIVE_LDOWN || !Get_Grid_Pos(iX, iY) ) { return( false ); } m_pTime->Assign(0.0); _CalculateTime(iX, iY); for(int y=0; ySet_Value(x, y, m_pTime->asDouble(x,y)/3600.0); } } ZeroToNoData(); DataObject_Update(m_pTime, SG_UI_DATAOBJECT_SHOW_LAST_MAP); return( true ); }//method saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Erosion_LS_Fields.cpp0000664000175000017500000006040112565125415030116 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Erosion_LS_Fields.cpp 1637 2013-03-23 11:52:10Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Erosion_LS_Fields.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Erosion_LS_Fields.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CErosion_LS_Fields::CErosion_LS_Fields(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name ("LS-Factor, Field Based"); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Calculation of slope length (LS) factor as used for the Universal Soil Loss Equation (USLE), " "based on slope and (specific) catchment area, latter as substitute for slope length. " "This tool takes only a Digital Elevation Model (DEM) as input and derives catchment areas " "according to Freeman (1991). " "Optionally field polygons can be supplied. Is this the case, calculations will be performed " "field by field, i.e. catchment area calculation is restricted to each field's area. " "\n" "References:\n" "\n" "Boehner, J., Selige, T. (2006): " "Spatial Prediction of Soil Attributes Using Terrain Analysis and Climate Regionalisation. " "In: Boehner, J., McCloy, K.R., Strobl, J.: 'SAGA - Analysis and Modelling Applications', " "Goettinger Geographische Abhandlungen, 115, 13-27.\n" "\n" "Desmet, P.J.J., Govers, G. (1996): " "A GIS Procedure for Automatically Calculating the USLE LS Factor on Topographically Complex Landscape Units. " "Journal of Soil and Water Conservation, 51(5), 427-433.\n" "\n" "Freeman, G.T. (1991): " "Calculating catchment area with divergent flow based on a regular grid. " "Computers and Geosciences, 17:413-22\n" "\n" "Kinnell, P.I.A. (2005): " "Alternative Approaches for Determining the USLE-M Slope Length Factor for Grid Cells. " "https://www.soils.org/publications/sssaj/abstracts/69/3/0674\n" "\n" "Moore, I.D., Grayson, R.B., Ladson, A.R. (1991): " "Digital terrain modelling: a review of hydrogical, geomorphological, and biological applications. " "Hydrological Processes, 5(1).\n" "\n" "Moore, I.D., Nieber, J.L. (1991): " "Landscape assessment of soil erosion and nonpoint source pollution. " "J. Minnesota Acad. Sci., 55, 18-25.\n" "\n" "Wischmeier, W.H., Smith, D.D. (1978): " "Predicting rainfall erosion losses - A guide to conservation planning. " "Agriculture Handbook No. 537: US Department of Agriculture, Washington DC.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , "Elevation", "", PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "FIELDS" , "Fields", "", PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "STATISTICS" , "Field Statistics", "", PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Grid( NULL , "UPSLOPE_AREA" , _TL("Upslope Length Factor"), "", PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "UPSLOPE_LENGTH" , _TL("Effective Flow Length"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "UPSLOPE_SLOPE" , _TL("Upslope Slope"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "LS_FACTOR" , _TL("LS Factor"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "BALANCE" , _TL("Sediment Balance"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); //----------------------------------------------------- Parameters.Add_Choice( NULL , "METHOD" , _TL("LS Calculation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Moore & Nieber 1989"), _TL("Desmet & Govers 1996"), _TL("Wischmeier & Smith 1978") ), 0 ); Parameters.Add_Choice( NULL , "METHOD_SLOPE" , _TL("Type of Slope"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("local slope"), _TL("distance weighted average catchment slope") ), 0 ); Parameters.Add_Choice( NULL , "METHOD_AREA" , _TL("Specific Catchment Area"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("specific catchment area (contour length simply as cell size)"), _TL("specific catchment area (contour length dependent on aspect)"), _TL("catchment length (square root of catchment area)"), _TL("effective flow length"), _TL("total catchment area") ), 1 ); Parameters.Add_Value( NULL , "STOP_AT_EDGE" , _TL("Stop at Edge"), "", PARAMETER_TYPE_Bool, true ); //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "DESMET_GOVERS" , _TL("Desmet & Govers"), _TL("") ); Parameters.Add_Value( pNode , "EROSIVITY" , _TL("Rill/Interrill Erosivity"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Choice( pNode , "STABILITY" , _TL("Stability"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("stable"), _TL("instable (thawing)") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CErosion_LS_Fields::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Get_Parameter("DESMET_GOVERS")->Set_Enabled(pParameter->asInt() == 1); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "FIELDS") ) { pParameters->Get_Parameter("STATISTICS")->Set_Enabled(pParameter->asShapes() != NULL); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CErosion_LS_Fields::On_Execute(void) { //----------------------------------------------------- m_Method = Parameters("METHOD" )->asInt(); m_Method_Slope = Parameters("METHOD_SLOPE" )->asInt(); m_Method_Area = Parameters("METHOD_AREA" )->asInt(); m_bStopAtEdge = Parameters("STOP_AT_EDGE" )->asBool(); m_Erosivity = Parameters("EROSIVITY" )->asDouble(); m_Stability = Parameters("STABILITY" )->asInt(); m_pDEM = Parameters("DEM" )->asGrid(); m_pUp_Area = Parameters("UPSLOPE_AREA" )->asGrid(); m_pUp_Length = Parameters("UPSLOPE_LENGTH")->asGrid(); m_pUp_Slope = Parameters("UPSLOPE_SLOPE" )->asGrid(); m_pLS = Parameters("LS_FACTOR" )->asGrid(); DataObject_Set_Colors(m_pUp_Area , 11, SG_COLORS_WHITE_BLUE , false); DataObject_Set_Colors(m_pUp_Length, 11, SG_COLORS_YELLOW_RED , false); DataObject_Set_Colors(m_pUp_Slope , 11, SG_COLORS_YELLOW_RED , false); DataObject_Set_Colors(m_pLS , 11, SG_COLORS_RED_GREY_GREEN, true ); if( m_pUp_Area == NULL ) m_pUp_Area = SG_Create_Grid(*Get_System(), SG_DATATYPE_Float); if( m_pUp_Length == NULL ) m_pUp_Length = SG_Create_Grid(*Get_System(), SG_DATATYPE_Float); if( m_pUp_Slope == NULL ) m_pUp_Slope = SG_Create_Grid(*Get_System(), SG_DATATYPE_Float); //----------------------------------------------------- bool bResult = Set_Fields() && Get_Flow() && Get_LS(); if( bResult ) { Get_Statistics(); Get_Balance(); } //----------------------------------------------------- if( m_pUp_Area && Parameters("UPSLOPE_AREA" )->asGrid() == NULL ) delete(m_pUp_Area ); if( m_pUp_Length && Parameters("UPSLOPE_LENGTH")->asGrid() == NULL ) delete(m_pUp_Length); if( m_pUp_Slope && Parameters("UPSLOPE_SLOPE" )->asGrid() == NULL ) delete(m_pUp_Slope ); m_Fields.Destroy(); return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CErosion_LS_Fields::Get_Flow(void) { //----------------------------------------------------- if( !m_pDEM->Set_Index() ) // create index ... { return( false ); } Process_Set_Text(_TL("Flow Accumulation")); m_pUp_Area ->Assign(0.0); m_pUp_Length->Assign(0.0); m_pUp_Slope ->Assign(0.0); for(sLong n=0; nGet_Sorted(n, x, y) && !m_Fields.is_NoData(x, y) && m_pDEM->Get_Gradient(x, y, Slope, Aspect) ) { double Up_Area = m_pUp_Area ->asDouble(x, y) + Get_Cellarea(); double Up_Length = m_pUp_Length->asDouble(x, y) + log(Up_Area); double Up_Slope = m_pUp_Slope ->asDouble(x, y) + log(Up_Area) * Slope; //--------------------------------------------- if( (dzSum = Get_Flow(x, y, dz)) > 0.0 ) { for(int i=0; i<8; i++) { if( dz[i] > 0.0 ) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); m_pUp_Area ->Add_Value(ix, iy, Up_Area * dz[i] / dzSum); m_pUp_Length->Add_Value(ix, iy, Up_Length * dz[i] / dzSum); m_pUp_Slope ->Add_Value(ix, iy, Up_Slope * dz[i] / dzSum); } } } //--------------------------------------------- switch( m_Method_Area ) { case 0: // specific catchment area (contour length simply as cell size) m_pUp_Area->Set_Value(x, y, Up_Area / (Get_Cellsize())); break; case 1: // specific catchment area (contour length dependent on aspect) m_pUp_Area->Set_Value(x, y, Up_Area / (Get_Cellsize() * (fabs(sin(Aspect)) + fabs(cos(Aspect))))); break; case 2: // catchment length (square root of catchment area) m_pUp_Area->Set_Value(x, y, sqrt(Up_Area)); break; case 3: // effective flow length m_pUp_Area->Set_Value(x, y, Up_Length); break; case 4: // total catchment area m_pUp_Area->Set_Value(x, y, Up_Area); break; } m_pUp_Length->Set_Value(x, y, Up_Length); m_pUp_Slope ->Set_Value(x, y, Up_Slope / (Up_Length > M_ALMOST_ZERO ? Up_Length : M_ALMOST_ZERO)); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- double CErosion_LS_Fields::Get_Flow(int x, int y, double dz[8]) { if( m_Fields.is_NoData(x, y) ) { return( 0.0 ); } double d, z = m_pDEM->asDouble(x, y), dzSum = 0.0; int ID = m_Fields.asInt(x, y); for(int i=0; i<8; i++) { dz[i] = 0.0; int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && (d = z - m_pDEM->asDouble(ix, iy)) > 0.0 ) { if( ID == m_Fields.asInt(ix, iy) ) { dzSum += (dz[i] = pow(d / Get_Length(i), 1.1)); } else if( m_bStopAtEdge ) { dzSum += pow(d / Get_Length(i), 1.1); } } } return( dzSum ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CErosion_LS_Fields::Get_LS(void) { Process_Set_Text(_TL("LS Factor")); for(int y=0; y= 0.0 ) { m_pLS->Set_Value(x, y, LS); } else { m_pLS->Set_NoData(x, y); m_pUp_Area ->Set_NoData(x, y); m_pUp_Length->Set_NoData(x, y); m_pUp_Slope ->Set_NoData(x, y); } } } return( true ); } //--------------------------------------------------------- double CErosion_LS_Fields::Get_LS(int x, int y) { double LS, Slope, Aspect, Area, sin_Slope; //----------------------------------------------------- if( m_Fields.is_NoData(x, y) ) { return( -1.0 ); } if( !m_pDEM->Get_Gradient(x, y, Slope, Aspect) ) { return( -1.0 ); } if( m_Method_Slope == 1 ) // distance weighted average up-slope slope { Slope = m_pUp_Slope->asDouble(x, y); } if( Slope <= 0.0 ) Slope = 0.000001; if( Aspect < 0.0 ) Aspect = 0.0; sin_Slope = sin(Slope); Area = m_pUp_Area->asDouble(x, y); //----------------------------------------------------- switch( m_Method ) { //----------------------------------------------------- default: // Moore and Nieber { LS = (0.4 + 1) * pow(Area / 22.13, 0.4) * pow(sin_Slope / 0.0896, 1.3); } break; //----------------------------------------------------- case 1: // Desmet and Govers { double L, S, m, x; m = m_Erosivity * (sin_Slope / 0.0896) / (3.0 * pow(sin_Slope, 0.8) + 0.56); m = m / (1.0 + m); x = fabs(sin(Aspect)) + fabs(cos(Aspect)); // x: coefficient that adjusts for width of flow at the center of the cell. // It has a value of 1.0 when the flow is toward a side and sqrt(2.0) when // the flow is toward a corner (Kinnel 2005). L = (pow(Area + Get_Cellarea(), m + 1.0) - pow(Area, m + 1.0)) / (pow(Get_Cellsize(), m + 2.0) * pow(22.13, m) * pow(x, m)); //----------------------------------------------------- if( Slope < 0.08975817419 ) // < 9% (= atan(0.09)), ca. 5 Degree { S = 10.8 * sin_Slope + 0.03; } else if( m_Stability == 0 ) // >= 9%, stable { S = 16.8 * sin_Slope - 0.5; } else // >= 9%, thawing, unstable { S = pow(sin_Slope / 0.896, 0.6); } LS = L * S; } break; //----------------------------------------------------- case 2: // Wischmeier and Smith { if( Slope > 0.0505 ) // > ca. 3° { LS = sqrt(Area / 22.13) * (65.41 * sin_Slope * sin_Slope + 4.56 * sin_Slope + 0.065); } else // <= ca. 3° { LS = pow (Area / 22.13, 3.0 * pow(Slope, 0.6)) * (65.41 * sin_Slope * sin_Slope + 4.56 * sin_Slope + 0.065); } } break; } return( LS ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CErosion_LS_Fields::Get_Balance(void) { CSG_Grid *pBalance = Parameters("BALANCE")->asGrid(); if( pBalance == NULL ) { return( false ); } DataObject_Set_Colors(pBalance, 11, SG_COLORS_RED_GREY_BLUE , false); //----------------------------------------------------- int y; CSG_Grid dzSum(*Get_System(), SG_DATATYPE_Float); //----------------------------------------------------- Process_Set_Text(CSG_String::Format(SG_T("%s: %s 1"), _TL("Sediment Balance"), _TL("Pass"))); for(y=0; yasDouble(x, y), iz; double Sum = 0.0; for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && ID == m_Fields.asInt(ix, iy) && (iz = m_pDEM->asDouble(ix, iy)) < z ) { Sum += atan((z - iz) / Get_Length(i)); // als Winkel !!!? } } dzSum.Set_Value(x, y, Sum); } } } //----------------------------------------------------- Process_Set_Text(CSG_String::Format(SG_T("%s: %s 2"), _TL("Sediment Balance"), _TL("Pass"))); for(y=0; yasDouble(x, y), iz; double Sum = -m_pLS->asDouble(x, y); for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && ID == m_Fields.asInt(ix, iy) && dzSum.asDouble(ix, iy) > 0.0 && (iz = m_pDEM->asDouble(ix, iy)) > z ) { iz = atan((z - iz) / Get_Length(i)); // als Winkel !!!? Sum += (-iz / dzSum.asDouble(ix, iy)) * m_pLS->asDouble(ix, iy); } } if( Sum > 0.0 ) { z = log(1.0 + Sum); pBalance->Set_Value (x, y, z > 5.0 ? 5.0 : z); } else if( Sum < 0.0 ) { z = -log(1.0 - Sum); pBalance->Set_Value (x, y, z < -5.0 ? -5.0 : z); } else { pBalance->Set_NoData(x, y); } } else { pBalance->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CErosion_LS_Fields::Get_Statistics(void) { CSG_Shapes *pFields = Parameters("FIELDS" )->asShapes(); CSG_Shapes *pStatistics = Parameters("STATISTICS")->asShapes(); //----------------------------------------------------- if( !pStatistics || !pFields || m_nFields <= 0 || pFields->Get_Count() != m_nFields ) { return( false ); } //----------------------------------------------------- int i; CSG_Simple_Statistics *Statistics = new CSG_Simple_Statistics[m_nFields]; //----------------------------------------------------- for(int y=0; yis_NoData(x, y) && (i = m_Fields.asInt(x, y)) >= 0 && i < m_nFields ) { Statistics[i] += m_pLS->asDouble(x, y); } } } //----------------------------------------------------- pStatistics->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pFields->Get_Name(), _TL("LS"))); pStatistics->Add_Field("NCELLS", SG_DATATYPE_Int ); pStatistics->Add_Field("MEAN" , SG_DATATYPE_Double); pStatistics->Add_Field("MIN" , SG_DATATYPE_Double); pStatistics->Add_Field("MAX" , SG_DATATYPE_Double); pStatistics->Add_Field("STDDEV", SG_DATATYPE_Double); for(i=0; iGet_Count() && Set_Progress(i, pFields->Get_Count()); i++) { CSG_Shape *pField = pStatistics->Add_Shape(pFields->Get_Shape(i)); if( Statistics[i].Get_Count() > 0 ) { pField->Set_Value(0, Statistics[i].Get_Count ()); pField->Set_Value(1, Statistics[i].Get_Mean ()); pField->Set_Value(2, Statistics[i].Get_Minimum()); pField->Set_Value(3, Statistics[i].Get_Maximum()); pField->Set_Value(4, Statistics[i].Get_StdDev ()); } else for(int j=0; jGet_Field_Count(); j++) { pField->Set_NoData(j); } } //------------------------------------------------- delete[](Statistics); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CErosion_LS_Fields::Set_Fields(void) { CSG_Shapes *pFields = Parameters("FIELDS")->asShapes(); //----------------------------------------------------- if( !pFields || pFields->Get_Count() <= 0 ) { m_Fields.Create(*Get_System(), SG_DATATYPE_Char); // m_Fields.Set_NoData_Value(1.0); // m_Fields.Assign(0.0); #pragma omp parallel for for(int y=0; yis_InGrid(x, y) ) { m_Fields.Set_NoData(x, y); } } } return( true ); } //----------------------------------------------------- Process_Set_Text(_TL("Initializing Fields")); m_nFields = pFields->Get_Count(); m_Fields.Create(*Get_System(), m_nFields < pow(2.0, 16.0) - 1.0 ? SG_DATATYPE_Word : SG_DATATYPE_DWord); m_Fields.Set_NoData_Value(m_nFields); m_Fields.Assign_NoData(); //----------------------------------------------------- for(int iField=0; iFieldGet_Count() && Set_Progress(iField, pFields->Get_Count()); iField++) { CSG_Shape_Polygon *pField = (CSG_Shape_Polygon *)pFields->Get_Shape(iField); int xMin = Get_System()->Get_xWorld_to_Grid(pField->Get_Extent().Get_XMin()) - 1; if( xMin < 0 ) xMin = 0; int xMax = Get_System()->Get_xWorld_to_Grid(pField->Get_Extent().Get_XMax()) + 1; if( xMax >= Get_NX() ) xMax = Get_NX() - 1; int yMin = Get_System()->Get_yWorld_to_Grid(pField->Get_Extent().Get_YMin()) - 1; if( yMin < 0 ) yMin = 0; int yMax = Get_System()->Get_yWorld_to_Grid(pField->Get_Extent().Get_YMax()) + 1; if( yMax >= Get_NY() ) yMax = Get_NY() - 1; for(int y=yMin; y<=yMax; y++) { for(int x=xMin; x<=xMax; x++) { if( m_pDEM->is_InGrid(x, y) && pField->Contains(Get_System()->Get_Grid_to_World(x, y)) ) { m_Fields.Set_Value(x, y, iField); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/SlopeLength.cpp0000664000175000017500000001137412565125415027045 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SlopeLength.cpp 1081 2011-06-08 08:05:26Z reklov_w $ *********************************************************/ /******************************************************************************* SlopeLength.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SlopeLength.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSlopeLength::CSlopeLength(void) { Set_Name (_TL("Slope Length")); Set_Author (SG_T("V.Olaya (c) 2004")); Set_Description (_TW( "" )); Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "LENGTH" , _TL("Slope Length"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSlopeLength::On_Execute(void) { int x, y; //----------------------------------------------------- m_pDEM = Parameters("DEM" )->asGrid(); m_pLength = Parameters("LENGTH")->asGrid(); if( !m_pDEM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } //----------------------------------------------------- m_Slope.Create(*Get_System()); for(y=0; yGet_Gradient(x, y, Slope, Aspect) ) { m_Slope .Set_Value(x, y, Slope); m_pLength->Set_Value(x, y, 0.0); } else { m_Slope .Set_NoData(x, y); m_pLength->Set_NoData(x, y); } } } //----------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y) ) { Get_Length(x, y); } } //----------------------------------------------------- m_Slope.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSlopeLength::Get_Length(int x, int y) { int i, ix, iy; if( m_Slope.is_InGrid(x, y) && (i = m_pDEM->Get_Gradient_NeighborDir(x, y)) >= 0 ) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( m_Slope.is_InGrid(ix, iy) ) { if( m_Slope.asDouble(ix, iy) > 0.5 * m_Slope.asDouble(x, y) ) // ??? { double Length = m_pLength->asDouble(x, y) + CSG_Module_Grid::Get_Length(i); if( Length > m_pLength->asDouble(ix, iy) ) { m_pLength->Set_Value(ix, iy, Length); } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/SAGA_Wetness_Index.h0000664000175000017500000001073612565125415027641 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SAGA_Wetness_Index.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // SAGA_Wetness_Index.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__SAGA_Wetness_Index_H #define HEADER_INCLUDED__SAGA_Wetness_Index_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSAGA_Wetness_Index : public CSG_Module_Grid { public: CSAGA_Wetness_Index(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Topographic Indices" )); } protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pSlope, *m_pArea, *m_pAreaMod, *m_pTWI, m_Suction; double Get_Local_Maximum (CSG_Grid *pGrid, int x, int y); bool Get_Area (void); bool Get_Modified (void); bool Get_TWI (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__SAGA_Wetness_Index_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/EdgeContamination.h0000664000175000017500000000442712565125415027657 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: EdgeContamination.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /******************************************************************************* EdgeContamination.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CEdgeContamination : public CSG_Module_Grid { public: CEdgeContamination(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Flow Accumulation" )); } protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pEffect; int Get_D8 (int x, int y); int Set_D8 (int x, int y); bool Get_MFD (int x, int y, double dz[8]); int Set_MFD (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_RecursiveDown.h0000664000175000017500000001215312565125415030050 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_RecursiveDown.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_RecursiveDown.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Flow_RecursiveDown_H #define HEADER_INCLUDED__Flow_RecursiveDown_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_hydrology_EXPORT CFlow_RecursiveDown : public CFlow { public: CFlow_RecursiveDown(void); protected: virtual void On_Initialize (void); virtual void On_Finalize (void); virtual bool Calculate (void); virtual bool Calculate (int x, int y); private: bool bFlowPathWeight; int Method; double Src_Value, DEMON_minDQV; CSG_Grid *pLinear, *pDir, *pDif; void Add_Flow (int x, int y, double qFlow); void Rho8_Start (int x, int y, double qFlow); void KRA_Start (int x, int y, double qFlow); void KRA_Trace (int x, int y, double qFlow, int Direction, double from); void DEMON_Start (int x, int y, double qFlow); void DEMON_Trace (int x, int y, double qFlow, int Direction, double from_A, double from_B); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Flow_RecursiveDown_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/flow_massflux.h0000664000175000017500000001122612565125415027153 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: flow_massflux.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // flow_massflux.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__flow_massflux_H #define HEADER_INCLUDED__flow_massflux_H //--------------------------------------------------------- #include //--------------------------------------------------------- class CFlow_MassFlux : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CFlow_MassFlux(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Flow Accumulation" )); } protected: /// protected members and functions: /////////// virtual bool On_Execute (void); private: ///// private members and functions: ///////////// int m_Method; CSG_Grid *m_pDEM, *m_pSlope, *m_pAspect, m_Area, m_dir, m_dif; CSG_Shapes *m_pFlow; bool Set_Flow (int x, int y, int Direction); double Get_Flow (int x, int y, int Direction); double Get_Area (int x, int y); bool Check_Flow (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__flow_massflux_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Makefile.in0000664000175000017500000006232512622651176026166 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/ta_hydrology DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libta_hydrology_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libta_hydrology_la_OBJECTS = CellBalance.lo EdgeContamination.lo \ Erosion_LS_Fields.lo Flow.lo Flow_AreaDownslope.lo \ Flow_AreaUpslope.lo flow_by_slope.lo Flow_Distance.lo \ Flow_Parallel.lo Flow_RecursiveDown.lo Flow_RecursiveUp.lo \ flow_massflux.lo flow_width.lo FlowDepth.lo Helper.lo \ IsochronesConst.lo IsochronesVar.lo LakeFlood.lo \ LakeFloodInteractive.lo MLB_Interface.lo melton_ruggedness.lo \ SAGA_Wetness_Index.lo Sinuosity.lo SlopeLength.lo \ TopographicIndices.lo libta_hydrology_la_OBJECTS = $(am_libta_hydrology_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libta_hydrology_la_SOURCES) DIST_SOURCES = $(libta_hydrology_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1824 2013-09-05 08:48:21Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_hydrology.la libta_hydrology_la_SOURCES = \ CellBalance.cpp\ EdgeContamination.cpp\ Erosion_LS_Fields.cpp\ Flow.cpp\ Flow_AreaDownslope.cpp\ Flow_AreaUpslope.cpp\ flow_by_slope.cpp\ Flow_Distance.cpp\ Flow_Parallel.cpp\ Flow_RecursiveDown.cpp\ Flow_RecursiveUp.cpp\ flow_massflux.cpp\ flow_width.cpp\ FlowDepth.cpp\ Helper.cpp\ IsochronesConst.cpp\ IsochronesVar.cpp\ LakeFlood.cpp\ LakeFloodInteractive.cpp\ MLB_Interface.cpp\ melton_ruggedness.cpp\ SAGA_Wetness_Index.cpp\ Sinuosity.cpp\ SlopeLength.cpp\ TopographicIndices.cpp\ CellBalance.h\ EdgeContamination.h\ Erosion_LS_Fields.h\ Flow.h\ Flow_AreaDownslope.h\ Flow_AreaUpslope.h\ flow_by_slope.h\ Flow_BRM.h\ Flow_Distance.h\ Flow_Parallel.h\ Flow_RecursiveDown.h\ Flow_RecursiveUp.h\ flow_massflux.h\ flow_width.h\ FlowDepth.h\ Helper.h\ IsochronesConst.h\ IsochronesVar.h\ LakeFlood.h\ MLB_Interface.h\ melton_ruggedness.h\ SAGA_Wetness_Index.h\ Sinuosity.h\ SlopeLength.h\ TopographicIndices.h libta_hydrology_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) --foreign src/modules/terrain_analysis/ta_hydrology/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/terrain_analysis/ta_hydrology/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libta_hydrology.la: $(libta_hydrology_la_OBJECTS) $(libta_hydrology_la_DEPENDENCIES) $(EXTRA_libta_hydrology_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libta_hydrology_la_OBJECTS) $(libta_hydrology_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CellBalance.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/EdgeContamination.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Erosion_LS_Fields.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flow.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FlowDepth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flow_AreaDownslope.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flow_AreaUpslope.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flow_Distance.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flow_Parallel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flow_RecursiveDown.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flow_RecursiveUp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Helper.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IsochronesConst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IsochronesVar.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LakeFlood.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LakeFloodInteractive.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SAGA_Wetness_Index.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sinuosity.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SlopeLength.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TopographicIndices.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flow_by_slope.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flow_massflux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flow_width.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/melton_ruggedness.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/FlowDepth.cpp0000664000175000017500000002215612565125415026515 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: FlowDepth.cpp 1016 2011-04-27 18:40:36Z oconrad $ *********************************************************/ /******************************************************************************* FlowDepth.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "FlowDepth.h" #include "Helper.h" #define NO_DEPTH -1 CFlowDepth::CFlowDepth(void){ Parameters.Set_Name(_TL("Flow Depth")); Parameters.Set_Description(_TW( "(c) 2004 by Victor Olaya. Flow Depth Calculation \r\n" "References:\r\n 1. Olaya, V. Hidrologia computacional y modelos digitales del terreno. Alqua. 536 pp. 2004")); Parameters.Add_Grid(NULL, "DEM", _TL("Elevation Grid"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "FLOWDEPTH", _TL("Flow Depth Grid (m)"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Float); Parameters.Add_Value(NULL, "THRESHOLD", _TL("Channel definition threshold"), _TL("Channel definition threshold"), PARAMETER_TYPE_Double, 10000.); Parameters.Add_Value(NULL, "FLOW", _TL("Peak Flow (m3/s)"), _TL("Peak Flow (m3/s) at selected outlet cell"), PARAMETER_TYPE_Double, 100.); }//constructor CFlowDepth::~CFlowDepth(void){ } bool CFlowDepth::On_Execute(void){ m_pDEM = Parameters("DEM") ->asGrid(); m_pFlowDepth = Parameters("FLOWDEPTH") ->asGrid(); m_dThreshold = Parameters("THRESHOLD") ->asDouble(); m_dFlow = Parameters("FLOW") ->asDouble(); m_pCatchArea = SG_Create_Grid(m_pDEM, SG_DATATYPE_Float); m_pBasinGrid = SG_Create_Grid(m_pDEM, SG_DATATYPE_Int); m_pSlope = SG_Create_Grid(m_pDEM, SG_DATATYPE_Float); m_pAspect = SG_Create_Grid(m_pDEM, SG_DATATYPE_Float); m_pFlowDepth->Set_NoData_Value(0.); Process_Set_Text(_TL("Calculating Catchment Area...")); CalculateFlowAccGrid(m_pCatchArea, m_pDEM); for(int y=0; yGet_Gradient(x, y, slope, aspect) ) { m_pSlope ->Set_Value(x, y, slope); m_pAspect ->Set_Value(x, y, aspect); } else { m_pSlope ->Set_NoData(x, y); m_pAspect ->Set_NoData(x, y); } } } //----------------------------------------------------- DataObject_Update(m_pFlowDepth, true); return true; }//method bool CFlowDepth::On_Execute_Finish(){ delete m_pSlope; delete m_pAspect; delete m_pBasinGrid; delete m_pCatchArea; return true; }//method bool CFlowDepth::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode){ int iX, iY; int iNextX, iNextY; int x,y; int iOutletX, iOutletY; double fArea; double fDepth, fPreviousDepth = 0; if( Mode != MODULE_INTERACTIVE_LDOWN || !Get_Grid_Pos(iOutletX, iOutletY) ) { return( false ); } m_pFlowDepth->Assign((double)0); fArea = m_pCatchArea->asFloat(iOutletX, iOutletY); if (fArea < m_dThreshold * 2.){ //check outlet point iNextX = iOutletX; iNextY = iOutletY; do{ iOutletX = iNextX; iOutletY = iNextY; getNextCell(m_pDEM, iOutletX, iOutletY, iNextX, iNextY); }while (m_pCatchArea->asFloat(iOutletX, iOutletY) < m_dThreshold * 2. && (iOutletX != iNextX || iOutletY != iNextY)); if (m_pCatchArea->asFloat(iOutletX, iOutletY) < m_dThreshold * 2.){ Message_Add(_TL("** Error : Wrong outlet point selected **")); return false; }//if Message_Add(_TL("** Warning : Outlet point was modified **")); }//if CalculateBasinGrid(m_pBasinGrid, m_pDEM, iOutletX, iOutletY); m_fMaxFlowAcc = m_pCatchArea->asFloat(iOutletX, iOutletY); for(y=0; yasFloat(x,y) > m_dThreshold){ if (isHeader(x,y)){ iNextX = x; iNextY = y; do { iX = iNextX; iY = iNextY; if (m_pFlowDepth->asFloat(iX,iY) == 0. && m_pBasinGrid->asInt(iX, iY) != 0){ getNextCell(m_pDEM, iX, iY, iNextX, iNextY); fDepth = CalculateFlowDepth(iX,iY); if (fDepth == NO_DEPTH){ m_pFlowDepth->Set_Value(iX,iY, fPreviousDepth); }//if else{ fPreviousDepth = fDepth; }//else }//if }while ((iX != iOutletX || iY != iOutletY) && (iX != iNextX || iY != iNextY)); }//if }//if }//for }// for DataObject_Update(m_pFlowDepth); return true; }//method bool CFlowDepth::isHeader(int iX, int iY){ int iNextX, iNextY; for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (m_pCatchArea->is_InGrid(iX+i,iY+j)){ if (m_pCatchArea->asFloat(iX+i,iY+j) > m_dThreshold && (i!=0 || j!=0)){ getNextCell(m_pDEM, iX + i, iY + j, iNextX, iNextY); if (iNextX == iX && iNextY == iY) { return false; }//if }// if }//if }// for }// for return true; }// method double CFlowDepth::CalculateFlowDepth(int iX, int iY){ int iIter=0; double fSup, fInf; double fH; double fDif; double fArea; double fPerim; double fFlow = m_dFlow / m_fMaxFlowAcc * m_pCatchArea->asFloat(iX,iY); double fSlope = tan(m_pSlope->asFloat(iX,iY)); bool bReturn = false; fSup = 100; fInf = 0; fH = 1; while (!bReturn && fH >= 0.00001){ bReturn = getWetAreaAndPerimeter(iX, iY, fH, fArea, fPerim); fH /= 2.0; } if (bReturn){ fDif = (sqrt(fSlope) * pow(fArea, 5.0 / 3.0) / pow(fPerim, 2.0 / 3.0) / 0.035) - fFlow; do { iIter++; if (fDif > 0) { fSup = fH; fH = (fInf + fH) / 2.0; }// if else if (fDif < 0) { fInf = fH; fH = (fSup + fH) / 2.0; }// else if bReturn = getWetAreaAndPerimeter(iX, iY, fH, fArea, fPerim); if (!bReturn){ return NO_DEPTH; }//if if (iIter>20){ return NO_DEPTH; }//if fDif = (sqrt(fSlope) * pow(fArea, 5.0 / 3.0) / pow(fPerim, 2.0 / 3.0) / 0.035) - fFlow; }while (fabs(fDif) > 0.1); }//if else{ return NO_DEPTH; }//else m_pFlowDepth->Set_Value(iX,iY,fH); return fH; }//method bool CFlowDepth::getWetAreaAndPerimeter(int iX, int iY, double fH, double &fArea, double &fPerim){ int iWidth = 0; int iX2, iY2; int iX3, iY3; int i = 0; int iStepX, iStepY; int pStepX[4] = {1,1,0,1}; int pStepY[4] = {0,-1,1,1}; int iDir = (m_pAspect->asInt(iX, iY) / 45) % 4; double fDist; double fLocalDist; double fBaseHeight = m_pDEM->asFloat(iX, iY); double fPerimLeft = 0; double fAreaLeft = 0; double fPerimRight = 0; double fAreaRight = 0; double fHeightDif; double fLocalHeightDif; iStepY = pStepX[iDir]; iStepX = pStepY[iDir]; fDist = M_GET_LENGTH(iStepX, iStepY) * m_pDEM->Get_Cellsize(); do{ iX2 = iX + iStepX * i; iY2 = iY + iStepY * i; iX3 = iX + iStepX * (i+1); iY3 = iY + iStepY * (i+1); if (m_pDEM->is_InGrid(iX2,iY2) && m_pDEM->is_InGrid(iX3,iY3)){ fHeightDif = m_pDEM->asFloat(iX3,iY3) - m_pDEM->asFloat(iX,iY); if (fHeightDif >= fH){ fLocalHeightDif = fabs(m_pDEM->asFloat(iX,iY) + fH - m_pDEM->asFloat(iX2,iY2)); fLocalDist = fabs(fDist * fLocalHeightDif / (m_pDEM->asFloat(iX3,iY3) - m_pDEM->asFloat(iX2,iY2))); }//if else{ fLocalHeightDif = fabs(m_pDEM->asFloat(iX3,iY3) - m_pDEM->asFloat(iX2,iY2)); fLocalDist = fDist; }//else fPerimLeft += sqrt(fLocalDist * fLocalDist + fLocalHeightDif * fLocalHeightDif); fAreaLeft += (i * fLocalHeightDif + fLocalHeightDif * fLocalDist / 2.); }//if else{ return false; }//else i++; }while(fHeightDif < fH); i = 0; do{ iX2 = iX - iStepX * i; iY2 = iY - iStepY * i; iX3 = iX - iStepX * (i+1); iY3 = iY - iStepY * (i+1); if (m_pDEM->is_InGrid(iX2,iY2) && m_pDEM->is_InGrid(iX3,iY3)){ fHeightDif = m_pDEM->asFloat(iX3,iY3) - m_pDEM->asFloat(iX,iY); if (fHeightDif >= fH){ fLocalHeightDif = fabs(m_pDEM->asFloat(iX,iY) + fH - m_pDEM->asFloat(iX2,iY2)); fLocalDist = fabs(fDist * fLocalHeightDif / (m_pDEM->asFloat(iX3,iY3) - m_pDEM->asFloat(iX2,iY2))); }//if else{ fLocalHeightDif = fabs(m_pDEM->asFloat(iX3,iY3) - m_pDEM->asFloat(iX2,iY2)); fLocalDist = fDist; }//else fPerimLeft += sqrt(fLocalDist * fLocalDist + fLocalHeightDif * fLocalHeightDif); fAreaLeft += (i * fLocalHeightDif + fLocalHeightDif * fLocalDist / 2.); }//if else{ return false; }//else i++; }while(fHeightDif < fH); fArea = fAreaLeft + fAreaRight; fPerim = fPerimLeft +fPerimRight; return true; }//method saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/flow_by_slope.cpp0000664000175000017500000002270212565125415027461 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: flow_by_slope.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // flow_by_slope.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "flow_by_slope.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_by_Slope::CFlow_by_Slope(void) { //----------------------------------------------------- Set_Name (_TL("Slope Limited Flow Accumulation")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "Flow accumulation is calculated as upslope contributing (catchment) area " "using the multiple flow direction approach of Freeman (1991). For this tool " "the approach has been modified to limit the flow portion routed through a cell " "depending on the local slope. If a cell is not inclined, no flow is routed " "through it at all. With increasing slopes the portion of flow routed through " "a cell becomes higher. Cells with slopes greater than a specified slope threshold " "route their entire accumulated flow downhill. " "\nReferences:\n" "- Freeman, G.T. (1991):" " Calculating catchment area with divergent flow based on a regular grid." " Computers and Geosciences, 17:413-22\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "WEIGHT" , _TL("Weight"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "FLOW" , _TL("Flow Accumulation"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "SLOPE_MIN" , _TL("Slope Minimum"), _TL("Assume a given minimum slope for each cell."), PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Value( NULL , "SLOPE_MAX" , _TL("Slope Threshold"), _TL("Slope threshold, given as degree, above which flow transport is unlimited."), PARAMETER_TYPE_Double, 5.0, 0.0, true, 90.0, true ); CSG_Parameter *pNode = Parameters.Add_Value( NULL , "B_FLOW" , _TL("Use Flow Threshold"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Range( pNode , "T_FLOW" , _TL("Flow Threshold"), _TL("Flow threshold, given as amount of cells, above which flow transport is unlimited. Ignored if range equals zero."), 1.0, 100.0, 1.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CFlow_by_Slope::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "B_FLOW") ) { pParameters->Get_Parameter("T_FLOW")->Set_Enabled(pParameter->asBool()); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_by_Slope::On_Execute(void) { m_Slope_Min = Parameters("SLOPE_MIN")->asDouble() * M_DEG_TO_RAD; m_Slope_Max = Parameters("SLOPE_MAX")->asDouble() * M_DEG_TO_RAD; if( m_Slope_Max <= 0.0 ) { Error_Set(_TL("slope threshold must not be zero!")); return( false ); } if( Parameters("B_FLOW")->asBool() ) { m_Flow_Min = Parameters("T_FLOW")->asRange()->Get_LoVal() * Get_Cellarea(); m_Flow_Max = Parameters("T_FLOW")->asRange()->Get_HiVal() * Get_Cellarea(); } else { m_Flow_Min = m_Flow_Max = 0.0; } //----------------------------------------------------- m_pDEM = Parameters("DEM" )->asGrid(); m_pFlow = Parameters("FLOW" )->asGrid(); m_pFlow->Assign(Get_Cellarea()); if( Parameters("WEIGHT")->asGrid() ) { m_pFlow->Multiply(*Parameters("WEIGHT")->asGrid()); } DataObject_Set_Colors(m_pFlow, 11, SG_COLORS_WHITE_BLUE, false); if( !m_pDEM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } //----------------------------------------------------- for(sLong i=0; iGet_Sorted(i, x, y, true) || m_pDEM->is_NoData(x, y) ) { m_pFlow->Set_NoData(x, y); } else { Set_Area(x, y); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CFlow_by_Slope::Get_Fuzzy(double Value, double Minimum, double Maximum) { return( Value <= Minimum ? 0.0 : Value >= Maximum ? 1.0 : 0.5 * (1.0 - cos(M_PI * ((Value - Minimum) / (Maximum - Minimum)))) ); } //--------------------------------------------------------- inline bool CFlow_by_Slope::Get_Decay(int x, int y, double &Decay) { double d; if( !m_pDEM->Get_Gradient(x, y, d, Decay) ) { return( false ); } if( d < m_Slope_Min ) { d = m_Slope_Min; } Decay = Get_Fuzzy(d, 0.0, m_Slope_Max); if( m_Flow_Min > 0.0 ) { d = Get_Fuzzy(m_pFlow->asDouble(x, y), m_Flow_Min, m_Flow_Max); switch( 1 ) { default: Decay = M_GET_MAX(Decay, d); break; case 1: Decay = Decay + d - Decay * d; break; } } return( Decay > 0.0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_by_Slope::Set_Area(int x, int y) { double Decay; if( Get_Decay(x, y, Decay) ) { int i, ix, iy; double z, dzSum, dz[8]; for(i=0, dzSum=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { if( m_pDEM->is_InGrid(ix = Get_xTo(i, x), iy = Get_yTo(i, y)) && (dz[i] = z - m_pDEM->asDouble(ix, iy)) > 0.0 ) { dzSum += (dz[i] = pow(dz[i] / Get_Length(i), 1.1)); } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { Decay *= m_pFlow->asDouble(x, y) / dzSum; for(i=0; i<8; i++) { if( dz[i] > 0.0 ) { m_pFlow->Add_Value(Get_xTo(i, x), Get_yTo(i, y), Decay * dz[i]); } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_Parallel.cpp0000664000175000017500000007105212565125415027343 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_Parallel.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_Parallel.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow_Parallel.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_Parallel::CFlow_Parallel(void) { Set_Name (_TL("Flow Accumulation (Top-Down)")); Set_Author ("O.Conrad (c) 2001-2014, T.Grabs portions (c) 2010"); Set_Description (_TW( "Top-down processing of cells for calculation of flow accumulation and related parameters. " "This set of algorithms processes a DEM downwards from the highest to the lowest cell.\n" "\n" "References:\n" "\n" "Deterministic 8\n" "- O'Callaghan, J.F. / Mark, D.M. (1984):\n" " 'The extraction of drainage networks from digital elevation data',\n" " Computer Vision, Graphics and Image Processing, 28:323-344\n" "\n" "Rho 8:\n" "- Fairfield, J. / Leymarie, P. (1991):\n" " 'Drainage networks from grid digital elevation models',\n" " Water Resources Research, 27:709-717\n" "\n" "Braunschweiger Reliefmodell:\n" "- Bauer, J. / Rohdenburg, H. / Bork, H.-R. (1985):\n" " 'Ein Digitales Reliefmodell als Vorraussetzung fuer ein deterministisches Modell der Wasser- und Stoff-Fluesse',\n" " Landschaftsgenese und Landschaftsoekologie, H.10, Parameteraufbereitung fuer deterministische Gebiets-Wassermodelle,\n" " Grundlagenarbeiten zu Analyse von Agrar-Oekosystemen, (Eds.: Bork, H.-R. / Rohdenburg, H.), p.1-15\n" "\n" "Deterministic Infinity:\n" "- Tarboton, D.G. (1997):\n" " 'A new method for the determination of flow directions and upslope areas in grid digital elevation models',\n" " Water Resources Research, Vol.33, No.2, p.309-319\n" "\n" "Multiple Flow Direction:\n" "- Freeman, G.T. (1991):\n" " 'Calculating catchment area with divergent flow based on a regular grid',\n" " Computers and Geosciences, 17:413-22\n" "\n" "- Quinn, P.F. / Beven, K.J. / Chevallier, P. / Planchon, O. (1991):\n" " 'The prediction of hillslope flow paths for distributed hydrological modelling using digital terrain models',\n" " Hydrological Processes, 5:59-79\n" "\n" "Triangular Multiple Flow Direction\n" "- Seibert, J. / McGlynn, B. (2007):\n" " 'A new triangular multiple flow direction algorithm for computing upslope areas from gridded digital elevation models',\n" " Water Resources Research, Vol. 43, W04501\n" " C++ Implementation into SAGA by Thomas Grabs, Copyrights (c) 2007\n" " Contact: thomas.grabs@natgeo.su.se, jan.seibert@natgeo.su.se \n" "\n" "Multiple Flow Direction based on Maximum Downslope Gradient:\n" "- Qin, C. Z. / Zhu, A. X. / Pei, T. / Li, B. L. / Scholten, T. / Behrens, T. / & Zhou, C. H. (2011):\n" " 'An approach to computing topographic wetness index based on maximum downslope gradient',\n" " Precision Agriculture, 12(1), 32-43.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "FLOWLEN" , _TL("Flow Path Length"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "LINEAR_VAL" , _TL("Linear Flow Threshold Grid"), _TL("optional grid providing values to be compared with linear flow threshold instead of flow accumulation"), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "LINEAR_DIR" , _TL("Channel Direction"), _TL("use this for (linear) flow routing, if the value is a valid direction (0-7 = N, NE, E, SE, S, SW, W, NW)"), PARAMETER_INPUT_OPTIONAL ); //----------------------------------------------------- Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|"), _TL("Deterministic 8"), _TL("Rho 8"), _TL("Braunschweiger Reliefmodell"), _TL("Deterministic Infinity"), _TL("Multiple Flow Direction"), _TL("Multiple Triangular Flow Directon"), _TL("Multiple Maximum Downslope Gradient Based Flow Directon") ), 4 ); //----------------------------------------------------- CSG_Parameter *pNode; pNode = Parameters.Add_Value( NULL , "LINEAR_DO" , _TL("Thresholded Linear Flow"), _TL("apply linear flow routing (D8) to all cells, having a flow accumulation greater than the specified threshold"), PARAMETER_TYPE_Bool ); Parameters.Add_Value( pNode , "LINEAR_MIN" , _TL("Linear Flow Threshold"), _TL("flow accumulation threshold (cells) for linear flow routing"), PARAMETER_TYPE_Int, 500 ); Parameters.Add_Value( NULL , "CONVERGENCE" , _TL("Convergence"), _TL("Convergence factor for Multiple Flow Direction Algorithm (Freeman 1991).\nApplies also to the Multiple Triangular Flow Directon Algorithm."), PARAMETER_TYPE_Double, 1.1, 0.0, true ); Parameters.Add_Value( NULL , "WEIGHT_GT_0" , _TL("Suppress Negative Flow Accumulation Values"), _TL("keep accumulated weights above zero; useful e.g. when accumulating measures of water balance."), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CFlow_Parallel::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("CONVERGENCE", pParameter->asInt() == 4 || pParameter->asInt() == 5); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "LINEAR_DO") ) { pParameters->Set_Enabled("LINEAR_MIN", pParameter->asBool()); pParameters->Set_Enabled("LINEAR_VAL", pParameter->asBool()); } return( CFlow::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_Parallel::On_Initialize(void) { m_pFlowPath = Parameters("FLOWLEN")->asGrid(); m_Converge = Parameters("CONVERGENCE")->asDouble(); m_bGT_Zero = m_pWeight ? Parameters("WEIGHT_GT_0")->asBool() : false; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_Parallel::Calculate(void) { for(int y=0; ySet_Index() ) { return( false ); } //----------------------------------------------------- int Method = Parameters("METHOD")->asInt(); if( Method == 2 ) { BRM_Init(); } //----------------------------------------------------- double dLinear = Parameters("LINEAR_DO")->asBool() ? Parameters("LINEAR_MIN")->asDouble() : -1.0; CSG_Grid *pLinear_Val = Parameters("LINEAR_VAL")->asGrid(); CSG_Grid *pLinear_Dir = Parameters("LINEAR_DIR")->asGrid(); //----------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y) ) { if( m_bGT_Zero && m_pCatch->asDouble(x, y) < 0.0 ) { m_pCatch->Set_Value(x, y, 0.0); } if( pLinear_Dir && !pLinear_Dir->is_NoData(x, y) ) { Set_D8(x, y, pLinear_Dir->asInt(x, y)); } else if( dLinear > 0.0 && dLinear <= (pLinear_Val && !pLinear_Val->is_NoData(x, y) ? pLinear_Val->asDouble(x, y) : m_pCatch->asDouble(x, y)) ) { Set_D8(x, y, pLinear_Dir && !pLinear_Dir->is_NoData(x, y) ? pLinear_Dir->asInt(x, y) : -1); } else switch( Method ) { case 0: Set_D8 (x, y); break; case 1: Set_Rho8 (x, y); break; case 2: Set_BRM (x, y); break; case 3: Set_DInf (x, y); break; case 4: Set_MFD (x, y); break; case 5: Set_MDInf (x, y); break; case 6: Set_MMDGFD(x, y); break; } } } //----------------------------------------------------- if( m_pRoute ) { for(sLong n=0; nGet_Sorted(n, x, y, false) ) { Check_Route(x, y); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_Parallel::Check_Route(int x, int y) { if( m_pRoute->asChar(x, y) <= 0 ) { return; } //----------------------------------------------------- int i, ix, iy; double z = m_pDTM->asDouble(x, y); for(i=0; i<8; i++) { if( !m_pDTM->is_InGrid(ix = Get_xTo(i, x), iy = Get_yTo(i, y)) || z > m_pDTM->asDouble(ix, iy) ) { return; // cell is no sink } } //----------------------------------------------------- i = m_pRoute->asChar(x, y); ix = Get_xTo(i, ix); iy = Get_yTo(i, iy); //--------------------------------------------- while( m_pDTM->is_InGrid(ix, iy) ) { Add_Portion(x, y, ix, iy, i); if( (i = m_pRoute->asChar(ix, iy)) > 0 ) { ix = Get_xTo(i, ix); iy = Get_yTo(i, iy); } else if( (i = m_pDTM->Get_Gradient_NeighborDir(ix, iy)) >= 0 ) { ix = Get_xTo(i, ix); iy = Get_yTo(i, iy); } else { return; } } } /////////////////////////////////////////////////////////// // // // Deterministic 8 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_Parallel::Set_D8(int x, int y, int Direction) { Add_Fraction(x, y, Direction >= 0 ? Direction : m_pDTM->Get_Gradient_NeighborDir(x, y)); } /////////////////////////////////////////////////////////// // // // Rho 8 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_Parallel::Set_Rho8(int x, int y) { int iMax = -1; double dMax, z = m_pDTM->asDouble(x, y); for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( !m_pDTM->is_InGrid(ix, iy) ) { return; } else { double d = z - m_pDTM->asDouble(ix, iy); if( i % 2 == 1 ) { d /= 1.0 + rand() / (double)RAND_MAX; } if( iMax < 0 || dMax < d ) { iMax = i; dMax = d; } } } if( iMax >= 0 ) { Add_Fraction(x, y, iMax); } } /*void CFlow_Parallel::Set_Rho8( int x, int y ) { int Direction, ix, iy; double Slope, Aspect; Get_Gradient(x, y, Slope, Aspect); if( Aspect >= 0 ) { Direction = (int)(Aspect / M_PI_045); if( fmod(Aspect, M_PI_045) / M_PI_045 > rand() / (double)RAND_MAX ) { Direction++; } Direction %= 8; ix = Get_xTo(Direction, x); iy = Get_yTo(Direction, y); if( is_InGrid(ix, iy) && m_pDTM->asDouble(ix, iy) >= m_pDTM->asDouble(x, y) ) { Direction = Get_Direction_Lowest(m_pDTM, x, y); } Add_Fraction(x, y, Direction); } }/**/ /////////////////////////////////////////////////////////// // // // Deterministic Infinity // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_Parallel::Set_DInf(int x, int y) { double s, a; if( m_pDTM->Get_Gradient(x, y, s, a) && a >= 0.0 ) { int i, ix, iy; i = (int)(a / M_PI_045); a = fmod (a , M_PI_045) / M_PI_045; s = m_pDTM->asDouble(x, y); if( m_pDTM->is_InGrid(ix = Get_xTo(i + 0, x), iy = Get_yTo(i + 0, y)) && m_pDTM->asDouble(ix, iy) < s && m_pDTM->is_InGrid(ix = Get_xTo(i + 1, x), iy = Get_yTo(i + 1, y)) && m_pDTM->asDouble(ix, iy) < s ) { Add_Fraction(x, y, i , 1.0 - a); Add_Fraction(x, y, (i + 1) % 8, a); return; } } Set_D8(x, y); } /////////////////////////////////////////////////////////// // // // Multiple Flow Direction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_Parallel::Set_MFD(int x, int y) { int i, ix, iy; double z, d, dzSum, dz[8]; //----------------------------------------------------- for(i=0, dzSum=0.0, z=m_pDTM->asDouble(x, y); i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy) ) { d = z - m_pDTM->asDouble(ix, iy); } else { ix = Get_xTo(i + 4, x); iy = Get_yTo(i + 4, y); if( m_pDTM->is_InGrid(ix, iy) ) { d = m_pDTM->asDouble(ix, iy) - z; } else { d = 0.0; } } if( d > 0.0 ) { dzSum += (dz[i] = pow(d / Get_Length(i), m_Converge)); } else { dz[i] = 0.0; } } //----------------------------------------------------- if( dzSum > 0.0 ) { for(i=0; i<8; i++) { if( dz[i] > 0.0 ) { Add_Fraction(x, y, i, dz[i] / dzSum); } } } } /////////////////////////////////////////////////////////// // // // Multiple Maximum Downslope Gradient Flow Directon // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_Parallel::Set_MMDGFD(int x, int y) { int i, ix, iy; double z, d, dzMax, dzSum, dz[8]; //----------------------------------------------------- for(i=0, dzMax=0.0, z=m_pDTM->asDouble(x, y); i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy) ) { d = z - m_pDTM->asDouble(ix, iy); } else { ix = Get_xTo(i + 4, x); iy = Get_yTo(i + 4, y); if( m_pDTM->is_InGrid(ix, iy) ) { d = m_pDTM->asDouble(ix, iy) - z; } else { d = 0.0; } } if( d > 0.0 ) { dz[i] = d / Get_Length(i); if( dzMax < dz[i] ) { dzMax = dz[i]; } } else { dz[i] = 0.0; } } //----------------------------------------------------- if( dzMax > 0.0 ) { dzMax = dzMax < 1.0 ? 8.9 * dzMax + 1.1 : 10.0; for(i=0, dzSum=0.0; i<8; i++) { if( dz[i] > 0.0 ) { dzSum += (dz[i] = pow(dz[i], dzMax)); } } for(i=0; i<8; i++) { if( dz[i] > 0.0 ) { Add_Fraction(x, y, i, dz[i] / dzSum); } } } } /////////////////////////////////////////////////////////// // // // Multiple Triangular Flow Direction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_Parallel::Set_MDInf(int x, int y) { int i, ix, iy; double dz[8], s_facet[8], r_facet[8], valley[8], portion[8]; bool bInGrid[8]; //----------------------------------------------------- double z = m_pDTM->asDouble(x, y); for(i=0; i<8; i++) { s_facet[i] = r_facet[i] = -999.0; ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( (bInGrid[i] = m_pDTM->is_InGrid(ix, iy)) ) { dz[i] = z - m_pDTM->asDouble(ix, iy); } else { dz[i] = 0.0; } } //----------------------------------------------------- for(i=0; i<8; i++) { double hs = -999.; double hr = -999.; if( bInGrid[i] ) { int j = i < 7 ? i + 1 : 0; if( bInGrid[j] ) { double nx = (dz[j] * Get_yTo(i) - dz[i] * Get_yTo(j)) * Get_Cellsize(); // vb-code: nx = (z1 * yd(j) - z2 * yd(i)) * gridsize /*ERROR?*/ double ny = (dz[i] * Get_xTo(j) - dz[j] * Get_xTo(i)) * Get_Cellsize(); // vb-code: ny = (z1 * xd(j) - z2 * xd(i)) * gridsize double nz = (Get_xTo(i) * Get_yTo(j) - Get_xTo(j) * Get_yTo(i)) * Get_Cellarea(); // vb-code: nz = (xd(j) * yd(i) - xd(i) * yd(j)) * gridsize ^ 2 double n_norm = sqrt(nx*nx + ny*ny +nz*nz); /* if( nx == 0.0 ) { hr = (ny >= 0.0)? 0.0 : M_PI; } else if( nx > 0.0 ) { hr = M_PI_090 - atan(ny / nx); } else { hr = M_PI_270 - atan(ny / nx); } */ if( nx == 0.0 ) { hr = (ny >= 0.0)? 0.0 : M_PI; } else if( nx < 0.0 ) { hr = M_PI_270 - atan(ny / nx); } else { hr = M_PI_090 - atan(ny / nx); } hs = -tan( acos( nz/n_norm ) ); // vb-code: hs = -Tan(arccos(nz / betrag_n)) // vb-code: If hr <= (i - 1) * PI / 4 Or hr >= i * PI / 4 Then //SHOULD IT BE LIKE THIS: (( hr <= i * M_PI_045 || hr >= j * M_PI_045 ) OR AS BELOW??? if( hr < i * M_PI_045 || hr > (i+1) * M_PI_045 ) { if( dz[i] > dz[j] ) { hr = i * M_PI_045; hs = dz[i] / Get_Length(i); } else { hr = j * M_PI_045; hs = dz[j] / Get_Length(j); } } } else if( dz[i] > 0.0 ) { hr = i * M_PI_045; hs = dz[i] / Get_Length(i); } s_facet[i] = hs; r_facet[i] = hr; } } //----------------------------------------------------- double dzSum = 0.0; for(i=0; i<8; i++) { valley[i] = 0.0; int j = i < 7 ? i + 1 : 0; if( s_facet[i] > 0.0 ) { if( r_facet[i] > i * M_PI_045 && r_facet[i] < (i+1) * M_PI_045 ) { valley[i] = s_facet[i]; } else if( r_facet[i] == r_facet[j] ) { valley[i] = s_facet[i]; } else if( s_facet[j] == -999.0 && r_facet[i] == (i+1) * M_PI_045 ) { valley[i] = s_facet[i]; } else { j = i > 0 ? i - 1 : 7; if( s_facet[j] == -999.0 && r_facet[i] == i * M_PI_045 ) { valley[i] = s_facet[i]; } } valley[i] = pow(valley[i], m_Converge); dzSum += valley[i]; } portion[i] = 0.0; } //----------------------------------------------------- if( dzSum ) { for(i=0; i<8; i++) { int j = i < 7 ? i + 1 : 0; if( i >= 7 && r_facet[i] == 0.0 ) { r_facet[i] = M_PI_360; } if( valley[i] ) { valley[i] /= dzSum; portion[i] += valley[i] * ((i+1) * M_PI_045 - r_facet[i]) / M_PI_045; // vb-code: portion(i) = portion(i) + valley(i) * (i * PI / 4 - r_facet(i)) / (PI / 4) portion[j] += valley[i] * (r_facet[i] - (i ) * M_PI_045) / M_PI_045; // vb-code: portion(j) = portion(j) + valley(i) * (r_facet(i) - (i - 1) * PI / 4) / (PI / 4) } } for(i=0; i<8; i++) { Add_Fraction(x, y, i, portion[i]); } } } /////////////////////////////////////////////////////////// // // // Braunschweiger Reliefmodell // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow_BRM.h" #define BRM_nint(x) ((int)(x >= 0 ? x + 0.5 : x - 0.5)) //--------------------------------------------------------- void CFlow_Parallel::Set_BRM( int x, int y ) { int Dir, QBinaer, ix[3], iy[3], nexp[6]; double QLinks, QMitte, QRecht, nnei[6]; //----------------------------------------------------- if( is_InGrid(x, y, 1) ) // Rand !!! { Dir = BRM_InitRZ(x,y,ix,iy); if( Dir >= 0 ) { if( Dir % 2 ) { BRM_GetDiago(Dir,x,y,ix,iy,nnei,nexp); BRM_QStreuung(4,1,nnei,nexp,QBinaer,QLinks,QMitte,QRecht); } else { BRM_GetOrtho(Dir,x,y,ix,iy,nnei,nexp); BRM_QStreuung(6,0,nnei,nexp,QBinaer,QLinks,QMitte,QRecht); } Add_Fraction(x,y,(Dir+1)%8,BRM_BitMtrx[0][QBinaer] ? QLinks : 0); Add_Fraction(x,y,(Dir+0)%8,BRM_BitMtrx[1][QBinaer] ? QMitte : 0); Add_Fraction(x,y,(Dir+7)%8,BRM_BitMtrx[2][QBinaer] ? QRecht : 0); } } } //--------------------------------------------------------- void CFlow_Parallel::BRM_Init(void) { int i; double DXT = Get_Cellsize()/2, DYT = Get_Cellsize()/2; //----------------------------------------------------- BRM_kgexp[0] = (int)(atan2(DXT , Get_Cellsize()) * M_RAD_TO_DEG); BRM_kgexp[1] = (int)(atan2(Get_Cellsize(), DYT ) * M_RAD_TO_DEG) + 1; BRM_kgexp[2] = (int)(atan2(Get_Cellsize(),-DYT ) * M_RAD_TO_DEG); BRM_kgexp[3] = (int)(atan2(DXT ,-Get_Cellsize()) * M_RAD_TO_DEG) + 1; for(i=0; i<4; i++) BRM_kgexp[i+4] = BRM_kgexp[i] + 180; //---BRM_idreh--------------------------------------------- BRM_idreh[0] = 180; BRM_idreh[1] = 180 - BRM_nint(atan2(Get_Cellsize(), Get_Cellsize()) * M_RAD_TO_DEG); BRM_idreh[2] = 90; BRM_idreh[3] = BRM_nint(atan2(Get_Cellsize(), Get_Cellsize()) * M_RAD_TO_DEG); BRM_idreh[4] = 0; for(i=1; i<4; i++) BRM_idreh[i+4] = BRM_idreh[i] + 180; } //--------------------------------------------------------- int CFlow_Parallel::BRM_InitRZ(int x, int y, int ix[3], int iy[3]) { int i, j, Dir; double Slope, Aspect; Get_Gradient(x, y, Slope, Aspect); Aspect *= M_RAD_TO_DEG; if( Aspect < 0 ) { return( -1 ); } //---Kategorisierte-Exposition------------------------- Dir = 0; while( Aspect > BRM_kgexp[Dir] && Dir < 8 ) Dir++; Dir %=8; //---Finde-Die-3-ZielRasterZellen---------------------- for(i=0; i<3; i++) // zxy[]: 0=Recht, 1=Mitte, 2=Links { j = (Dir + 7 + i) % 8; ix[2-i] = Get_xTo(j,x); iy[2-i] = Get_yTo(j,y); } return(Dir); } //--------------------------------------------------------- void CFlow_Parallel::BRM_GetOrtho(int Dir, int x, int y, int ix[3], int iy[3], double nnei[6], int nexp[6]) { int jx, jy, i, i0 = (Dir + 2) % 8, i4 = (Dir + 6) % 8; double Slope, Aspect; for(i=0; i<3; i++) { jx = ix[i]; jy = iy[i]; Get_Gradient(jx, jy, Slope, Aspect); nnei[i] = M_RAD_TO_DEG * Slope; nexp[i] = (int)(M_RAD_TO_DEG * Aspect); } jx = Get_xTo(i0,x); jy = Get_yTo(i0,y); Get_Gradient(jx, jy, Slope, Aspect); nnei[3] = M_RAD_TO_DEG * Slope; nexp[3] = (int)(M_RAD_TO_DEG * Aspect); jx = Get_xTo(i4,x); jy = Get_yTo(i4,y); Get_Gradient(jx, jy, Slope, Aspect); nnei[5] = M_RAD_TO_DEG * Slope; nexp[5] = (int)(M_RAD_TO_DEG * Aspect); Get_Gradient(x, y, Slope, Aspect); nnei[4] = M_RAD_TO_DEG * Slope; nexp[4] = (int)(M_RAD_TO_DEG * Aspect); //[jy][jx]) ????!!!!...; for(i=0; i<6; i++) if(nexp[i]<0) nexp[i] = nexp[4]; for(i=0; i<6; i++) { nexp[i] += BRM_idreh[Dir]; if(nexp[i]>360) nexp[i] -= 360; } } //--------------------------------------------------------- void CFlow_Parallel::BRM_GetDiago(int Dir, int x, int y, int ix[3], int iy[3], double nnei[6], int nexp[6]) { int i; double Slope, Aspect; Get_Gradient( x , y , Slope, Aspect); nexp[0] = (int)(M_RAD_TO_DEG * Aspect); nnei[0] = M_RAD_TO_DEG * Slope; Get_Gradient(ix[0], iy[0], Slope, Aspect); nexp[1] = (int)(M_RAD_TO_DEG * Aspect); nnei[1] = M_RAD_TO_DEG * Slope; Get_Gradient(ix[2], iy[2], Slope, Aspect); nexp[2] = (int)(M_RAD_TO_DEG * Aspect); nnei[2] = M_RAD_TO_DEG * Slope; Get_Gradient(ix[1], iy[1], Slope, Aspect); nexp[3] = (int)(M_RAD_TO_DEG * Aspect); nnei[3] = M_RAD_TO_DEG * Slope; for(i=1; i<4; i++) if(nexp[i]<0) nexp[i] = nexp[0]; for(i=0; i<4; i++) { nexp[i] += BRM_idreh[Dir]; if(nexp[i]>360) nexp[i] -= 360; } } //--------------------------------------------------------- void CFlow_Parallel::BRM_QStreuung(int i64, int g64, double nnei[6], int nexp[6], int &QBinaer, double &QLinks, double &QMitte, double &QRecht) { int i, j, ix, iy, ALinks, AMitte=2, ARecht; double x=1, y=1, sg=0, a, s[6], c[6]; ALinks = ARecht = 0; QLinks = QRecht = 0.0; for(i=0; i8.99 || y<1 ) { ALinks = 4; QLinks = 1; break; } if(y>8.95) { if(x<1.02) { ALinks = 0; QLinks = 0; } else { ALinks = 4; QLinks = (x - 1) / 8; if(i64==4) { if(QLinks<0.5) QLinks = QLinks * (1.67 - QLinks * 1.078); else QLinks = QLinks * 0.869 + 0.131; } } break; } } //---QRechts-ermitteln--------------------------------- x = 9; y = 1; for(i=0; i<100; i++) { ix = BRM_nint(x) - 1; iy = BRM_nint(y) - 1; for(j=0; j9) { ARecht = 0; QRecht = 0; break; } if( x<1.01 || y<1 ) { ARecht = 1; QRecht = 1; break; } if(y>8.95) { if(x>8.98) { ARecht = 0; QRecht = 0; } else { ARecht = 1; QRecht = 1 - (x - 1) / 8; if(i64==4) { if(QRecht<0.5) QRecht = QRecht * (1.67 - QRecht * 1.078); else QRecht = QRecht * 0.869 + 0.131; } } break; } } //---QMitte-ist-Rest-/-QBinaer'Bits-setzen------------- QMitte = 1 - QLinks - QRecht; QBinaer = ALinks + AMitte + ARecht; if(QMitte<=0.01) { a = QLinks + QRecht; QLinks /= a; QRecht /= a; QMitte = 0; QBinaer -= 2; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_RecursiveDown.cpp0000664000175000017500000004523512565125415030412 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_RecursiveDown.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_RecursiveDown.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow_RecursiveDown.h" //--------------------------------------------------------- #define GET_OUTLET_DIAG__1(in, angle) (1.0 - (1.0 - in) * tan(M_PI_090 - angle)) #define GET_OUTLET_CROSS_1(in, angle) (in + tan(angle)) #define GET_OUTLET_DIAG__2(in, angle) (in * tan(angle)) #define GET_OUTLET_CROSS_2(in, angle) (in - tan(M_PI_090 - angle)) #define GET_LENGTH(a, b) (sqrt((a)*(a) + (b)*(b))) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_RecursiveDown::CFlow_RecursiveDown(void) { Set_Name (_TL("Flow Accumulation (Flow Tracing)")); Set_Author (SG_T("O.Conrad (c) 2001")); Set_Description (_TW( "Flow tracing algorithms for calculations of flow accumulation and related parameters. " "These algorithms trace the flow of each cell in a DEM separately until it finally leaves the DEM or ends in a sink.\n\n" "References:\n\n" "Rho 8 (this implementation adopted the original algorithm only for the flow routing and will give quite different results):\n" "- Fairfield, J. / Leymarie, P. (1991):\n" " 'Drainage networks from grid digital elevation models',\n" " Water Resources Research, 27:709-717\n\n" "Kinematic Routing Algorithm:\n" "- Lea, N.L. (1992):\n" " 'An aspect driven kinematic routing algorithm',\n" " in: Parsons, A.J., Abrahams, A.D. (Eds.), 'Overland Flow: hydraulics and erosion mechanics', London, 147-175\n\n" "DEMON:\n" "- Costa-Cabral, M. / Burges, S.J. (1994):\n" " 'Digital Elevation Model Networks (DEMON): a model of flow over hillslopes for computation of contributing and dispersal areas',\n" " Water Resources Research, 30:1681-1692\n\n") ); //----------------------------------------------------- // Method... Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Rho 8"), _TL("Kinematic Routing Algorithm"), _TL("DEMON") ), 1 ); //----------------------------------------------------- // Options... Parameters.Add_Value( NULL , "MINDQV" , _TL("DEMON - Min. DQV"), _TL("DEMON - Minium Drainage Quota Volume (DQV) for traced flow tubes"), PARAMETER_TYPE_Double , 0.0, 0.0, true, 1.0, true ); Parameters.Add_Value( NULL , "CORRECT" , _TL("Flow Correction"), _TL(""), PARAMETER_TYPE_Bool ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveDown::On_Initialize(void) { int x, y; double Slope, Aspect; //----------------------------------------------------- Method = Parameters("METHOD" )->asInt(); DEMON_minDQV = Parameters("MINDQV" )->asDouble(); bFlowPathWeight = Parameters("CORRECT")->asBool(); pLinear = 1 ? SG_Create_Grid(m_pDTM, SG_DATATYPE_Float) : NULL; //----------------------------------------------------- Lock_Create(); //----------------------------------------------------- switch( Method ) { case 0: default: // Rho 8... pDir = NULL; pDif = NULL; break; //----------------------------------------------------- case 1: case 2: // KRA, DEMON... pDir = SG_Create_Grid(m_pDTM, SG_DATATYPE_Char); pDif = SG_Create_Grid(m_pDTM, SG_DATATYPE_Float); for(y=0; yis_NoData(x, y) ) { Get_Gradient(x, y, Slope, Aspect); if( Aspect >= 0.0 ) { pDir->Set_Value(x, y, 2 * (((int)(Aspect / M_PI_090)) % 4)); pDif->Set_Value(x, y, fmod(Aspect, M_PI_090)); } } } } break; } } //--------------------------------------------------------- void CFlow_RecursiveDown::On_Finalize(void) { //----------------------------------------------------- if( pDir ) { delete(pDir); } if( pDif ) { delete(pDif); } Lock_Destroy(); //----------------------------------------------------- if( pLinear ) { if( m_pDTM->Set_Index() ) { for(sLong n=0; nGet_Sorted(n, x, y) && (qFlow = pLinear->asDouble(x, y)) > 0.0 ) { Add_Flow(x, y, qFlow); if( (dir = m_pDTM->Get_Gradient_NeighborDir(x, y)) >= 0 ) { x = Get_xTo(dir, x); y = Get_yTo(dir, y); if( m_pDTM->is_InGrid(x, y) ) { pLinear->Add_Value(x, y, qFlow); } } } } } delete(pLinear); pLinear = NULL; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_RecursiveDown::Calculate(void) { for(int y=0; yis_NoData(x, y) && (qFlow = m_pWeight ? m_pWeight->asDouble(x, y) : 1.0) > 0.0 ) { Src_Value = m_pVal_Mean && !m_pVal_Input->is_NoData(x, y) ? m_pVal_Input->asDouble(x, y) : 0.0; Add_Flow(x, y, qFlow); Lock_Set(x, y, 1); switch( Method ) { case 0: Rho8_Start (x, y, qFlow); break; case 1: KRA_Start (x, y, qFlow); break; case 2: DEMON_Start(x, y, qFlow); break; } Lock_Set(x, y, 0); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveDown::Add_Flow(int x, int y, double Fraction) { if( m_pCatch ) { m_pCatch ->Add_Value(x, y, Fraction); } if( m_pVal_Mean ) { m_pVal_Mean->Add_Value(x, y, Fraction * Src_Value ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveDown::Rho8_Start(int x, int y, double qFlow) { int dir, ix, iy; double Slope, Aspect; //----------------------------------------------------- Get_Gradient(x, y, Slope, Aspect); if( Aspect >= 0.0 ) { dir = (int)(Aspect / M_PI_045); if( fmod(Aspect, M_PI_045) / M_PI_045 > rand() / (double)RAND_MAX ) { dir++; } dir %= 8; ix = Get_xTo(dir, x); iy = Get_yTo(dir, y); //------------------------------------------------- if( is_InGrid(ix, iy) ) { if( is_Locked(ix, iy) ) { if( pLinear ) { pLinear->Add_Value(x, y, qFlow); } } else { Lock_Set( x, y, 1); Add_Flow(ix, iy, qFlow); Rho8_Start(ix, iy, qFlow); Lock_Set( x, y, 0); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveDown::KRA_Start(int x, int y, double qFlow) { int dir; double dif; if( (dif = pDif->asDouble(x, y)) > M_PI_045 ) // to the right... { dir = pDir->asInt(x, y) + 2; dif = 0.5 - tan(M_PI_090 - dif) / 2.0; } else // to the top... { dir = pDir->asInt(x, y) + 0; dif = 0.5 + tan(dif) / 2.0; } KRA_Trace(x, y, qFlow, dir, dif); } //--------------------------------------------------------- void CFlow_RecursiveDown::KRA_Trace(int x, int y, double qFlow, int Direction, double from) { bool bLinear; int dir; double dif, to, weight; Direction %= 8; x = Get_xTo(Direction, x); y = Get_yTo(Direction, y); //----------------------------------------------------- if( m_pDTM->is_InGrid(x, y) && !is_Locked(x, y) ) { Lock_Set(x, y, 1); bLinear = false; weight = 1.0; dir = pDir->asInt(x, y); dif = pDif->asDouble(x, y); //------------------------------------------------- if( Direction == dir ) // entering from the bottom... { if( from > 1.0 - tan(dif) ) // 1. to the right... { to = GET_OUTLET_DIAG__1(from, dif); KRA_Trace(x, y, qFlow, dir + 2, to); if( bFlowPathWeight ) { weight = GET_LENGTH(1.0 - from, 1.0 - to); } } else // 2. to the top... { to = GET_OUTLET_CROSS_1(from, dif); KRA_Trace(x, y, qFlow, dir + 0, to); if( bFlowPathWeight ) { weight = GET_LENGTH(1.0, to - from); } } } else if( (8 + Direction - dir) % 8 == 2 ) // entering from the left... { if( from < tan(M_PI_090 - dif) ) // 1. to the top... { to = GET_OUTLET_DIAG__2(from, dif); KRA_Trace(x, y, qFlow, dir + 0, to); if( bFlowPathWeight ) { weight = GET_LENGTH(from, to); } } else // 2. to the right... { to = GET_OUTLET_CROSS_2(from, dif); KRA_Trace(x, y, qFlow, dir + 2, to); if( bFlowPathWeight ) { weight = GET_LENGTH(1.0, from - to); } } } else // go linear... { bLinear = true; } //------------------------------------------------- if( bLinear && pLinear ) { pLinear->Add_Value(x, y, qFlow); } else { Add_Flow(x, y, weight * qFlow); } Lock_Set(x, y, 0); } } /////////////////////////////////////////////////////////// // // // DEMON - Digital Elevation MOdel Network // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_RecursiveDown::DEMON_Start(int x, int y, double qFlow) { double dif, flow_A, flow_B; if( (dif = pDif->asDouble(x, y)) < M_PI_045 ) // mostly to the top... { flow_B = tan(dif) / 2.0; flow_A = 1.0 - flow_B; } else // mostly to the right... { flow_A = tan(M_PI_090 - dif) / 2.0; flow_B = 1.0 - flow_A; } flow_A *= qFlow; flow_B *= qFlow; if( flow_A <= DEMON_minDQV ) { DEMON_Trace(x, y, qFlow , pDir->asInt(x, y) + 2, 0.0, 1.0); // all to the right... } else if( flow_B <= DEMON_minDQV ) { DEMON_Trace(x, y, qFlow , pDir->asInt(x, y) + 0, 0.0, 1.0); // all to the top... } else { DEMON_Trace(x, y, flow_A, pDir->asInt(x, y) + 0, 0.0, 1.0); // to the top... DEMON_Trace(x, y, flow_B, pDir->asInt(x, y) + 2, 0.0, 1.0); // to the right... } } //--------------------------------------------------------- void CFlow_RecursiveDown::DEMON_Trace(int x, int y, double qFlow, int Direction, double from_A, double from_B) { bool bLinear; int dir; double dif, to_A, to_B, flow_A, flow_B, weight; Direction %= 8; x = Get_xTo(Direction, x); y = Get_yTo(Direction, y); //----------------------------------------------------- if( m_pDTM->is_InGrid(x, y) && !is_Locked(x, y) ) { Lock_Set(x, y, 1); bLinear = false; weight = 1.0; dir = pDir->asInt(x, y); dif = pDif->asDouble(x, y); //------------------------------------------------- if( Direction == dir ) // entering from the bottom... { if( from_A >= 1.0 - tan(dif) ) // 1. completely to the right... { to_A = GET_OUTLET_DIAG__1(from_A, dif); to_B = GET_OUTLET_DIAG__1(from_B, dif); DEMON_Trace(x, y, qFlow, dir + 2, to_A, to_B); if( bFlowPathWeight ) { //weight = ((1.0 - from_A) * (1.0 - to_A) - (1.0 - from_B) * (1.0 - to_B)) / 2.0; // area... weight = GET_LENGTH(1.0 - (from_B + from_A) / 2.0, 1.0 - (to_B + to_A) / 2.0); } } else if( from_B < 1.0 - tan(dif) ) // 2. completely to the top... { to_A = GET_OUTLET_CROSS_1(from_A, dif); to_B = GET_OUTLET_CROSS_1(from_B, dif); DEMON_Trace(x, y, qFlow, dir + 0, to_A, to_B); if( bFlowPathWeight ) { //weight = from_B - from_A; // area... weight = GET_LENGTH(1.0, to_A - from_A); } } else // 3. partly to the right, partly to the top... { to_A = GET_OUTLET_CROSS_1(from_A, dif); to_B = GET_OUTLET_DIAG__1(from_B, dif); dif = 1.0 - tan(dif); flow_A = dif - from_A; flow_B = from_B - dif; flow_A = qFlow * flow_A / (flow_A + flow_B); flow_B = qFlow - flow_A; if( bFlowPathWeight ) { //weight = (dif - from_A) + ((1.0 - dif) - (1.0 - from_B) * (1.0 - to_B)) / 2.0; // area... if( (weight = (from_A + from_B) / 2.0) < dif ) // to the top... { weight = GET_LENGTH(1.0, to_A - from_A); } else // to the right... { weight = (1.0 - weight) / (1.0 - dif) * GET_LENGTH(1.0, to_A - from_A); } } if( flow_A <= DEMON_minDQV ) { DEMON_Trace(x, y, qFlow, dir + 2, 0.0, to_B); } else if( flow_B <= DEMON_minDQV ) { DEMON_Trace(x, y, qFlow, dir + 0, to_A, 1.0); } else { DEMON_Trace(x, y, flow_A, dir + 0, to_A, 1.0); DEMON_Trace(x, y, flow_B, dir + 2, 0.0, to_B); } } } else if( (8 + Direction - dir) % 8 == 2 ) // entering from the left... { if( from_B <= tan(M_PI_090 - dif) ) // 1. completely to the top... { to_A = GET_OUTLET_DIAG__2(from_A, dif); to_B = GET_OUTLET_DIAG__2(from_B, dif); DEMON_Trace(x, y, qFlow, dir + 0, to_A, to_B); if( bFlowPathWeight ) { //weight = (from_B * to_B - from_A * to_A) / 2.0; // area... weight = GET_LENGTH((from_A + from_B) / 2.0, (to_A + to_B) / 2.0); } } else if( from_A > tan(M_PI_090 - dif) ) // 2. completely to the right... { to_A = GET_OUTLET_CROSS_2(from_A, dif); to_B = GET_OUTLET_CROSS_2(from_B, dif); DEMON_Trace(x, y, qFlow, dir + 2, to_A, to_B); if( bFlowPathWeight ) { //weight = from_B - from_A; // area... weight = GET_LENGTH(1.0, from_A - to_A); } } else // 3. partly to the top, partly to the right... { to_A = GET_OUTLET_DIAG__2(from_A, dif); to_B = GET_OUTLET_CROSS_2(from_B, dif); dif = tan(M_PI_090 - dif); flow_A = dif - from_A; flow_B = from_B - dif; flow_A = qFlow * flow_A / (flow_A + flow_B); flow_B = qFlow - flow_A; if( bFlowPathWeight ) { //weight = (from_B - dif) + (dif - (from_A * to_A)) / 2.0; // area... if( (weight = (from_A + from_B) / 2.0) > dif ) { weight = GET_LENGTH(1.0, from_B - to_B); } else { weight = weight / dif * GET_LENGTH(1.0, from_B - to_B); } } if( flow_A <= DEMON_minDQV ) { DEMON_Trace(x, y, qFlow, dir + 2, 0.0, to_B); } else if( flow_B <= DEMON_minDQV ) { DEMON_Trace(x, y, qFlow, dir + 0, to_A, 1.0); } else { DEMON_Trace(x, y, flow_A, dir + 0, to_A, 1.0); DEMON_Trace(x, y, flow_B, dir + 2, 0.0, to_B); } } } else { bLinear = true; } //------------------------------------------------- if( bLinear && pLinear ) { pLinear->Add_Value(x, y, qFlow); } else { if( bFlowPathWeight ) { Add_Flow(x, y, weight * qFlow); //Add_Flow(x, y, weight >= qFlow ? qFlow : weight * qFlow); } else { Add_Flow(x, y, qFlow); } } Lock_Set(x, y, 0); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/IsochronesConst.cpp0000664000175000017500000001241312565125415027737 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: IsochronesConst.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* IsochronesConst.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "Helper.h" #include "IsochronesConst.h" //----------------------------------------------------- CIsochronesConst::CIsochronesConst(void){ Set_Name(_TL("Isochrones Constant Speed")); Set_Author(_TL("V.Olaya (c) 2004, V.Wichmann (c) 2015")); Set_Description (_TW("Isochrones calculation with constant speed based on a user " "provided Time of Concentration. For each selected pour point, " "the longest watercourse length and the average slope of the " "watercourse are reported. These can be used to estimate the " "Time of Concentration with one of the empirical equations " "available.\n\n")); Parameters.Add_Grid(NULL, "DEM", _TL("Elevation Grid"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "TIME", _TL("Time Out [min]"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Double); Parameters.Add_Value( NULL, "TIME_OF_CONCENTRATION", _TL("Time of Concentration [min]"), _TL("Time of Concentration [min] used to estimate flow speed."), PARAMETER_TYPE_Double, 60.0, 0.001, true ); }//constructor //----------------------------------------------------- CIsochronesConst::~CIsochronesConst(void){ On_Execute_Finish(); } //----------------------------------------------------- void CIsochronesConst::_CalculateDistance(int x, int y) { CSG_Grid_Stack Stack; Stack.Push(x, y); //----------------------------------------------------- while( Stack.Get_Size() > 0 && Process_Get_Okay() ) { Stack.Pop(x, y); //------------------------------------------------- for(int i=0; i<8; i++) { int ix = Get_xFrom(i, x); int iy = Get_yFrom(i, y); if( m_pDEM->is_InGrid(ix, iy) && i == m_Direction.asInt(ix, iy) ) { m_pTime->Set_Value(ix, iy, m_pTime->asDouble(x, y) + Get_Length(i)); Stack.Push(ix, iy); } } } return; } //----------------------------------------------------- bool CIsochronesConst::On_Execute(void) { m_pDEM = Parameters("DEM")->asGrid(); m_pTime = Parameters("TIME")->asGrid(); m_pTime->Assign(0.0); m_dConcTime = Parameters("TIME_OF_CONCENTRATION")->asDouble(); m_Direction.Create(*Get_System(), SG_DATATYPE_Char); m_Direction.Set_NoData_Value(-1); Init_FlowDirectionsD8(m_pDEM, &m_Direction); return( true ); } //----------------------------------------------------- bool CIsochronesConst::On_Execute_Finish(void) { m_Direction.Destroy(); return( true ); } //----------------------------------------------------- bool CIsochronesConst::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { int iX, iY; int iHighX, iHighY; if( Mode != MODULE_INTERACTIVE_LDOWN || !Get_Grid_Pos(iX, iY) ) { return( false ); } m_pTime->Assign(0.0); _CalculateDistance(iX, iY); double dMax = m_pTime->Get_ZMax(); bool bMaxFound = false; for(int y=0; yasDouble(x,y); if (dValue == dMax) { #pragma omp critical { iHighX = x; iHighY = y; bMaxFound = true; } } }// for }// for double dMaxDist = m_pTime->Get_ZMax(); double dH1 = m_pDEM->asDouble(iX, iY); double dH2 = m_pDEM->asDouble(iHighX, iHighY); double dSpeed = dMaxDist / m_dConcTime; SG_UI_Msg_Add(SG_T("--------------------------------------------------------------------------------"), true); SG_UI_Msg_Add(CSG_String::Format(_TL("Longest watercourse length: %.2f m"), dMaxDist), true); SG_UI_Msg_Add(CSG_String::Format(_TL("Average slope of watercourse: %.2f m/m"), (dH2 - dH1) / dMaxDist), true); SG_UI_Msg_Add(CSG_String::Format(_TL("Average velocity in watercourse: %.2f m/min"), dSpeed), true); SG_UI_Msg_Add(SG_T("--------------------------------------------------------------------------------"), true); for(int y=0; ySet_Value(x, y, m_pTime->asDouble(x, y) / dSpeed); } } m_pTime->Set_NoData_Value(0.0); DataObject_Update(m_pTime, SG_UI_DATAOBJECT_SHOW_LAST_MAP); return (true); }//method saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/TopographicIndices.h0000664000175000017500000001375112565125415030045 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: TopographicIndices.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // TopographicIndices.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__TopographicIndices_H #define HEADER_INCLUDED__TopographicIndices_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_hydrology_EXPORT CTWI : public CSG_Module_Grid { public: CTWI(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Topographic Indices" )); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_hydrology_EXPORT CStream_Power : public CSG_Module_Grid { public: CStream_Power(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Topographic Indices" )); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_hydrology_EXPORT CLS_Factor : public CSG_Module_Grid { public: CLS_Factor(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Topographic Indices" )); } protected: virtual bool On_Execute (void); private: int m_Method, m_Stability; double m_Erosivity; double Get_LS (double Slope, double Area); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_hydrology_EXPORT CTCI_Low : public CSG_Module_Grid { public: CTCI_Low(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Topographic Indices" )); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__TopographicIndices_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Helper.cpp0000664000175000017500000002343112565125415026035 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Helper.cpp 1016 2011-04-27 18:40:36Z oconrad $ *********************************************************/ /******************************************************************************* Helper.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "Helper.h" void Init_FlowDirectionsD8(CSG_Grid *pDEM, CSG_Grid *pDirection) { for(int y=0; yGet_NY() && SG_UI_Process_Set_Progress(y, pDEM->Get_NY()); y++) { #pragma omp parallel for for(int x=0; xGet_NX(); x++) { pDirection->Set_Value(x, y, pDEM->Get_Gradient_NeighborDir(x, y), false); } } } void getNextCell( CSG_Grid *g, int iX, int iY, int &iNextX, int &iNextY) { float fDist; float fMaxSlope; float fSlope; fMaxSlope = 0; fSlope = 0; if (iX < 1 || iX >= g->Get_NX() - 1 || iY < 1 || iY >= g->Get_NY() - 1 || g->is_NoData(iX,iY)) { iNextX = iX; iNextY = iY; return; }// if for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (!g->is_NoData(iX + i, iY + i)){ if (i == 0 || j == 0) { fDist = 1.0f; }// if else { fDist = 1.414f; }// else fSlope = (g->asFloat(iX+i,iY+j) - g->asFloat(iX,iY)) / fDist; if (fSlope <= fMaxSlope) { iNextX = iX+i; iNextY = iY+j; fMaxSlope = fSlope; }// if }//if }// for }// for }// method void getNextCell( CSG_Grid *g, CSG_Grid *g2, int iX, int iY, int &iNextX, int &iNextY) { double fDist; double fMaxSlope; double fSlope; fMaxSlope = 0.0000001; fSlope = 0; if (iX < 1 || iX >= g->Get_NX() - 1 || iY < 1 || iY >= g->Get_NY() - 1 || g->is_NoData(iX,iY)) { iNextX = iX; iNextY = iY; return; }// if for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (!g->is_NoData(iX+i,iY+j) && !g2->is_NoData(iX+i,iY+j)){ if (i == 0 || j == 0) { fDist = 1.0f; }// if else { fDist = 1.414f; }// else fSlope = (g->asFloat(iX+i,iY+j) - g->asFloat(iX,iY)) / fDist; if (fSlope < fMaxSlope) { iNextX = iX+i; iNextY = iY+j; fMaxSlope = fSlope; }// if }//if }// for }// for }// method double FlowDistance(CSG_Grid *pDEM, CSG_Grid *pBasinGrid, int iBasin, int iX, int iY, int iX2, int iY2){// result in m, coords in grid coords. Returns 0 if no distance is calculated. bool bIsInBasin; double dDist = 1; int iNextX = iX; int iNextY = iY; if (iX2 <= 0 || iX2 >= pDEM->Get_NX() || iY2 <= 0 || iY2 >= pDEM->Get_NY() || iX <= 0 || iX >= pDEM->Get_NX() || iY <= 0 || iY >= pDEM->Get_NY() ) { return 0; }// if do { iX = iNextX; iY = iNextY; getNextCell(pDEM,iX,iY,iNextX,iNextY); if (fabs((double)(iX - iNextX + iY - iNextY)) == 1.0) { dDist = dDist + pDEM->Get_Cellsize(); }// if else { dDist = dDist + 1.414 * pDEM->Get_Cellsize(); }// else if (iX == iX2 && iY == iY2) { return dDist; }// if if (iBasin == GLOBAL_BASIN){ bIsInBasin = !pBasinGrid->is_NoData(iX,iY); }//if else{ bIsInBasin = (pBasinGrid->asInt(iX,iY) == iBasin); }//else }while (bIsInBasin &&(iX!=iNextX || iY!=iNextY)); return 0; }// method double AccFlow(CSG_Grid *pGrid, CSG_Grid *pDEM, int iX, int iY){ int iNextX, iNextY; double dAccFlow = pGrid->Get_Cellsize()*pGrid->Get_Cellsize(); for (int i = -1; i<2; i++){ for (int j = -1; j<2; j++){ if (!(i == 0) || !(j == 0)) { getNextCell(pDEM, iX + i, iY + j, iNextX, iNextY); if (iNextY == iY && iNextX == iX) { if (pGrid->asDouble(iX+i,iY+j)!=0){ dAccFlow += pGrid->asDouble(iX+i,iY+j); }//if else{ dAccFlow += AccFlow (pGrid,pDEM,iX+i,iY+j); }//else }// if }//if }//for }//for pGrid->Set_Value(iX,iY,dAccFlow); return dAccFlow; }// function double CalculateBasinGrid(CSG_Grid *pBasinGrid, CSG_Grid *pDEM, int iOutletX, int iOutletY){ pBasinGrid->Assign((double)0); double dAccFlow = AccFlow(pBasinGrid,pDEM,iOutletX,iOutletY); return dAccFlow; }//function void CalculateFlowAccGrid(CSG_Grid *pFlowAccGrid, CSG_Grid *pDEM){ int x,y; pFlowAccGrid->Assign((double)0); for(y=0; yGet_NY(); y++){ for(x=0; xGet_NX(); x++){ AccFlow(pFlowAccGrid,pDEM,x,y); }//for }//for pFlowAccGrid->Set_Description(_TL("Acc. Area")); pFlowAccGrid->Set_Unit(_TL("m2")); }//function /* #include TSG_Point ** RiverProfile(int iX, int iY, CSG_Grid* pDEM, CSG_Grid* pBasinGrid, CSG_Grid* pExtGrid, int &iProfileLength){ int i; float fLength = 0; int iNextX, iNextY; CSG_Points Profile; CSG_Points Ext; TSG_Point P; TSG_Point **pProfile; iProfileLength = 0; if (!pBasinGrid->is_NoData(iX,iY)) { iNextX = iX; iNextY = iY; do { iX = iNextX; iY = iNextY; getNextCell(pDEM, iX, iY, iNextX, iNextY); if (fabs(iX - iNextX + iY - iNextY) == 1) { fLength += pDEM->Get_DX(); }//if else { fLength += (1.414f * pDEM->Get_DX()); }//else P.x = fLength; P.y = pDEM->asFloat(iNextX, iNextY); Profile.push_back(P); P.y = pExtGrid->asFloat(iNextX, iNextY); Ext.push_back(P); }while (!pBasinGrid->is_NoData(iX, iY) && (iX != iNextX || iY != iNextY)); pProfile = new Pt*[2]; for (i = 0; i<2; i++){ pProfile[i] = new Pt [Profile.size()]; }//for for (i = 0; iis_NoData(iX,iY)) { iNextX = iX; iNextY = iY; do { iX = iNextX; iY = iNextY; getNextCell(pDEM, iX, iY, iNextX, iNextY); P.x = iX; P.y = iY; Profile.push_back(P); }while (!pBasinGrid->is_NoData(iX, iY) && (iX != iNextX || iY != iNextY)); pProfile = new Pt [Profile.size()]; for (int i = 0; iAssign(0); for (int i = 0; i < pHeaders->Get_Count(); i++) { iX = (pHeaders->Get_Shape(i)->Get_Point(0).x - pBasinGrid->Get_XMin())/pBasinGrid->Get_DX(); iY = (pHeaders->Get_Shape(i)->Get_Point(0).y - pBasinGrid->Get_YMin())/pBasinGrid->Get_DX(); if (!pBasinGrid->is_NoData(iX,iY)) { iNextX = iX; iNextY = iY; do { iX = iNextX; iY = iNextY; getNextCell(pDEM, iX, iY, iNextX, iNextY); if (fabs(iX - iNextX + iY - iNextY) == 1) { fLength += pChannelsGrid->Get_DX(); }//if else { fLength += (1.414f * pChannelsGrid->Get_DX()); }//else if (pChannelsGrid->asFloat(iX,iY) == 0) { pChannelsGrid->Set_Value(iX, iY, 1); }// if else { break; }// else }while (!pBasinGrid->is_NoData(iX, iY) && (iX != iNextX || iY != iNextY)); }// if }// for float fArea = pBasins->Get_Shape(0)->asFloat(4); return fLength / fArea / 10000.0; }//method void ClosingPoint(CSG_Grid* pDEM, CSG_Grid* pBasinGrid, int &iClosingX, int &iClosingY){ int x,y; int iX,iY; int iNextX, iNextY; for (x = 0; xGet_NX(); x++){ for (y = 0; yGet_NY(); y++){ if (!pBasinGrid->is_NoData(x,y)){ iX = x; iY = y; goto out; }//if }//for }//for return; out: iNextX = iX; iNextY = iY; do { iX = iNextX; iY = iNextY; getNextCell(pDEM, iX, iY, iNextX, iNextY); }while (!pBasinGrid->is_NoData(iX, iY) && (iX != iNextX || iY != iNextY)); iClosingX = iX; iClosingY = iY; }//method*/saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/CellBalance.cpp0000664000175000017500000001413212565125415026741 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CellBalance.cpp 1616 2013-02-27 16:23:56Z oconrad $ *********************************************************/ /******************************************************************************* CellBalance.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "CellBalance.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCellBalance::CCellBalance(void) { Set_Name (_TL("Cell Balance")); Set_Author (SG_T("(c) 2004 by V.Olaya, (c) 2006 by O.Conrad")); Set_Description (_TW( "(c) 2004 by Victor Olaya. Cell Balance Calculation\r\n" "References:\r\n 1. Olaya, V. Hidrologia computacional y modelos digitales del terreno. Alqua. 536 pp. 2004" )); Parameters.Add_Grid( NULL, "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_or_Const( NULL, "WEIGHTS" , _TL("Weights"), _TL(""), 1.0, 0.0, true ); Parameters.Add_Grid( NULL, "BALANCE" , _TL("Cell Balance"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL, "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Deterministic 8"), _TL("Multiple Flow Direction") ) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCellBalance::On_Execute(void) { int Method; double Weight; CSG_Grid *pWeights; m_pDEM = Parameters("DEM" )->asGrid(); pWeights = Parameters("WEIGHTS")->asGrid(); Weight = Parameters("WEIGHTS")->asDouble(); m_pBalance = Parameters("BALANCE")->asGrid(); Method = Parameters("METHOD" )->asInt(); m_pBalance->Assign(0.0); for(int y=0; yis_NoData(x, y) ) { m_pBalance->Set_NoData(x, y); } else { if( pWeights ) { Weight = pWeights->is_NoData(x, y) ? 0.0 : pWeights->asDouble(x, y); } if( Weight ) { m_pBalance->Add_Value(x, y, -Weight); switch( Method ) { case 0: Set_D8 (x, y, Weight); break; case 1: Set_MFD (x, y, Weight); break; } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CCellBalance::Set_D8(int x, int y, double Weight) { int Dir; if( (Dir = m_pDEM->Get_Gradient_NeighborDir(x, y)) >= 0 ) { x += Get_xTo(Dir); y += Get_yTo(Dir); if( is_InGrid(x, y) ) { m_pBalance->Add_Value(x, y, Weight); } } } //--------------------------------------------------------- void CCellBalance::Set_MFD(int x, int y, double Weight) { const double MFD_Converge = 1.1; int i, ix, iy; double z, d, dzSum, dz[8]; z = m_pDEM->asDouble(x, y); dzSum = 0.0; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && (d = z - m_pDEM->asDouble(ix, iy)) > 0.0 ) { dz[i] = pow(d / Get_Length(i), MFD_Converge); dzSum += dz[i]; } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { d = Weight / dzSum; for(i=0; i<8; i++) { if( dz[i] > 0.0 ) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); m_pBalance->Add_Value(ix, iy, dz[i] * d); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// /*/--------------------------------------------------------- #include "Helper.h" double CCellBalance::getCellBalance(int iX, int iY) { int iNextX, iNextY; double dIn=0, dOut=0, dBalance; for (int i = -1; i<2; i++){ for (int j = -1; j<2; j++){ if (!(i == 0) || !(j == 0)) { getNextCell(m_pDEM, iX + i, iY + j, iNextX, iNextY); if (iNextY == iY && iNextX == iX) { dIn+=m_pWeight->asDouble(iX+i,iY+j); }// if }//if }//for }//for dOut = m_pWeight->asDouble(iX,iY); dBalance = dIn-dOut; return dBalance; }//function bool CCellBalance::On_Execute(void) { m_pDEM = Parameters("DEM")->asGrid(); m_pWeight = Parameters("WEIGHT")->asGrid(); m_pBalance = Parameters("BALANCE")->asGrid(); m_pBalance->Assign((double)0); for(int y=0; ySet_Value(x,y,getCellBalance(x,y)); }// for }// for return( true ); }//method /**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/TopographicIndices.cpp0000664000175000017500000004755412565125415030410 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: TopographicIndices.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // TopographicIndices.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "TopographicIndices.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTWI::CTWI(void) { //----------------------------------------------------- Set_Name (_TL("Topographic Wetness Index (TWI)")); Set_Author (SG_T("O.Conrad (c) 2003")); Set_Description (_TW( "Calculation of the slope and specific catchment area (SCA) based Topographic Wetness Index (TWI)\n" // "ln(SCA / tan(Slope))\n" "\n" "References:\n" "\n" "Beven, K.J., Kirkby, M.J. (1979):\n" "A physically-based variable contributing area model of basin hydrology'\n" "Hydrology Science Bulletin 24(1), p.43-69\n" "\n" "Boehner, J., Selige, T. (2006):\n" "Spatial Prediction of Soil Attributes Using Terrain Analysis and Climate Regionalisation'\n" "In: Boehner, J., McCloy, K.R., Strobl, J.: 'SAGA - Analysis and Modelling Applications', " "Goettinger Geographische Abhandlungen, Vol.115, p.13-27\n" "\n" "Moore, I.D., Grayson, R.B., Ladson, A.R. (1991):\n" "'Digital terrain modelling: a review of hydrogical, geomorphological, and biological applications'\n" "Hydrological Processes, Vol.5, No.1\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL, "SLOPE" , _TL("Slope"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "AREA" , _TL("Catchment Area"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "TRANS" , _TL("Transmissivity"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "TWI" , _TL("Topographic Wetness Index"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "CONV" , _TL("Area Conversion"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("no conversion (areas already given as specific catchment area)"), _TL("1 / cell size (pseudo specific catchment area)") ), 0 ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method (TWI)"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Standard"), _TL("TOPMODEL") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTWI::On_Execute(void) { bool bTopmodel, bConvert; int x, y; double Area, Slope, Kf, Mean_Kf, Mean_TWI; CSG_Grid *pArea, *pSlope, *pKf, *pTWI; //----------------------------------------------------- pSlope = Parameters("SLOPE") ->asGrid(); pArea = Parameters("AREA") ->asGrid(); pKf = Parameters("TRANS") ->asGrid(); pTWI = Parameters("TWI") ->asGrid(); bConvert = Parameters("CONV") ->asInt() == 1; bTopmodel = Parameters("METHOD") ->asInt() == 1; DataObject_Set_Colors(pTWI, 100, SG_COLORS_RED_GREY_BLUE); //----------------------------------------------------- Kf = 1.0; if( bTopmodel ) { Mean_TWI = 0.0; Mean_Kf = 0.0; Area = 0.0; for(y=0; yis_NoData(x, y) && !pSlope->is_NoData(x, y) ) { if( pKf ) { if( !pKf->is_NoData(x, y) ) { Kf = pKf->asDouble(x, y); if( Kf < M_ALMOST_ZERO ) Kf = M_ALMOST_ZERO; Kf = log(Kf); } else { Kf = 0.0; } } Slope = tan(pSlope->asDouble(x, y)); if( Slope < M_ALMOST_ZERO ) Slope = M_ALMOST_ZERO; Area ++; Mean_TWI += log((pArea->asDouble(x, y) / (bConvert ? Get_Cellsize() : 1.0)) / Slope); Mean_Kf += Kf; } } } if( Area > 0.0 ) { Area *= pArea->Get_Cellarea(); Mean_TWI /= Area; Mean_Kf /= Area; } else { return( false ); } } //----------------------------------------------------- for(y=0; yis_NoData(x, y) || pSlope->is_NoData(x, y) || (pKf && pKf->is_NoData(x, y)) ) { pTWI->Set_NoData(x, y); } else { Area = pArea->asDouble(x, y); if( bConvert ) Area /= Get_Cellsize(); Slope = tan(pSlope->asDouble(x, y)); if( Slope < M_ALMOST_ZERO ) Slope = M_ALMOST_ZERO; if( pKf ) { Kf = pKf->asDouble(x, y); if( Kf < M_ALMOST_ZERO ) Kf = M_ALMOST_ZERO; } pTWI->Set_Value(x, y, bTopmodel ? (log(Area / ( Slope)) - Mean_TWI) - (log(Kf) - Mean_Kf) : log(Area / (Kf * Slope)) ); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CStream_Power::CStream_Power(void) { //----------------------------------------------------- Set_Name (_TL("Stream Power Index")); Set_Author (SG_T("O.Conrad (c) 2003")); Set_Description (_TW( "Calculation of stream power index based on slope and specific catchment area (SCA).\n" "SPI = SCA * tan(Slope)\n" "\n" "References:\n" "\n" "Moore, I.D., Grayson, R.B., Ladson, A.R. (1991):\n" "'Digital terrain modelling: a review of hydrogical, geomorphological, and biological applications'\n" "Hydrological Processes, Vol.5, No.1\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "SLOPE" , _TL("Slope"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "AREA" , _TL("Catchment Area"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SPI" , _TL("Stream Power Index"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "CONV" , _TL("Area Conversion"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("no conversion (areas already given as specific catchment area)"), _TL("1 / cell size (pseudo specific catchment area)") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CStream_Power::On_Execute(void) { bool bConvert; CSG_Grid *pArea, *pSlope, *pSPI; //----------------------------------------------------- pSlope = Parameters("SLOPE") ->asGrid(); pArea = Parameters("AREA") ->asGrid(); pSPI = Parameters("SPI") ->asGrid(); bConvert = Parameters("CONV") ->asInt() == 1; DataObject_Set_Colors(pSPI, 100, SG_COLORS_RED_GREY_GREEN, true); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) || pSlope->is_NoData(x, y) ) { pSPI->Set_NoData(x, y); } else { pSPI->Set_Value(x, y, (pArea->asDouble(x, y) / (bConvert ? Get_Cellsize() : 1.0)) * tan(pSlope->asDouble(x, y))); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLS_Factor::CLS_Factor(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("LS Factor")); Set_Author (SG_T("O.Conrad (c) 2003")); Set_Description (_TW( "Calculation of slope length (LS) factor as used by the Universal Soil Loss Equation (USLE), " "based on slope and specific catchment area (SCA, as substitute for slope length). " "\n" "References:\n" "\n" "Boehner, J., Selige, T. (2006):\n" "Spatial Prediction of Soil Attributes Using Terrain Analysis and Climate Regionalisation'\n" "In: Boehner, J., McCloy, K.R., Strobl, J.: 'SAGA - Analysis and Modelling Applications', " "Goettinger Geographische Abhandlungen, Vol.115, p.13-27\n" "\n" "Desmet & Govers (1996):\n" "'A GIS Procedure for Automatically Calculating the USLE LS Factor on Topographically Complex Landscape Units'\n" "Journal of Soil and Water Conservation, 51(5):427.433\n" "\n" "Kinnell, P.I.A. (2005):\n" "'Alternative Approaches for Determining the USLE-M Slope Length Factor for Grid Cells.'\n" "http://soil.scijournals.org/cgi/content/full/69/3/674\n" "\n" "Moore, I.D., Grayson, R.B., Ladson, A.R. (1991):\n" "'Digital terrain modelling: a review of hydrogical, geomorphological, and biological applications'\n" "Hydrological Processes, Vol.5, No.1\n" "\n" "Wischmeier, W.H., Smith, D.D. (1978):\n" "'Predicting rainfall erosion losses - A guide to conservation planning'\n" "Agriculture Handbook No. 537: US Department of Agriculture, Washington DC.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "SLOPE" , _TL("Slope"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "AREA" , _TL("Catchment Area"), _TL(""), PARAMETER_INPUT ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "LS" , _TL("LS Factor"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "CONV" , _TL("Area to Length Conversion"), _TL("Derivation of slope lengths from catchment areas. These are rough approximations! Applies not to Desmet & Govers' method."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("no conversion (areas already given as specific catchment area)"), _TL("1 / cell size (specific catchment area)"), _TL("square root (catchment length)") ), 0 ); //----------------------------------------------------- Parameters.Add_Choice( NULL , "METHOD" , _TL("Method (LS)"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Moore et al. 1991"), _TL("Desmet & Govers 1996"), _TL("Boehner & Selige 2006") ), 0 ); pNode = Parameters.Add_Node( NULL , "NODE_DG" , _TL("Desmet & Govers"), _TL("") ); Parameters.Add_Value( pNode , "EROSIVITY" , _TL("Rill/Interrill Erosivity"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Choice( pNode , "STABILITY" , _TL("Stability"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("stable"), _TL("instable (thawing)") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLS_Factor::On_Execute(void) { int Conversion; CSG_Grid *pArea, *pSlope, *pLS; //----------------------------------------------------- pSlope = Parameters("SLOPE") ->asGrid(); pArea = Parameters("AREA") ->asGrid(); pLS = Parameters("LS") ->asGrid(); Conversion = Parameters("CONV") ->asInt(); m_Method = Parameters("METHOD") ->asInt(); m_Erosivity = Parameters("EROSIVITY") ->asInt(); m_Stability = Parameters("STABILITY") ->asInt(); DataObject_Set_Colors(pLS, 100, SG_COLORS_RED_GREY_GREEN, true); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) || pSlope->is_NoData(x, y) ) { pLS->Set_NoData(x, y); } else { double Area; switch( Conversion ) { default: Area = pArea->asDouble(x, y); // no conversion... case 1: Area = pArea->asDouble(x, y) / Get_Cellsize(); // pseudo specific catchment area... case 2: Area = sqrt(pArea->asDouble(x, y)); // pseudo slope length... } pLS->Set_Value(x, y, Get_LS(pSlope->asDouble(x, y), Area)); } } } return( true ); } //--------------------------------------------------------- double CLS_Factor::Get_LS(double Slope, double Area) { double LS, sinSlope; switch( m_Method ) { //----------------------------------------------------- case 0: default: { LS = (0.4 + 1) * pow(Area / 22.13, 0.4) * pow(sin(Slope) / 0.0896, 1.3); } break; //----------------------------------------------------- case 1: { double L, S, m, x, d; sinSlope = sin(Slope); d = Get_Cellsize(); m = m_Erosivity * (sinSlope / 0.0896) / (3.0 * pow(sinSlope, 0.8) + 0.56); m = m / (1.0 + m); // x = Aspect < 0.0 ? 0.0 : fmod(Aspect, M_PI_090); // x = sin(x) + cos(x); x = 1.0; // x : coefficient that adjusts for width of flow at the center of the cell. // It has a value of 1.0 when the flow is toward a side and sqrt(2.0) when // the flow is toward a corner. // (Peter I. A. Kinnell: 'ALTERNATIVE APPROACHES FOR DETERMINING THE // USLE-M SLOPE LENGTH FACTOR FOR GRID CELLS' // https://www.soils.org/publications/sssaj/abstracts/69/3/0674) L = (pow(Area + d*d, m + 1.0) - pow(Area, m + 1.0)) / (pow(d, m + 2.0) * pow(22.13, m) * pow(x, m)); //----------------------------------------------------- if( Slope < 0.08975817419 ) // < 9% Steigung := atan(0.09), ca. 5 Degree { S = 10.8 * sinSlope + 0.03; } else if( m_Stability == 0 ) // >= 9% Steigung, stabil { S = 16.8 * sinSlope - 0.5; } else // >= 9% Steigung, tauend u. instabil { S = pow(sinSlope / 0.896, 0.6); } LS = L * S; } break; //----------------------------------------------------- case 2: { sinSlope = sin(Slope); if( Slope > 0.0505 ) // > ca. 3 Degree { LS = sqrt(Area / 22.13) * (65.41 * sinSlope * sinSlope + 4.56 * sinSlope + 0.065); } else // <= ca. 3 Degree { LS = pow (Area / 22.13, 3.0 * pow(Slope, 0.6)) * (65.41 * sinSlope * sinSlope + 4.56 * sinSlope + 0.065); } } break; } return( LS ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTCI_Low::CTCI_Low(void) { //----------------------------------------------------- Set_Name (_TL("TCI Low")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Terrain Classification Index for Lowlands (TCI Low).\n" "\n" "Reference:\n" "Bock, M., Boehner, J., Conrad, O., Koethe, R., Ringeler, A. (2007): " "Methods for creating Functional Soil Databases and applying Digital Soil Mapping with SAGA GIS. " "In: Hengl, T., Panagos, P., Jones, A., Toth, G. [Eds.]: " "Status and prospect of soil information in south-eastern Europe: soil databases, projects and applications. " "EUR 22646 EN Scientific and Technical Research series, Office for Official Publications of the European Communities, Luxemburg, p.149-162. " "online.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DISTANCE" , _TL("Vertical Distance to Channel Network"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "TWI" , _TL("Topographic Wetness Index"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "TCILOW" , _TL("TCI Low"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTCI_Low::On_Execute(void) { //----------------------------------------------------- CSG_Grid *pDistance = Parameters("DISTANCE")->asGrid(); CSG_Grid *pTWI = Parameters("TWI" )->asGrid(); CSG_Grid *pTCI_Low = Parameters("TCILOW" )->asGrid(); DataObject_Set_Colors(pTCI_Low, 100, SG_COLORS_RED_GREY_BLUE, false); double dMax = pDistance->Get_ZMax(); double dRange = pDistance->Get_ZRange(); double wMin = pTWI->Get_ZMin(); double wRange = log(1.0 + pTWI->Get_ZRange()); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) || pTWI->is_NoData(x, y) ) { pTCI_Low->Set_NoData(x, y); } else { double d = (dMax - pDistance->asDouble(x, y)) / dRange; // inverted, normalized [0...1] double w = log(1.0 + (pTWI->asDouble(x, y) - wMin)) / wRange; // natural logarithm, normalized [0...1] pTCI_Low->Set_Value(x, y, (2.0 * d + w) / 3.0); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/flow_width.h0000664000175000017500000001074512565125415026435 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: flow_width.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // flow_width.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__flow_width_H #define HEADER_INCLUDED__flow_width_H //--------------------------------------------------------- #include //--------------------------------------------------------- class CFlow_Width : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CFlow_Width(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Flow Accumulation" )); } protected: /// protected members and functions: /////////// virtual bool On_Execute (void); private: ///// private members and functions: ///////////// CSG_Grid *m_pDEM; double Get_D8 (int x, int y); double Get_MFD (int x, int y); double Get_Aspect (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__flow_width_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_AreaDownslope.cpp0000664000175000017500000002460012565125415030347 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_AreaDownslope.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_AreaDownslope.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow_AreaDownslope.h" #include "Flow_Parallel.h" #include "Flow_RecursiveDown.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_AreaDownslope::CFlow_AreaDownslope(void) { Set_Name(_TL("Downslope Area")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (_TW( "This interactive module allows you to specify source cells (with a left mouse click), " "for which the downslope area shall be identified. " "For the 'Deterministic Infinity' and 'Multiple Flow Direction' algorithms, " "which are able to simulate flow divergence, the result will give " "the percentage of the source cell's flow that drains through each cell.\n\n" "References:\n\n" "Deterministic 8\n" "- O'Callaghan, J.F. / Mark, D.M. (1984):\n" " 'The extraction of drainage networks from digital elevation data',\n" " Computer Vision, Graphics and Image Processing, 28:323-344\n\n" "Rho 8:\n" "- Fairfield, J. / Leymarie, P. (1991):\n" " 'Drainage networks from grid digital elevation models',\n" " Water Resources Research, 27:709-717\n\n" "Braunschweiger Reliefmodell:\n" "- Bauer, J. / Rohdenburg, H. / Bork, H.-R. (1985):\n" " 'Ein Digitales Reliefmodell als Vorraussetzung fuer ein deterministisches Modell der Wasser- und Stoff-Fluesse',\n" " Landschaftsgenese und Landschaftsoekologie, H.10, Parameteraufbereitung fuer deterministische Gebiets-Wassermodelle,\n" " Grundlagenarbeiten zu Analyse von Agrar-Oekosystemen, (Eds.: Bork, H.-R. / Rohdenburg, H.), p.1-15\n\n" "Deterministic Infinity:\n" "- Tarboton, D.G. (1997):\n" " 'A new method for the determination of flow directions and upslope areas in grid digital elevation models',\n" " Water Resources Research, Vol.33, No.2, p.309-319\n\n" "Multiple Flow Direction:\n" "- Freeman, G.T. (1991):\n" " 'Calculating catchment area with divergent flow based on a regular grid',\n" " Computers and Geosciences, 17:413-22\n\n" "- Quinn, P.F. / Beven, K.J. / Chevallier, P. / Planchon, O. (1991):\n" " 'The prediction of hillslope flow paths for distributed hydrological modelling using digital terrain models',\n" " Hydrological Processes, 5:59-79\n\n" "Kinematic Routing Algorithm:\n" "- Lea, N.L. (1992):\n" " 'An aspect driven kinematic routing algorithm',\n" " in: Parsons, A.J., Abrahams, A.D. (Eds.), 'Overland Flow: hydraulics and erosion mechanics', London, 147-175\n\n" "DEMON:\n" "- Costa-Cabral, M. / Burges, S.J. (1994):\n" " 'Digital Elevation Model Networks (DEMON): a model of flow over hillslopes for computation of contributing and dispersal areas',\n" " Water Resources Research, 30:1681-1692\n\n") ); //----------------------------------------------------- // Input... Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SINKROUTE" , _TL("Sink Routes"), _TL(""), PARAMETER_INPUT_OPTIONAL ); //----------------------------------------------------- // Output... Parameters.Add_Grid( NULL , "AREA" , _TL("Downslope Area"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- // Method... Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("Deterministic 8"), _TL("Rho 8"), _TL("Braunschweiger Reliefmodell"), _TL("Deterministic Infinity"), _TL("Multiple Flow Direction"), _TL("Multiple Triangular Flow Directon"), _TL("Multiple Maximum Downslope Gradient Based Flow Directon"), _TL("Kinematic Routing Algorithm"), _TL("DEMON") ), 4 ); //----------------------------------------------------- // Options... Parameters.Add_Value( NULL , "CONVERG" , _TL("Convergence"), _TL("Convergence factor for Multiple Flow Direction algorithm"), PARAMETER_TYPE_Double, 1.1, 0.001, true ); //----------------------------------------------------- // Initialisations... pFlow = NULL; } //--------------------------------------------------------- CFlow_AreaDownslope::~CFlow_AreaDownslope(void) { On_Execute_Finish(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_AreaDownslope::On_Execute(void) { CSG_Parameters *pParameters; if( On_Execute_Finish() ) { switch( Parameters("METHOD")->asInt() ) { // Parallel... case 0: // Deterministic 8... pFlow = new CFlow_Parallel; pFlow->Get_Parameters()->Get_Parameter("METHOD")->Set_Value(0.0); break; case 1: // Rho 8... pFlow = new CFlow_RecursiveDown; pFlow->Get_Parameters()->Get_Parameter("METHOD")->Set_Value(0.0); break; case 2: // BRM... pFlow = new CFlow_Parallel; pFlow->Get_Parameters()->Get_Parameter("METHOD")->Set_Value(2); break; case 3: // Deterministic Infinity... pFlow = new CFlow_Parallel; pFlow->Get_Parameters()->Get_Parameter("METHOD")->Set_Value(3); break; case 4: // MFD... pFlow = new CFlow_Parallel; pFlow->Get_Parameters()->Get_Parameter("METHOD")->Set_Value(4); break; case 5: // Triangular MFD... pFlow = new CFlow_Parallel; pFlow->Get_Parameters()->Get_Parameter("METHOD")->Set_Value(5); break; case 6: // Multiple Maximum Downslope Gradient Based Flow Directon... pFlow = new CFlow_Parallel; pFlow->Get_Parameters()->Get_Parameter("METHOD")->Set_Value(6); break; // Downward Recursive... case 7: // KRA... pFlow = new CFlow_RecursiveDown; pFlow->Get_Parameters()->Get_Parameter("METHOD")->Set_Value(1); break; case 8: // DEMON... pFlow = new CFlow_RecursiveDown; pFlow->Get_Parameters()->Get_Parameter("METHOD")->Set_Value(2); //pFlow->Parameters(DEMON_minDQV)-Set_Value(0) = 0; break; } //------------------------------------------------- if( pFlow ) { pParameters = pFlow->Get_Parameters(); pFlow->Get_System()->Assign(Parameters("ELEVATION")->asGrid()->Get_System()); pParameters->Get_Parameter("ELEVATION") ->Set_Value(Parameters("ELEVATION") ->asGrid()); pParameters->Get_Parameter("SINKROUTE") ->Set_Value(Parameters("SINKROUTE") ->asGrid()); pParameters->Get_Parameter("CAREA") ->Set_Value(Parameters("AREA") ->asGrid()); } } return( pFlow != NULL ); } //--------------------------------------------------------- bool CFlow_AreaDownslope::On_Execute_Finish(void) { if( pFlow ) { delete( pFlow ); pFlow = NULL; } return( pFlow == NULL ); } //--------------------------------------------------------- bool CFlow_AreaDownslope::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { if( pFlow && Mode == MODULE_INTERACTIVE_LDOWN ) { pFlow->Set_Point(Get_xGrid(), Get_yGrid()); pFlow->Execute(); DataObject_Update(Parameters("AREA")->asGrid(), 0.0, 100.0, true); return( true ); } return( false ); } saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_AreaUpslope.h0000664000175000017500000001422412565125415027472 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_AreaUpslope.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_AreaUpslope.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Flow_AreaUpslope_H #define HEADER_INCLUDED__Flow_AreaUpslope_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFlow_AreaUpslope { public: CFlow_AreaUpslope(void); virtual ~CFlow_AreaUpslope(void); CSG_String Get_Description (void); CSG_String Get_Methods (void); bool Initialise (int Method, CSG_Grid *pDTM, CSG_Grid *pRoute, CSG_Grid *pFlow, double MFD_Converge); bool Finalise (void); bool Add_Target (int x, int y); bool Clr_Target (void); bool Get_Area (int x, int y); bool Get_Area (void); private: int m_Method; double m_MFD_Converge; CSG_Grid *m_pDTM, *m_pRoute, *m_pFlow; void Set_Value (int x, int y); void Set_D8 (int x, int y); void Set_DInf (int x, int y); void Set_MFD (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFlow_AreaUpslope_Interactive : public CSG_Module_Grid_Interactive { public: CFlow_AreaUpslope_Interactive(void); virtual ~CFlow_AreaUpslope_Interactive(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Flow Accumulation" )); } protected: virtual bool On_Execute (void); virtual bool On_Execute_Finish (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CFlow_AreaUpslope m_Calculator; }; //--------------------------------------------------------- class CFlow_AreaUpslope_Area : public CSG_Module_Grid { public: CFlow_AreaUpslope_Area(void); virtual ~CFlow_AreaUpslope_Area(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Flow Accumulation" )); } protected: virtual bool On_Execute (void); private: CFlow_AreaUpslope m_Calculator; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Flow_AreaUpslope_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/flow_width.cpp0000664000175000017500000001770012565125415026766 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: flow_width.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // flow_width.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "flow_width.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_Width::CFlow_Width(void) { Set_Name (_TL("Flow Width and Specific Catchment Area")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "Flow width and specific catchment area (SCA) calculation.\n" "\n" "References:\n" "Gruber, S., Peckham, S. (2008): Land-Surface Parameters and Objects in Hydrology. " "In: Hengl, T. and Reuter, H.I. [Eds.]: Geomorphometry: Concepts, Software, Applications. " "Developments in Soil Science, Elsevier, 33:293-308.\n" "\n" "Quinn, P.F., Beven, K.J., Chevallier, P., Planchon, O. (1991): " "The prediction of hillslope flow paths for distributed hydrological modelling using digital terrain models. " "Hydrological Processes, 5:59-79\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "WIDTH" , _TL("Flow Width"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "TCA" , _TL("Total Catchment Area (TCA)"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "SCA" , _TL("Specific Catchment Area (SCA)"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Deterministic 8"), _TL("Multiple Flow Direction (Quinn et al. 1991)"), _TL("Aspect") ), 2 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_Width::On_Execute(void) { int x, y, Method; double Width; CSG_Grid *pWidth, *pTCA, *pSCA; //----------------------------------------------------- m_pDEM = Parameters("DEM") ->asGrid(); pWidth = Parameters("WIDTH") ->asGrid(); pTCA = Parameters("TCA") ->asGrid(); pSCA = Parameters("SCA") ->asGrid(); Method = Parameters("METHOD") ->asInt(); if( pTCA ) { if( pSCA == NULL ) { Parameters("SCA")->Set_Value(pSCA = SG_Create_Grid(*Get_System(), SG_DATATYPE_Float)); } pSCA->Set_Name(_TL("Specific Catchment Area")); } //----------------------------------------------------- for(y=0; y 0.0 ) { pWidth->Set_Value(x, y, Width); } else { pWidth->Set_NoData(x, y); } if( pTCA && pSCA ) { if( Width > 0.0 && !pTCA->is_NoData(x, y) ) { pSCA->Set_Value(x, y, pTCA->asDouble(x, y) / Width); } else { pSCA->Set_NoData(x, y); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CFlow_Width::Get_D8(int x, int y) { int Direction; if( (Direction = m_pDEM->Get_Gradient_NeighborDir(x, y)) >= 0 ) { return( Get_Length(Direction) ); } return( -1.0 ); } //--------------------------------------------------------- inline double CFlow_Width::Get_MFD(int x, int y) { if( m_pDEM->is_InGrid(x, y) ) { double Width = 0.0; double z = m_pDEM->asDouble(x, y); for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy, true) && z > m_pDEM->asDouble(ix, iy) ) { Width += 0.5 * Get_Cellsize() / Get_System()->Get_UnitLength(i); } } return( Width ); } return( -1.0 ); } //--------------------------------------------------------- inline double CFlow_Width::Get_Aspect(int x, int y) { double Slope, Aspect; if( m_pDEM->Get_Gradient(x, y, Slope, Aspect) ) { return( (fabs(sin(Aspect)) + fabs(cos(Aspect))) * Get_Cellsize() ); } return( -1.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_Distance.h0000664000175000017500000001137312565125415027006 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_Distance.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_Distance.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Flow_Distance_H #define HEADER_INCLUDED__Flow_Distance_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_hydrology_EXPORT CFlow_Distance : public CSG_Module_Grid { public: CFlow_Distance(void); virtual ~CFlow_Distance(void); virtual CSG_String Get_MenuPath (void) { return( SG_T("Flow Accumulation") ); } protected: virtual bool On_Execute (void); private: double m_Converge; CSG_Grid *m_pDTM, *m_pLength, *m_pWeight; void Set_Length_D8 (int x, int y); void Set_Length_MFD (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Flow_Distance_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/flow_massflux.cpp0000664000175000017500000003024512565125415027510 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: flow_massflux.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // flow_massflux.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "flow_massflux.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const int xDir[4] = { 1, 1, 0, 0 }; const int yDir[4] = { 1, 0, 0, 1 }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_MassFlux::CFlow_MassFlux(void) { Set_Name (_TL("Flow Accumulation (Mass-Flux Method)")); Set_Author ("O. Conrad (c) 2009"); Set_Description (_TW( "The Mass-Flux Method (MFM) for the DEM based calculation of flow accumulation " "as proposed by Gruber and Peckham (2008).\n" "\n" "!!!UNDER DEVELOPMENT!!! To be done: solving the streamline resolution problem\n" "\n" "References:\n" "Gruber, S., Peckham, S. (2008): Land-Surface Parameters and Objects in Hydrology. " "In: Hengl, T. and Reuter, H.I. [Eds.]: Geomorphometry: Concepts, Software, Applications. " "Developments in Soil Science, Elsevier, Bd.33, S.293-308.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "AREA" , _TL("Flow Accumulation"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Flow Split Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("flow width (original)"), _TL("cell area") ), 0 ); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Node(NULL, "NODE_QUARTERS", _TL("Create Output of Quarter Cell Grids"), _TL("")); Parameters.Add_Value( pNode , "B_SLOPE" , _TL("Slope"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Grid_Output( NULL , "G_SLOPE" , _TL("Slope") , _TL("") ); Parameters.Add_Value( pNode , "B_ASPECT", _TL("Aspect"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Grid_Output( NULL , "G_ASPECT", _TL("Aspect") , _TL("") ); Parameters.Add_Value( pNode , "B_AREA" , _TL("Flow Accumulation"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Grid_Output( NULL , "G_AREA" , _TL("Flow Accumulation") , _TL("") ); Parameters.Add_Value( pNode , "B_FLOW" , _TL("Flow Lines"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Shapes_Output( NULL , "G_FLOW" , _TL("Flow Lines") , _TL("") ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_MassFlux::On_Execute(void) { int x, y, i, ix, iy; CSG_Grid *pArea; //----------------------------------------------------- m_pDEM = Parameters("DEM") ->asGrid(); pArea = Parameters("AREA") ->asGrid(); m_Method = Parameters("METHOD") ->asInt(); //----------------------------------------------------- if( 1 ) { CSG_Grid_System System(0.5 * Get_Cellsize(), Get_XMin() - 0.25 * Get_Cellsize(), Get_YMin() - 0.25 * Get_Cellsize(), 2 * Get_NX(), 2 * Get_NY()); m_Area .Create(System, SG_DATATYPE_Float); m_dir .Create(System, SG_DATATYPE_Byte); m_dif .Create(System, SG_DATATYPE_Float); m_dir .Assign(-1.0); m_Area .Assign( 0.0); m_Area .Set_NoData_Value(0.0); Parameters("G_SLOPE" )->Set_Value(m_pSlope = !Parameters("B_SLOPE" )->asBool() ? NULL : SG_Create_Grid(System, SG_DATATYPE_Float)); Parameters("G_ASPECT")->Set_Value(m_pAspect = !Parameters("B_ASPECT")->asBool() ? NULL : SG_Create_Grid(System, SG_DATATYPE_Float)); Parameters("G_FLOW" )->Set_Value(m_pFlow = !Parameters("B_FLOW" )->asBool() ? NULL : SG_Create_Shapes(SHAPE_TYPE_Line, _TL("Flow Lines"))); //------------------------------------------------- // Calculate flow portions... for(y=0; y 0.0 ) { Area += d; } } if( Area > 0.0 ) { pArea->Set_Value(x, y, Area * m_Area.Get_Cellarea()); } else { pArea->Set_NoData(x, y); } } } //------------------------------------------------- if( Parameters("B_AREA")->asBool() ) { Parameters("G_AREA")->Set_Value(SG_Create_Grid(m_Area)); } m_Area .Destroy(); m_dif .Destroy(); m_dir .Destroy(); DataObject_Set_Colors(pArea, 100, SG_COLORS_WHITE_BLUE); return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_MassFlux::Set_Flow(int x, int y, int Direction) { int dir, ix, iy, jx, jy; double dif, Z, A, B; if( m_pDEM->is_InGrid(x, y) && m_pDEM->is_InGrid(ix = Get_xTo(2 * Direction , x), iy = Get_yTo(2 * Direction , y)) && m_pDEM->is_InGrid(jx = Get_xTo(2 * Direction + 2, x), jy = Get_yTo(2 * Direction + 2, y)) ) { Z = m_pDEM->asDouble( x, y); A = (m_pDEM->asDouble(ix, iy) - Z) / Get_Cellsize(); B = (m_pDEM->asDouble(jx, jy) - Z) / Get_Cellsize(); dif = A != 0.0 ? M_PI_180 + atan2(B, A) : (B > 0.0 ? M_PI_270 : (B < 0.0 ? M_PI_090 : -1.0)); if( dif >= 0.0 ) { x = 2 * x + xDir[Direction]; y = 2 * y + yDir[Direction]; dif = fmod(dif + M_PI_090 * Direction, M_PI_360); if( m_pFlow ) { double dScale = 0.50 * m_dir.Get_System().Get_Cellsize(); TSG_Point Point = m_dir.Get_System().Get_Grid_to_World(x, y); CSG_Shape *pLine = m_pFlow->Add_Shape(); pLine->Add_Point( Point.x - dScale * sin(dif), Point.y - dScale * cos(dif), 0 ); pLine->Add_Point(Point, 0); dScale = 0.20 * m_dir.Get_System().Get_Cellsize(); pLine->Add_Point( Point.x - dScale * sin(dif + 25.0 * M_DEG_TO_RAD), Point.y - dScale * cos(dif + 25.0 * M_DEG_TO_RAD), 1 ); pLine->Add_Point(Point, 1); pLine->Add_Point( Point.x - dScale * sin(dif - 25.0 * M_DEG_TO_RAD), Point.y - dScale * cos(dif - 25.0 * M_DEG_TO_RAD), 1 ); } if( m_pSlope ) m_pSlope ->Set_Value(x, y, atan(sqrt(A*A + B*B))); if( m_pAspect ) m_pAspect->Set_Value(x, y, dif); dir = (int)(dif / M_PI_090); dif = dif - dir * M_PI_090; switch( m_Method ) { case 0: dif = cos(dif) / (cos(dif) + sin(dif)); break; case 1: dif = dif < M_PI_045 ? 1.0 - tan(dif) / 2.0 : tan(M_PI_090 - dif) / 2.0; break; } m_dir.Set_Value(x, y, dir * 2); m_dif.Set_Value(x, y, dif); return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CFlow_MassFlux::Get_Flow(int x, int y, int Direction) { if( m_dir.is_InGrid(x, y) ) { int i = m_dir.asInt(x, y); if( Direction == i ) { return( m_dif.asDouble(x, y) ); } if( Direction == (i + 2) % 8 ) { return( 1.0 - m_dif.asDouble(x, y) ); } } return( 0.0 ); } //--------------------------------------------------------- double CFlow_MassFlux::Get_Area(int x, int y) { if( m_Area.is_NoData(x, y) ) // cell has not been processed yet... { int i, ix, iy; double d; m_Area.Set_Value(x, y, 1.0); // add this cell's contribution... for(i=0; i<8; i+=2) { ix = Get_xFrom(i, x); iy = Get_yFrom(i, y); d = Get_Flow(ix, iy, i); if( d > 0.0 ) // which portion drains ith neigbour into this cell??? { m_Area.Add_Value(x, y, d * Get_Area(ix, iy)); // then recursive call of this function... } } } return( m_Area.asDouble(x, y) ); // return this cell's area... } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/melton_ruggedness.cpp0000664000175000017500000001565212565125415030350 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: melton_ruggedness.cpp 1091 2011-06-16 15:50:52Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // melton_ruggedness.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "melton_ruggedness.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMelton_Ruggedness::CMelton_Ruggedness(void) { Set_Name (_TL("Melton Ruggedness Number")); Set_Author (SG_T("O. Conrad (c) 2012")); Set_Description (_TW( "Melton ruggedness number (MNR) is a simple flow accumulation related index, " "calculated as difference between maximum and minimum elevation " "in catchment area divided by square root of catchment area size. " "The calculation is performed for each grid cell, therefore minimum elevation " "is same as elevation at cell's position. " "Due to the discrete character of a single maximum elevation, flow calculation " "is simply done with Deterministic 8. " "\n\n" "References:\n" "Marchi, L. & Fontana, G.D. (2005): " "GIS morphometric indicators for the analysis of sediment dynamics in mountain basins. " "Environ. Geol. 48:218-228, DOI 10.1007/s00254-005-1292-4.\n" "\n" "Melton M.A. (1965): " "The geomorphic and paleoclimatic significance of alluvial deposits in Southern Arizona. " "J. Geol. 73:1-38.\n" "\n" "O'Callaghan, J.F. / Mark, D.M. (1984): " "The extraction of drainage networks from digital elevation data. " "Computer Vision, Graphics and Image Processing 28:323-344.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "AREA" , _TL("Catchment Area"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "ZMAX" , _TL("Maximum Height"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "MRN" , _TL("Melton Ruggedness Number"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMelton_Ruggedness::On_Execute(void) { CSG_Grid *pDEM, *pArea, *pMRN, *pZMax; //----------------------------------------------------- pDEM = Parameters("DEM" )->asGrid(); pArea = Parameters("AREA")->asGrid(); pZMax = Parameters("ZMAX")->asGrid(); pMRN = Parameters("MRN" )->asGrid(); if( !pDEM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } pArea->Set_NoData_Value(0.0); pArea->Assign_NoData(); pZMax->Assign_NoData(); pMRN ->Assign_NoData(); //------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y, true, true) ) { pArea->Add_Value(x, y, Get_Cellsize()); if( pZMax->is_NoData(x, y) ) { pZMax->Set_Value(x, y, pDEM->asDouble(x, y)); } if( (i = pDEM->Get_Gradient_NeighborDir(x, y, true)) >= 0 && Get_System()->Get_Neighbor_Pos(i, x, y, ix, iy) ) { pArea->Add_Value(ix, iy, pArea->asDouble(x, y)); if( pZMax->is_NoData(ix, iy) || pZMax->asDouble(ix, iy) < pZMax->asDouble(x, y) ) { pZMax->Set_Value(ix, iy, pZMax->asDouble(x, y)); } } pMRN->Set_Value(x, y, (pZMax->asDouble(x, y) - pDEM->asDouble(x, y)) / sqrt(pArea->asDouble(x, y))); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/SlopeLength.h0000664000175000017500000000476312565125415026516 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SlopeLength.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /******************************************************************************* SlopeLength.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSlopeLength : public CSG_Module_Grid { public: CSlopeLength(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Miscellaneous") ); } protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pLength, m_Slope; void Get_Length (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/EdgeContamination.cpp0000664000175000017500000001637312565125415030215 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: EdgeContamination.cpp 1016 2011-04-27 18:40:36Z oconrad $ *********************************************************/ /******************************************************************************* EdgeContamination.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "EdgeContamination.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define NOT_VISITED -1 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CEdgeContamination::CEdgeContamination(void) { Set_Name (_TL("Edge Contamination")); Set_Author ("V.Olaya (c) 2004"); Set_Description (_TW( "This tool uses flow directions to estimate possible contamination " "effects moving from outside of the grid passing the edge into its interior. " "This means that derived contributing area values might be underestimated " "for the marked cells. Cells not contamined will be marked as no data. " )); Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CONTAMINATION" , _TL("Edge Contamination"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Char ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("single flow direction"), _TL("multiple flow direction") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { EFFECT_NO = -1, EFFECT_NODATA = 0, EFFECT_EDGE = 1, EFFECT_YES = 2, }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CEdgeContamination::On_Execute(void) { //----------------------------------------------------- m_pDEM = Parameters("ELEVATION" )->asGrid(); m_pEffect = Parameters("CONTAMINATION")->asGrid(); int Method = Parameters("METHOD")->asInt(); m_pEffect->Assign(0.0); m_pEffect->Set_NoData_Value_Range(EFFECT_NO, EFFECT_NODATA); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { bool bEdge = false; for(int i=0; i<8 && !bEdge; i++) { if( !m_pDEM->is_InGrid(Get_xTo(i, x), Get_yTo(i, y)) ) { bEdge = true; } } if( bEdge ) { switch( Method ) { default: Set_D8 (x, y); break; case 1: Set_MFD (x, y); break; } } else if( m_pEffect->asInt(x, y) == EFFECT_NODATA ) { m_pEffect->Set_Value(x, y, EFFECT_NO); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CEdgeContamination::Get_D8(int x, int y) { int iMax = -1; if( m_pDEM->is_InGrid(x, y) ) { double z = m_pDEM->asDouble(x, y); double dzMax = 0.0; for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) ) { double dz = (z - m_pDEM->asDouble(ix, iy)) / Get_Length(i); if( dz > dzMax ) { iMax = i; dzMax = dz; } } } } return( iMax ); } //--------------------------------------------------------- int CEdgeContamination::Set_D8(int x, int y) { m_pEffect->Set_Value(x, y, EFFECT_EDGE); int i, nContaminated = 1; //----------------------------------------------------- while( (i = Get_D8(x, y)) >= 0 && m_pDEM->is_InGrid(x = Get_xTo(i, x), y = Get_yTo(i, y)) && m_pEffect->asInt(x, y) <= EFFECT_NODATA ) { m_pEffect->Set_Value(x, y, EFFECT_YES); nContaminated++; } //----------------------------------------------------- return( nContaminated ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CEdgeContamination::Get_MFD(int x, int y, double dz[8]) { if( m_pDEM->is_InGrid(x, y) ) { int i; double z, d, dzSum; for(i=0, dzSum=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && (d = (z - m_pDEM->asDouble(ix, iy)) / Get_Length(i)) > 0.0 ) { dzSum += (dz[i] = d); } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { for(i=0; i<8; i++) { if( dz[i] > 0.0 ) { dz[i] /= dzSum; } } return( true ); } } return( false ); } //--------------------------------------------------------- int CEdgeContamination::Set_MFD(int x, int y) { m_pEffect->Set_Value(x, y, EFFECT_EDGE); CSG_Grid_Stack Stack; Stack.Push(x, y); double dz[8]; //----------------------------------------------------- while( Stack.Get_Size() > 0 && Process_Get_Okay() ) { Stack.Pop(x, y); if( Get_MFD(x, y, dz) ) { for(int i=0; i<8; i++) { if( dz[i] > 0.0 ) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pEffect->asInt(ix, iy) <= EFFECT_NODATA ) { m_pEffect->Set_Value(ix, iy, EFFECT_YES); Stack.Push(ix, iy); } } } } } //----------------------------------------------------- return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow.h0000664000175000017500000001357212565125415025177 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Flow_H #define HEADER_INCLUDED__Flow_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { flow_D8 = 0, flow_Rho8, flow_DInf, flow_MFD, flow_BRM, flow_KRA, flow_DEMON }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_hydrology_EXPORT CFlow : public CSG_Module_Grid { public: CFlow(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Flow Accumulation" )); } void Set_Point (int x, int y); protected: bool m_bGT_Zero; int m_Step; double m_Converge; CSG_Grid *m_pDTM, *m_pRoute, *m_pWeight, *m_pCatch, *m_pFlowPath, *m_pVal_Input, *m_pVal_Mean, *m_pMaterial, *m_pTarget, *m_pAccu_Tot, *m_pAccu_Left, *m_pAccu_Right; virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); virtual void On_Initialize (void) = 0; virtual void On_Finalize (void) {} virtual bool Calculate (void) = 0; virtual bool Calculate (int x, int y) = 0; void Init_Cell (int x, int y); void Get_Gradient (int x, int y, double &Slope, double &Aspect); void Add_Fraction (int x, int y, int Direction, double Fraction = 1.0); void Add_Portion (int x, int y, int ix, int iy, int Direction); void Find_Sides (int x, int y, int Direction, bool &left, bool &right); private: bool m_bPoint, m_bKill_Material; int m_xPoint, m_yPoint; void _Finalize (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Flow_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_AreaUpslope.cpp0000664000175000017500000004031212565125415030022 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_AreaUpslope.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_AreaUpslope.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow_AreaUpslope.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_AreaUpslope::CFlow_AreaUpslope(void) { m_pDTM = NULL; m_pRoute = NULL; m_pFlow = NULL; } //--------------------------------------------------------- CFlow_AreaUpslope::~CFlow_AreaUpslope(void) { Finalise(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CFlow_AreaUpslope::Get_Description(void) { return( _TW( "This module allows you to specify target cells, " "for which the upslope contributing area shall be identified. " "The result will give " "for each cell the percentage of its flow that reaches the target cell(s).\n\n" "References:\n\n" "Deterministic 8\n" "- O'Callaghan, J.F. / Mark, D.M. (1984):\n" " 'The extraction of drainage networks from digital elevation data',\n" " Computer Vision, Graphics and Image Processing, 28:323-344\n\n" "Deterministic Infinity:\n" "- Tarboton, D.G. (1997):\n" " 'A new method for the determination of flow directions and upslope areas in grid digital elevation models',\n" " Water Resources Research, Vol.33, No.2, p.309-319\n\n" "Multiple Flow Direction:\n" "- Freeman, G.T. (1991):\n" " 'Calculating catchment area with divergent flow based on a regular grid',\n" " Computers and Geosciences, 17:413-22\n\n" "- Quinn, P.F. / Beven, K.J. / Chevallier, P. / Planchon, O. (1991):\n" " 'The prediction of hillslope flow paths for distributed hydrological modelling using digital terrain models',\n" " Hydrological Processes, 5:59-79\n\n" ) ); } //--------------------------------------------------------- CSG_String CFlow_AreaUpslope::Get_Methods(void) { return( CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Deterministic 8"), _TL("Deterministic Infinity"), _TL("Multiple Flow Direction") )); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_AreaUpslope::Initialise(int Method, CSG_Grid *pDTM, CSG_Grid *pRoute, CSG_Grid *pFlow, double MFD_Converge) { Finalise(); if( pDTM && pDTM->is_Valid() && pFlow && pFlow->is_Valid() && pFlow->Get_System() == pDTM->Get_System() ) { m_Method = Method; m_pDTM = pDTM; m_pFlow = pFlow; m_MFD_Converge = MFD_Converge; if( pRoute && pRoute->is_Valid() && pRoute->Get_System() == pDTM->Get_System() ) { m_pRoute = pRoute; } return( true ); } return( false ); } //--------------------------------------------------------- bool CFlow_AreaUpslope::Finalise(void) { m_pDTM = NULL; m_pRoute = NULL; m_pFlow = NULL; return( true ); } //--------------------------------------------------------- bool CFlow_AreaUpslope::Add_Target(int x, int y) { if( m_pFlow && m_pFlow->is_InGrid(x, y, false) ) { m_pFlow->Set_Value(x, y, 100.0); return( true ); } return( false ); } //--------------------------------------------------------- bool CFlow_AreaUpslope::Clr_Target(void) { if( m_pFlow ) { m_pFlow->Assign(0.0); return( true ); } return( false ); } //--------------------------------------------------------- bool CFlow_AreaUpslope::Get_Area(int x, int y) { return( Clr_Target() && Add_Target(x, y) && Get_Area() ); } //--------------------------------------------------------- bool CFlow_AreaUpslope::Get_Area(void) { if( !m_pDTM || !m_pFlow || !m_pDTM->Set_Index() ) { return( false ); } sLong i; int x, y; for(i=0; iGet_NCells() && SG_UI_Process_Set_Progress((double)i, (double)m_pDTM->Get_NCells()); i++) { if( m_pDTM->Get_Sorted(i, x, y, false) && m_pFlow->asDouble(x, y) > 0.0 ) { break; } } for(i++; iGet_NCells() && SG_UI_Process_Set_Progress((double)i, (double)m_pDTM->Get_NCells()); i++) { if( m_pDTM->Get_Sorted(i, x, y, false) && m_pFlow->asDouble(x, y) <= 0.0 ) { Set_Value(x, y); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CFlow_AreaUpslope::Set_Value(int x, int y) { int i; if( m_pRoute && (i = m_pRoute->asChar(x, y)) >= 0 ) { int ix, iy; double Flow; ix = m_pDTM->Get_System().Get_xTo(i, x); iy = m_pDTM->Get_System().Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy, true) && (Flow = m_pFlow->asDouble(ix, iy)) > 0.0 ) { m_pFlow->Set_Value(x, y, Flow); } } else if( !m_pDTM->is_NoData(x, y) ) { switch( m_Method ) { case 0: Set_D8 (x, y); break; case 1: Set_DInf (x, y); break; case 2: Set_MFD (x, y); break; } } } //--------------------------------------------------------- void CFlow_AreaUpslope::Set_D8(int x, int y) { int i; if( (i = m_pDTM->Get_Gradient_NeighborDir(x, y, true)) >= 0 ) { int ix, iy; double Flow; ix = m_pDTM->Get_System().Get_xTo(i, x); iy = m_pDTM->Get_System().Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy, true) && (Flow = m_pFlow->asDouble(ix, iy)) > 0.0 ) { m_pFlow->Set_Value(x, y, Flow); } } } //--------------------------------------------------------- void CFlow_AreaUpslope::Set_DInf(int x, int y) { double Slope, Aspect; if( m_pDTM->Get_Gradient(x, y, Slope, Aspect) ) // && Aspect >= 0.0 ) { int i, ix, iy, jx, jy; double Flow; i = (int)(Aspect / M_PI_045); ix = m_pDTM->Get_System().Get_xTo(i, x); iy = m_pDTM->Get_System().Get_yTo(i, y); i++; jx = m_pDTM->Get_System().Get_xTo(i, x); jy = m_pDTM->Get_System().Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy) && m_pDTM->asDouble(ix, iy) < m_pDTM->asDouble(x, y) && m_pDTM->is_InGrid(jx, jy) && m_pDTM->asDouble(jx, jy) < m_pDTM->asDouble(x, y) ) { Aspect = fmod(Aspect, M_PI_045) / M_PI_045; Flow = m_pFlow->asDouble(ix, iy) * (1.0 - Aspect) + m_pFlow->asDouble(jx, jy) * ( Aspect); if( Flow > 0.0 ) { m_pFlow->Set_Value(x, y, Flow); } return; } } Set_D8(x, y); } //--------------------------------------------------------- void CFlow_AreaUpslope::Set_MFD(int x, int y) { int i, ix, iy; double z, d, f, dzSum, dz[8]; for(i=0, dzSum=0.0, z=m_pDTM->asDouble(x, y); i<8; i++) { dz[i] = 0.0; ix = m_pDTM->Get_System().Get_xTo(i, x); iy = m_pDTM->Get_System().Get_yTo(i, y); if( m_pDTM->is_InGrid(ix, iy) && (d = z - m_pDTM->asDouble(ix, iy)) > 0.0 ) { dzSum += (d = pow(d / m_pDTM->Get_System().Get_Length(i), m_MFD_Converge)); if( (f = m_pFlow->asDouble(ix, iy)) > 0.0 ) { dz[i] = d * f; } } } if( dzSum > 0.0 ) { for(i=0, d=0.0; i<8; i++) { if( dz[i] > 0.0 ) { d += dz[i] / dzSum; } } m_pFlow->Set_Value(x, y, d); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_AreaUpslope_Interactive::CFlow_AreaUpslope_Interactive(void) { Set_Name (_TL("Upslope Area")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (CSG_String::Format(SG_T("%s_______\n%s"), m_Calculator.Get_Description().c_str(), _TL("Interactive version (left mouse clicks will trigger the calculation for the selected cell).") )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SINKROUTE" , _TL("Sink Routes"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "AREA" , _TL("Upslope Area"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), m_Calculator.Get_Methods(), 2 ); Parameters.Add_Value( NULL , "CONVERGE" , _TL("Convergence"), _TL("Convergence factor for Multiple Flow Direction algorithm"), PARAMETER_TYPE_Double , 1.1, 0.001, true ); } //--------------------------------------------------------- CFlow_AreaUpslope_Interactive::~CFlow_AreaUpslope_Interactive(void) {} //--------------------------------------------------------- bool CFlow_AreaUpslope_Interactive::On_Execute(void) { if( m_Calculator.Initialise( Parameters("METHOD") ->asInt(), Parameters("ELEVATION") ->asGrid(), Parameters("SINKROUTE") ->asGrid(), Parameters("AREA") ->asGrid(), Parameters("CONVERGE") ->asDouble() ) ) { DataObject_Set_Colors(Parameters("AREA")->asGrid(), 100, SG_COLORS_WHITE_BLUE); return( true ); } return( false ); } //--------------------------------------------------------- bool CFlow_AreaUpslope_Interactive::On_Execute_Finish(void) { return( m_Calculator.Finalise() ); } //--------------------------------------------------------- bool CFlow_AreaUpslope_Interactive::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { if( Mode == MODULE_INTERACTIVE_LDOWN && m_Calculator.Get_Area(Get_xGrid(), Get_yGrid()) ) { DataObject_Update(Parameters("AREA")->asGrid(), 0.0, 100.0, true); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_AreaUpslope_Area::CFlow_AreaUpslope_Area(void) { Set_Name (_TL("Upslope Area")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (CSG_String::Format(SG_T("%s_______\n\n%s"), m_Calculator.Get_Description().c_str(), _TW("This version uses all valid cells (not \'no data\' values) of a given target grid to determine the contributing area. " "In case no target grid is provided as input, the specified x/y coordinates are used as target point.") )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "TARGET" , _TL("Target Area"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( NULL , "TARGET_PT_X" , _TL("Target X coordinate"), _TL("The x-coordinate of the target point in world coordinates [map units]"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( NULL , "TARGET_PT_Y" , _TL("Target Y coordinate"), _TL("The y-coordinate of the target point in world coordinates [map units]"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SINKROUTE" , _TL("Sink Routes"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "AREA" , _TL("Upslope Area"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), m_Calculator.Get_Methods(), 2 ); Parameters.Add_Value( NULL , "CONVERGE" , _TL("Convergence"), _TL("Convergence factor for Multiple Flow Direction algorithm"), PARAMETER_TYPE_Double , 1.1, 0.001, true ); } //--------------------------------------------------------- CFlow_AreaUpslope_Area::~CFlow_AreaUpslope_Area(void) {} //--------------------------------------------------------- bool CFlow_AreaUpslope_Area::On_Execute(void) { bool bResult = false; //----------------------------------------------------- if( m_Calculator.Initialise( Parameters("METHOD") ->asInt(), Parameters("ELEVATION") ->asGrid(), Parameters("SINKROUTE") ->asGrid(), Parameters("AREA") ->asGrid(), Parameters("CONVERGE") ->asDouble() ) ) { if( m_Calculator.Clr_Target() ) { int x, y; CSG_Grid *pTarget = Parameters("TARGET")->asGrid(); if( pTarget != NULL ) { for(y=0; yis_NoData(x, y) && m_Calculator.Add_Target(x, y) ) { bResult = true; } } } } else { Parameters("ELEVATION")->asGrid()->Get_System().Get_World_to_Grid(x, y, Parameters("TARGET_PT_X")->asDouble(), Parameters("TARGET_PT_Y")->asDouble()); if( m_Calculator.Add_Target(x, y) ) { bResult = true; } else { SG_UI_Msg_Add_Error(_TL("Coordinates of target point outside of DEM!")); } } if( bResult ) { m_Calculator.Get_Area(); DataObject_Set_Colors(Parameters("AREA")->asGrid(), 100, SG_COLORS_WHITE_BLUE); } } } //----------------------------------------------------- m_Calculator.Finalise(); return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_RecursiveUp.h0000664000175000017500000001151012565125415027521 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_RecursiveUp.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_RecursiveUp.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Flow_RecursiveUp_H #define HEADER_INCLUDED__Flow_RecursiveUp_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_hydrology_EXPORT CFlow_RecursiveUp : public CFlow { public: CFlow_RecursiveUp(void); protected: virtual void On_Initialize (void); virtual bool Calculate (void); virtual bool Calculate (int x, int y); private: double ***m_Flow; void On_Create (void); void On_Destroy (void); void Get_Flow (int x, int y ); void Set_D8 (int x, int y ); void Set_Rho8 (int x, int y ); void Set_DInf (int x, int y ); void Set_MFD (int x, int y ); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Flow_RecursiveUp_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/SAGA_Wetness_Index.cpp0000664000175000017500000006252712565125415030201 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SAGA_Wetness_Index.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // SAGA_Wetness_Index.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SAGA_Wetness_Index.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSAGA_Wetness_Index::CSAGA_Wetness_Index(void) { //----------------------------------------------------- Set_Name (_TL("SAGA Wetness Index")); Set_Author (SG_T("(c) 2001 by J.Boehner, O.Conrad")); Set_Description (_TW( "The 'SAGA Wetness Index' is, as the name says, similar to the " "'Topographic Wetness Index' (TWI), but it is based on a modified " "catchment area calculation ('Modified Catchment Area'), which does " "not think of the flow as very thin film. As result it predicts for " "cells situated in valley floors with a small vertical distance to " "a channel a more realistic, higher potential soil moisture compared " "to the standard TWI calculation.\n\n" "References\n" "- Boehner, J., Koethe, R. Conrad, O., Gross, J., Ringeler, A., Selige, T. (2002): " "Soil Regionalisation by Means of Terrain Analysis and Process Parameterisation. " "In: Micheli, E., Nachtergaele, F., Montanarella, L. [Ed.]: Soil Classification 2001. " "European Soil Bureau, Research Report No. 7, EUR 20398 EN, Luxembourg. pp.213-222.\n\n" "- Boehner, J. and Selige, T. (2006): Spatial prediction of soil attributes using " "terrain analysis and climate regionalisation. In: Boehner, J., McCloy, K.R., Strobl, J. " "[Ed.]: SAGA - Analysis and Modelling Applications, Goettinger Geographische Abhandlungen, " "Goettingen: 13-28. " "(pdf)\n\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "WEIGHT" , _TL("Weights"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "AREA" , _TL("Catchment area"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "SLOPE" , _TL("Catchment slope"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "AREA_MOD" , _TL("Modified Catchment Area"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "TWI" , _TL("Topographic Wetness Index"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "SUCTION" , _TL("Suction"), _TL("the lower this value is the stronger is the suction effect"), PARAMETER_TYPE_Double , 10.0, 0.0, true ); CSG_Parameter *pNode = Parameters.Add_Node( NULL , "TWI_NODE" , _TL("Topograpic Wetness Index Calculation"), _TL("") ); Parameters.Add_Choice( pNode , "AREA_TYPE" , _TL("Type of Area"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("absolute catchment area"), _TL("square root of catchment area"), _TL("specific catchment area") ), 1 ); Parameters.Add_Choice( pNode , "SLOPE_TYPE" , _TL("Type of Slope"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("local slope"), _TL("catchment slope") ), 1 ); Parameters.Add_Value( NULL , "SLOPE_MIN" , _TL("Minimum Slope"), _TL(""), PARAMETER_TYPE_Double , 0.0, 0.0, true ); Parameters.Add_Value( NULL , "SLOPE_OFF" , _TL("Offset Slope"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( NULL , "SLOPE_WEIGHT", _TL("Slope Weighting"), _TL("weighting factor for slope in index calculation"), PARAMETER_TYPE_Double , 1.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSAGA_Wetness_Index::On_Execute(void) { //----------------------------------------------------- m_pDEM = Parameters("DEM" )->asGrid(); m_pSlope = Parameters("SLOPE" )->asGrid(); m_pArea = Parameters("AREA" )->asGrid(); m_pAreaMod = Parameters("AREA_MOD")->asGrid(); m_pTWI = Parameters("TWI" )->asGrid(); DataObject_Set_Colors(m_pArea , 100, SG_COLORS_WHITE_BLUE); DataObject_Set_Colors(m_pAreaMod, 100, SG_COLORS_WHITE_BLUE); DataObject_Set_Colors(m_pSlope , 100, SG_COLORS_YELLOW_RED); DataObject_Set_Colors(m_pTWI , 100, SG_COLORS_RED_GREY_BLUE); m_pSlope->Set_Unit (_TL("radians")); if( !m_pDEM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } //----------------------------------------------------- Get_Area(); Get_Modified(); Get_TWI(); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CSAGA_Wetness_Index::Get_Local_Maximum(CSG_Grid *pGrid, int x, int y) { double z = pGrid->asDouble(x, y); for(int i=0, ix, iy; i<8; i++) { if( pGrid->Get_System().Get_Neighbor_Pos(i, x, y, ix, iy) && !pGrid->is_NoData(ix, iy) && pGrid->asDouble(ix, iy) > z ) { z = pGrid->asDouble(ix, iy); } } return( z ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // Im Unterschied zu Freeman's urspruenglichen Verfahren // wird der Winkel (atan(dz / dx)) und nicht das Gefaelle // (dz / dx) fuer die Gewichtung der Abfluszanteile benutzt! //--------------------------------------------------------- bool CSAGA_Wetness_Index::Get_Area(void) { const double MFD_Converge = 1.1; int x, y, i, ix, iy; double z, d, dz[8], dzSum, Area, Slope; CSG_Grid *pWeight = Parameters("WEIGHT")->asGrid(); //----------------------------------------------------- Process_Set_Text(_TL("catchment area and slope...")); m_pArea ->Assign(0.0); m_pSlope->Assign(0.0); m_Suction.Create(*Get_System()); m_Suction.Assign(0.0); double Suction = Parameters("SUCTION" )->asDouble(); double Slope_Weight = Parameters("SLOPE_WEIGHT")->asDouble(); //----------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y, true, false); if( m_pDEM->is_NoData(x, y) ) { m_pArea ->Set_NoData(x, y); m_pSlope->Set_NoData(x, y); m_Suction.Set_NoData(x, y); } else { m_pDEM->Get_Gradient(x, y, Slope, d); d = pow(Suction, Slope_Weight * Slope); m_Suction.Set_Value(x, y, pow(1.0 / d, exp(d))); Area = m_pArea ->asDouble(x, y) + (!pWeight ? 1.0 : pWeight->is_NoData(x, y) ? 0.0 : pWeight->asDouble(x, y)); Slope = m_pSlope->asDouble(x, y) + Slope; m_pArea ->Set_Value(x, y, Area); m_pSlope->Set_Value(x, y, Slope / Area); for(i=0, dzSum=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { if( Get_System()->Get_Neighbor_Pos(i, x, y, ix, iy) && !m_pDEM->is_NoData(ix, iy) && (d = z - m_pDEM->asDouble(ix, iy)) > 0.0 ) { dzSum += (dz[i] = pow(atan(d / Get_Length(i)), MFD_Converge)); } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { for(i=0; i<8; i++) { if( dz[i] > 0.0 ) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); d = dz[i] / dzSum; m_pArea ->Add_Value(ix, iy, d * Area); m_pSlope->Add_Value(ix, iy, d * Slope); } } } } } //----------------------------------------------------- *m_pArea *= m_pArea->Get_Cellarea(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // in den folgenden drei Schritten wird die gesaugte // Einzugsgebietsgroeße CS ermittelt, wobei der t-Parameter // die Staerke der Saugung steuert. Werte unter 10 (z.B. 5) // fuehren zu einer starken Saugung, Werte ueber 10 (z.B. 15) // zu einer schwachen Saugung. Die gesaugte // Einzugsgebietsgroeße selbst stellt bereits einen Parameter // dar, der die raeumliche Relief-bedingte Feuchteverteilung // in guter Weise annaehert //--------------------------------------------------------- bool CSAGA_Wetness_Index::Get_Modified(void) { int y; CSG_Grid Area(*m_pArea); m_pAreaMod->Assign(m_pArea); //----------------------------------------------------- int nChanges = 1; for(int Iteration=1; nChanges && Process_Get_Okay(); Iteration++) { nChanges = 0; #pragma omp parallel for private(y) reduction(+:nChanges) for(y=0; y Area.asDouble(x, y) ) { nChanges++; Area.Set_Value(x, y, z); } } } } if( nChanges > 0 ) { nChanges = 0; #pragma omp parallel for private(y) for(y=0; yasDouble(x, y) ) { nChanges++; m_pAreaMod->Set_Value(x, y, Area.asDouble(x, y)); } } } } Process_Set_Text(CSG_String::Format(SG_T("pass %d (%d > 0)"), Iteration, nChanges)); } //----------------------------------------------------- Process_Set_Text(_TL("post-processing...")); #pragma omp parallel for private(y) for(y=0; y m_pArea->asDouble(ix, iy) ) { bModify = true; } n ++; z += Area.asDouble(ix, iy); } } } m_pAreaMod->Set_Value(x, y, bModify ? z / n : Area.asDouble(x, y)); } else { m_pAreaMod->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSAGA_Wetness_Index::Get_TWI(void) { int Area_Type = Parameters("AREA_TYPE" )->asInt(); int Slope_Type = Parameters("SLOPE_TYPE")->asInt(); double Slope_Min = Parameters("SLOPE_MIN" )->asDouble() * M_DEG_TO_RAD; double Slope_Off = Parameters("SLOPE_OFF" )->asDouble() * M_DEG_TO_RAD; Process_Set_Text(_TL("topographic wetness index...")); #pragma omp parallel for(int y=0; yis_NoData(x, y) || m_pSlope->is_NoData(x, y) ) { m_pTWI->Set_NoData(x, y); } else { double s, a; if( Slope_Type == 1 ) { s = m_pSlope->asDouble(x, y); } else { m_pDEM->Get_Gradient(x, y, s, a); } s = s + Slope_Off; s = 6 * tan(Slope_Min < s ? s : Slope_Min); a = m_pAreaMod->asDouble(x, y); switch( Area_Type ) { case 1: a = sqrt(a); break; // square root of catchment area case 2: a = a / Get_Cellsize(); break; // specific catchment area } m_pTWI->Set_Value(x, y, log(a / s)); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // The original BSL script by J.Boehner //--------------------------------------------------------- /* Matrix Loop, O("sch-hoe.grd"), N("sch-nei.grd"), M, R, UL, LL, OL, OO, OR, RR, UR, UU, X, Y, Z, C, CS, SB; Point ploop, p, pul, pu, pur, pl, pr, pol, po, por; Float a, wul, wll, wol, woo, wor, wrr, wur, wuu; Integer t, h, i, j, gefunden; a = 0.0174532; t = 10; pul.x = -1; pul.y = -1; pu.x = 0; pu.y = -1; pur.x = 1; pur.y = -1; pl.x = -1; pl.y = 0; pr.x = 1; pr.y = 0; pol.x = -1; pol.y = 1; po.x = 0; po.y = 1; por.x = 1; por.y = 1; M = O; R = O; UL = O; LL = O; OL = O; OO = O; OR = O; RR = O; UR = O; UU = O; X = O; Y = O; Z = O; C = O; CS = O; SB = O; Loop.xanz = 100000; Loop.yanz = 1; h = 0; i = 0; j = 0; // hier wird eine Hilfsmatrix X erzeugt, die in der folgenden Schleife fafuer sorgt, dass noch nicht attributisierte Rasterzellen in Ihrer Position identifiziert werden koennen // foreach p in X do { if (p.x == 0 || p.x == M.xanz - 1 || p.y == 0 || p.y == M.yanz - 1) {X[p] = -10000;} else {X[p] = M[p];} } // hier wird eine Matrix R erzeugt, die ausgehend von lokalen Maxima fortlaufend Rangplatzziffernerzeugt // foreach ploop in Loop do { ploop.x = 1; h = h +1; gefunden = 0; foreach p in X do { if (X[p] == max9(p, X) && X[p] > -10000) {X[p] = -10000; R[p] = h; gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } setRandN(R); // hier wird eine Hilfsmatrix R erzeugt, die Rangplatzziffern am Rand duch 0 ersetzt // foreach p in R do { if (p.x == 0 || p.x == M.xanz - 1 || p.y == 0 || p.y == M.yanz - 1) {R[p] = 0;} else {R[p] = R[p];} } // hier wird eine Matrix Z erzeugt, die die positiven Winkel zu den 8 Nachbarzellen aufsummiert // foreach p in Z do { if(p.x == 0 && p.y == 0) { if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((woo + wor + wrr) == 0) {Z[p] = 0;} else {Z[p] = woo + wor + wrr;} } else { if(p.x == 0 && p.y == (M.yanz - 1)) { if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = wrr + wur + wuu;} } else { if(p.x == M.xanz - 1 && p.y == M.yanz - 1) { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wuu;} } else { if(p.x == M.xanz - 1 && p.y == 0) { if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((wll + wol + woo) == 0) {Z[p] = 0;} else {Z[p] = wll + wol + woo;} } else { if(p.x == 0) { if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((woo + wor + wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = woo + wor + wrr + wur + wuu;} } else { if(p.x == M.xanz - 1) { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wol + woo + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wol + woo + wuu;} } else { if(p.y == 0) { if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((wll + wol + woo + wor + wrr) == 0) {Z[p] = 0;} else {Z[p] = wll + wol + woo + wor + wrr;} } else { if(p.y == M.yanz - 1) { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wrr + wur + wuu;} } else { if((M[p] - M[p+pul]) > 0) {wul = atan ((M[p] - M[p+pul]) / (2 * M.dxy^2)^0.5);} else {wul = 0;} if((M[p] - M[p+pl]) > 0) {wll = atan ((M[p] - M[p+pl]) / M.dxy);} else {wll = 0;} if((M[p] - M[p+pol]) > 0) {wol = atan ((M[p] - M[p+pol]) / (2 * M.dxy^2)^0.5);} else {wol = 0;} if((M[p] - M[p+po]) > 0) {woo = atan ((M[p] - M[p+po]) / M.dxy);} else {woo = 0;} if((M[p] - M[p+por]) > 0) {wor = atan ((M[p] - M[p+por]) / (2 * M.dxy^2)^0.5);} else {wor = 0;} if((M[p] - M[p+pr]) > 0) {wrr = atan ((M[p] - M[p+pr]) / M.dxy);} else {wrr = 0;} if((M[p] - M[p+pur]) > 0) {wur = atan ((M[p] - M[p+pur]) / (2 * M.dxy^2)^0.5);} else {wur = 0;} if((M[p] - M[p+pu]) > 0) {wuu = atan ((M[p] - M[p+pu]) / M.dxy);} else {wuu = 0;} if((wul + wll + wol + woo + wor + wrr + wur + wuu) == 0) {Z[p] = 0;} else {Z[p] = wul + wll + wol + woo + wor + wrr + wur + wuu;} } }}}}}}}} // hier werden Grids UL bis UU (im Uhrzeigersinn) erzeugt, die angeben, welchen Anteil des Inhalts einer benachbarten Rasterzelle in die Zielrasterzelle (zentrale Rasterzelle im 9er Feld) uebergen wird // foreach p in UL do { if (p.x == 0 || p.y == 0) {UL[p] = 0;} else { if((M[p] - M[p+pul]) < 0 && Z[p+pul] > 0) {UL[p] = (atan((M[p+pul] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+pul];} else {UL[p] = 0;} } } foreach p in LL do { if (p.x == 0) {LL[p] = 0;} else { if((M[p] - M[p+pl]) < 0 && Z[p+pl] > 0) {LL[p] = (atan((M[p+pl] - M[p])/M.dxy))/Z[p+pl];} else {LL[p] = 0;} } } foreach p in OL do { if (p.x == 0 || p.y == M.yanz - 1) {OL[p] = 0;} else { if((M[p] - M[p+pol]) < 0 && Z[p+pol] > 0) {OL[p] = (atan((M[p+pol] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+pol];} else {OL[p] = 0;} } } foreach p in OO do { if (p.y == M.yanz - 1) {OO[p] = 0;} else { if((M[p] - M[p+po]) < 0 && Z[p+po] > 0) {OO[p] = (atan((M[p+po] - M[p])/M.dxy))/Z[p+po];} else {OO[p] = 0;} } } foreach p in OR do { if (p.x == M.xanz - 1 || p.y == M.yanz - 1) {OR[p] = 0;} else { if((M[p] - M[p+por]) < 0 && Z[p+por] > 0) {OR[p] = (atan((M[p+por] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+por];} else {OR[p] = 0;} } } foreach p in RR do { if (p.x == M.xanz - 1) {RR[p] = 0;} else { if((M[p] - M[p+pr]) < 0 && Z[p+pr] > 0) {RR[p] = (atan((M[p+pr] - M[p])/M.dxy))/Z[p+pr];} else {RR[p] = 0;} } } foreach p in UR do { if (p.x == M.xanz - 1 || p.y == 0) {UR[p] = 0;} else { if((M[p] - M[p+pur]) < 0 && Z[p+pur] > 0) {UR[p] = (atan((M[p+pur] - M[p])/(2 * M.dxy^2)^0.5))/Z[p+pur];} else {UR[p] = 0;} } } foreach p in UU do { if (p.y == 0) {UU[p] = 0;} else { if((M[p] - M[p+pu]) < 0 && Z[p+pu] > 0) {UU[p] = (atan((M[p+pu] - M[p])/M.dxy))/Z[p+pu];} else {UU[p] = 0;} } } // in den folgenden drei Schritten wird nach der "multiple flow methode" die Einzugsgebietsgroeße C ermittelt // foreach p in Z do {Z[p] = 1;} foreach ploop in Loop do { ploop.x = 1; i = i +1; gefunden = 0; foreach p in Z do { if (R[p] == i) {Z[p] = 1 + Z[p+pul] * UL[p] + Z[p+pl] * LL[p] + Z[p+pol] * OL[p] + Z[p+po] * OO[p] + Z[p+por] * OR[p] + Z[p+pr] * RR[p] + Z[p+pur] * UR[p] + Z[p+pu] * UU[p]; gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } setRandN(Z); foreach p in C do {C[p] = Z[p] * O.dxy^2;} // in den folgenden drei Schritten wird die gesaugte Einzugsgebietsgroeße CS ermittelt, wobei der t-Parameter die Staerke der Saugung steuert. Werte unter 10 (z.B.: 5) fuehren zu einer starken Saugung, Werte ueber 10 (z.B. 15) zu einer schwachen Saugung. Die gesaugte Einzugsgebietsgroeße selbst stellt bereits einen Parameter Dar, der die raeumliche Relief-bedingte Feuchteverteilung in guter Weise annaehert // foreach p in X do {X[p] = C[p];} foreach ploop in Loop do { ploop.x = 1; j = j +1; gefunden = 0; foreach p in X do { if ((((1/t^N[p])^exp(t^N[p])) * max9(p, X)) > X[p]) {X[p] = (((1/t^N[p])^exp(t^N[p])) * max9(p, X)); gefunden = 1;} } if (gefunden == 0) {ploop.x = 100000;} } foreach p in CS do { if (isRand(p, M) == 0) { if(X[p] > C[p] || X[p+pul] > C[p+pul] || X[p+pl] > X[p+pl] || X[p+pol] > C[p+pol] || X[p+po] > C[p+po] || X[p+por] > C[p+por] || X[p+pr] > C[p+pr] || X[p+pur] > C[p+pur] || X[p+pu] > C[p+pu]) {CS[p] = ln((X[p] + X[p+pul] + X[p+pu] + X[p+pur] + X[p+pl] + X[p+pr] + X[p+pol] + X[p+po] + X[p+por])/9);} else {CS[p] = ln(X[p]);} } } setRandN (CS); showMatrix(CS); // in den folgenden zwei Schritten wird der SAGA Bodenfeuchteindex SB ermittelt. Der a-Parameter muss bei den Settings definiert werden und sorgt dafuer, das nicht durch 0 dividiert wird // foreach p in SB do {SB[p] = exp(CS[p])/tan(N[p] + a);} foreach p in SB do {SB[p] = ln(SB[p]);} showMatrix(SB); /**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/IsochronesVar.h0000664000175000017500000000374012565125415027051 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: IsochronesVar.h 2492 2015-05-18 12:37:39Z reklov_w $ *********************************************************/ /******************************************************************************* IsochronesVar.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CIsochronesVar : public CSG_Module_Grid_Interactive { public: CIsochronesVar(void); virtual ~CIsochronesVar(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Dynamics" )); } protected: virtual bool On_Execute(void); virtual bool On_Execute_Finish(); virtual bool On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CSG_Grid *m_pDEM; CSG_Grid *m_pTime; CSG_Grid *m_pSpeed; CSG_Grid *m_pManning; CSG_Grid *m_pCN; CSG_Grid *m_pCatchArea; CSG_Grid *m_pSlope; CSG_Grid m_Direction; double m_dManning; double m_dCN; double m_dRainfall; double m_dMixedThresh; double m_dChannelThresh; double m_dChannelSlope; double m_dMinSpeed; void ZeroToNoData(void); double Runoff(double, double); void _CalculateTime(int x, int y); }; saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Helper.h0000664000175000017500000000347512565125415025510 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Helper.h 1016 2011-04-27 18:40:36Z oconrad $ *********************************************************/ /******************************************************************************* Helper.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include #define GLOBAL_BASIN -1 void Init_FlowDirectionsD8(CSG_Grid *pDEM, CSG_Grid *pDirection); void getNextCell(CSG_Grid*,int,int,int &,int &); void getNextCell(CSG_Grid*,CSG_Grid*,int,int,int&,int&); double FlowDistance(CSG_Grid*,CSG_Grid*,int,int,int,int,int); double CalculateBasinGrid(CSG_Grid*, CSG_Grid*, int, int); void CalculateFlowAccGrid(CSG_Grid*, CSG_Grid*); //TSG_Point ** RiverProfile(int, int, CSG_Grid*, CSG_Grid*, CSG_Grid*, int &); //TSG_Point * RiverCoords (int, int, CSG_Grid*, CSG_Grid*, int &); //float DrainageDensity(CSG_Shapes*, CSG_Shapes*, CSG_Grid*, CSG_Grid*); //void ClosingPoint(CSG_Grid*, CSG_Grid*, int &, int &); saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/MLB_Interface.cpp0000664000175000017500000001403712565125415027212 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Hydrology") ); case MLB_INFO_Category: return( _TL("Terrain Analysis") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Olaya (c) 2001-4") ); case MLB_INFO_Description: return( _TL("Tools for digital terrain analysis.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Terrain Analysis|Hydrology") ); } } //--------------------------------------------------------- #include "Flow_Parallel.h" #include "Flow_RecursiveUp.h" #include "Flow_RecursiveDown.h" #include "Flow_AreaUpslope.h" #include "Flow_AreaDownslope.h" #include "Flow_Distance.h" #include "SlopeLength.h" #include "EdgeContamination.h" #include "IsochronesConst.h" #include "IsochronesVar.h" #include "CellBalance.h" #include "Sinuosity.h" #include "FlowDepth.h" #include "TopographicIndices.h" #include "SAGA_Wetness_Index.h" #include "LakeFlood.h" #include "flow_massflux.h" #include "flow_width.h" #include "melton_ruggedness.h" #include "Erosion_LS_Fields.h" #include "flow_by_slope.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CFlow_Parallel ); case 1: return( new CFlow_RecursiveUp ); case 2: return( new CFlow_RecursiveDown ); case 3: return( new CFlow_AreaUpslope_Interactive ); case 4: return( new CFlow_AreaUpslope_Area ); case 5: return( new CFlow_AreaDownslope ); case 6: return( new CFlow_Distance ); case 7: return( new CSlopeLength ); case 8: return( new CIsochronesConst ); case 9: return( new CIsochronesVar ); case 10: return( new CCellBalance ); case 11: return( new CSinuosity ); case 12: return( new CFlowDepth ); case 13: return( new CEdgeContamination ); case 14: return( MLB_INTERFACE_SKIP_MODULE ); // removed: CTopographicIndices case 15: return( new CSAGA_Wetness_Index ); case 16: return( new CLakeFlood ); case 17: return( new CLakeFloodInteractive ); case 18: return( new CFlow_MassFlux ); case 19: return( new CFlow_Width ); case 20: return( new CTWI ); case 21: return( new CStream_Power ); case 22: return( new CLS_Factor ); case 23: return( new CMelton_Ruggedness ); case 24: return( new CTCI_Low ); case 25: return( new CErosion_LS_Fields ); case 26: return( new CFlow_by_Slope ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Makefile.am0000664000175000017500000000270312565125415026145 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1824 2013-09-05 08:48:21Z oconrad $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_hydrology.la libta_hydrology_la_SOURCES =\ CellBalance.cpp\ EdgeContamination.cpp\ Erosion_LS_Fields.cpp\ Flow.cpp\ Flow_AreaDownslope.cpp\ Flow_AreaUpslope.cpp\ flow_by_slope.cpp\ Flow_Distance.cpp\ Flow_Parallel.cpp\ Flow_RecursiveDown.cpp\ Flow_RecursiveUp.cpp\ flow_massflux.cpp\ flow_width.cpp\ FlowDepth.cpp\ Helper.cpp\ IsochronesConst.cpp\ IsochronesVar.cpp\ LakeFlood.cpp\ LakeFloodInteractive.cpp\ MLB_Interface.cpp\ melton_ruggedness.cpp\ SAGA_Wetness_Index.cpp\ Sinuosity.cpp\ SlopeLength.cpp\ TopographicIndices.cpp\ CellBalance.h\ EdgeContamination.h\ Erosion_LS_Fields.h\ Flow.h\ Flow_AreaDownslope.h\ Flow_AreaUpslope.h\ flow_by_slope.h\ Flow_BRM.h\ Flow_Distance.h\ Flow_Parallel.h\ Flow_RecursiveDown.h\ Flow_RecursiveUp.h\ flow_massflux.h\ flow_width.h\ FlowDepth.h\ Helper.h\ IsochronesConst.h\ IsochronesVar.h\ LakeFlood.h\ MLB_Interface.h\ melton_ruggedness.h\ SAGA_Wetness_Index.h\ Sinuosity.h\ SlopeLength.h\ TopographicIndices.h libta_hydrology_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/MLB_Interface.h0000664000175000017500000000772312565125415026663 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_hydrology_H #define HEADER_INCLUDED__ta_hydrology_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef ta_hydrology_EXPORTS #define ta_hydrology_EXPORT _SAGA_DLL_EXPORT #else #define ta_hydrology_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ta_hydrology_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/melton_ruggedness.h0000664000175000017500000001176212565125415030013 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: melton_ruggedness.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // melton_ruggedness.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__melton_ruggedness_H #define HEADER_INCLUDED__melton_ruggedness_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMelton_Ruggedness : public CSG_Module_Grid { public: CMelton_Ruggedness(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Topographic Indices" )); } protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM; bool Set_Flow (int x, int y, int Direction); double Get_Flow (int x, int y, int Direction); double Get_Area (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__melton_ruggedness_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/IsochronesConst.h0000664000175000017500000000342712565125415027411 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: IsochronesConst.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /******************************************************************************* IsochronesConst.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #ifndef HEADER_INCLUDED__IsochronesConst_H #define HEADER_INCLUDED__IsochronesConst_H #include "MLB_Interface.h" class CIsochronesConst : public CSG_Module_Grid_Interactive { public: CIsochronesConst(void); virtual ~CIsochronesConst(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Dynamics" )); } protected: virtual bool On_Execute(void); virtual bool On_Execute_Finish(void); virtual bool On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CSG_Grid *m_pDEM; CSG_Grid *m_pTime; CSG_Grid m_Direction; double m_dConcTime; void _CalculateDistance(int x, int y); }; #endif // #ifndef HEADER_INCLUDED__IsochronesConst_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Erosion_LS_Fields.h0000664000175000017500000001200512565125415027560 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Erosion_LS_Fields.h 1524 2012-11-09 15:08:30Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Erosion_LS_Fields.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Erosion_LS_Fields_H #define HEADER_INCLUDED__Erosion_LS_Fields_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CErosion_LS_Fields : public CSG_Module_Grid { public: CErosion_LS_Fields(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Topographic Indices" )); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool m_bStopAtEdge; int m_nFields, m_Method, m_Method_Slope, m_Method_Area, m_Stability; double m_Erosivity; CSG_Grid m_Fields, *m_pDEM, *m_pUp_Area, *m_pUp_Length, *m_pUp_Slope, *m_pLS; bool Get_Flow (void); double Get_Flow (int x, int y, double dz[8]); bool Get_LS (void); double Get_LS (int x, int y); bool Set_Fields (void); bool Get_Statistics (void); bool Get_Balance (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Erosion_LS_Fields_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/Flow_AreaDownslope.h0000664000175000017500000001141012565125415030007 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Flow_AreaDownslope.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // Flow_AreaDownslope.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Flow_AreaDownslope_H #define HEADER_INCLUDED__Flow_AreaDownslope_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Flow.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFlow_AreaDownslope : public CSG_Module_Grid_Interactive { public: CFlow_AreaDownslope(void); virtual ~CFlow_AreaDownslope(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Flow Accumulation" )); } protected: virtual bool On_Execute (void); virtual bool On_Execute_Finish (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CFlow *pFlow; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Flow_AreaDownslope_H saga-2.2.3/src/modules/terrain_analysis/ta_hydrology/LakeFlood.h0000664000175000017500000001267212565125415026130 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: LakeFlood.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_hydrology // // // //-------------------------------------------------------// // // // LakeFlood.h // // // // Copyright (C) 2005-6 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: volkerwichmann@ku-eichstaett.de // // // // contact: Volker Wichmann // // Research Associate // // Chair of Physical Geography // // KU Eichst�tt-Ingolstadt // // Ostenstr. 18 // // 85072 Eichst�tt // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__LakeFlood_H #define HEADER_INCLUDED__LakeFlood_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTraceOrder { public: CTraceOrder(void) { x = y = 0; prev = NULL; next = NULL; }; ~CTraceOrder(void) { if(next != NULL) delete (next); next = NULL; }; int x; int y; CTraceOrder *prev; CTraceOrder *next; }; //--------------------------------------------------------- class ta_hydrology_EXPORT CLakeFlood : public CSG_Module_Grid { public: CLakeFlood(void); virtual ~CLakeFlood(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Miscellaneous") ); } protected: virtual bool On_Execute (void); typedef struct { int x; // grid x int y; // grid y double z; // absolute water level }SEED; private: }; //--------------------------------------------------------- class ta_hydrology_EXPORT CLakeFloodInteractive : public CSG_Module_Grid_Interactive { public: CLakeFloodInteractive(void); virtual ~CLakeFloodInteractive(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Miscellaneous") ); } protected: virtual bool On_Execute (void); virtual bool On_Execute_Finish (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CSG_Grid *pElev, *pOdepth, *pOlevel; CTraceOrder *newCell, *firstCell, *iterCell, *lastCell; bool m_bLevel; double m_water; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__LakeFlood_H saga-2.2.3/src/modules/terrain_analysis/ta_channels/0000775000175000017500000000000012634325752023665 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/terrain_analysis/ta_channels/D8_Flow_Analysis.h0000664000175000017500000001147712565125414027151 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: D8_Flow_Analysis.h 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // D8_Flow_Analysis.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__D8_Flow_Analysis_H #define HEADER_INCLUDED__D8_Flow_Analysis_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_channels_EXPORT CD8_Flow_Analysis : public CSG_Module_Grid { public: CD8_Flow_Analysis(void); protected: virtual bool On_Execute (void); private: int m_Threshold; CSG_Grid *m_pDEM, *m_pDir, *m_pOrder, *m_pBasins, m_Nodes; CSG_Shapes *m_pSegments; void Get_Direction (void); void Get_Order (void); int Get_Order (int x, int y); void Get_Nodes (void); void Set_Node (int x, int y, int id, int type, CSG_Shape *pNode); void Get_Basins (void); int Get_Basin (int x, int y); void Get_Segments (void); void Get_Segment (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__D8_Flow_Analysis_H saga-2.2.3/src/modules/terrain_analysis/ta_channels/Watersheds.h0000664000175000017500000001067012565125414026147 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Watersheds.h 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // Watersheds.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Watersheds_H #define HEADER_INCLUDED__Watersheds_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_channels_EXPORT CWatersheds : public CSG_Module_Grid { public: CWatersheds(void); virtual ~CWatersheds(void); protected: virtual bool On_Execute (void); private: int m_nBasins; CSG_Grid *m_pBasins, m_Direction; int Get_Basin (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Watersheds_H saga-2.2.3/src/modules/terrain_analysis/ta_channels/Watersheds_ext.h0000664000175000017500000000514312565125414027026 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Watersheds_ext.h 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /******************************************************************************* Watersheds.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWatersheds_ext : public CSG_Module_Grid { public: CWatersheds_ext(void); protected: virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pChannels, m_Distance, m_Direction; bool Get_Basin (CSG_Grid *pBasins, CSG_Shapes *pPolygons, int xMouth, int yMouth, int Main_ID); CSG_Shape * Get_Basin (CSG_Grid *pBasins, CSG_Shapes *pPolygons); bool is_Outlet (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_channels/ChannelNetwork_Altitude.cpp0000664000175000017500000003357612565125414031160 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ChannelNetwork_Altitude.cpp 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // ChannelNetwork_Altitude.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ChannelNetwork_Altitude.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CChannelNetwork_Altitude::CChannelNetwork_Altitude(void) { //----------------------------------------------------- Set_Name (_TL("Vertical Distance to Channel Network")); Set_Author (SG_T("O.Conrad (c) 2002")); Set_Description (_TW( "This module calculates the vertical distance to a channel network base level. " "The algorithm consists of two major steps:\n" " 1. Interpolation of a channel network base level elevation\n" " 2. Subtraction of this base level from the original elevations\n" )); //----------------------------------------------------- // Input... Parameters.Add_Grid( NULL, "ELEVATION" , _TL("Elevation"), _TL("A grid that contains elevation data."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "CHANNELS" , _TL("Channel Network"), _TW("A grid providing information about the channel network. It is assumed that no-data cells are not part " "of the channel network. Vice versa all others cells are recognised as channel network members."), PARAMETER_INPUT ); //----------------------------------------------------- // Output... Parameters.Add_Grid( NULL, "DISTANCE" , _TL("Vertical Distance to Channel Network"), _TL("The resulting grid gives the altitude above the channel network in the same units as the elevation data."), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "BASELEVEL" , _TL("Channel Network Base Level"), _TL("This optional grid output contains the interpolated channel network base level elevations."), PARAMETER_OUTPUT_OPTIONAL ); //----------------------------------------------------- // Options... Parameters.Add_Value( NULL, "THRESHOLD" , _TL("Tension Threshold [Percentage of Cell Size]"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL, "NOUNDERGROUND", _TL("Keep Base Level below Surface"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CChannelNetwork_Altitude::On_Execute(void) { int nCells, nCells_Start, iStep, nSteps; double Threshold; //----------------------------------------------------- m_pDTM = Parameters("ELEVATION") ->asGrid(); m_pChannels = Parameters("CHANNELS") ->asGrid(); m_pDistance = Parameters("DISTANCE") ->asGrid(); m_bNoUnderground = Parameters("NOUNDERGROUND") ->asBool(); Threshold = Parameters("THRESHOLD") ->asDouble() * Get_Cellsize(); DataObject_Set_Colors(m_pDistance, 10, SG_COLORS_YELLOW_BLUE, true); //----------------------------------------------------- nCells = Get_NX() > Get_NY() ? Get_NX() : Get_NY(); for(nSteps=0; pow(2.0, nSteps + 1) < nCells; nSteps++); nCells_Start = (int)pow(2.0, nSteps); //----------------------------------------------------- m_pDistance->Assign_NoData(); m_Mask.Create(*Get_System(), SG_DATATYPE_Byte); m_Dist.Create(*Get_System()); m_Dist.Set_NoData_Value_Range(m_pDTM->Get_NoData_Value(), m_pDTM->Get_NoData_hiValue()); for(nCells=nCells_Start, iStep=1; nCells>0 && Process_Get_Okay(); nCells/=2, iStep++) { Process_Set_Text(CSG_String::Format(SG_T("%d [%d]"), iStep, nSteps + 1)); Set_Surface(nCells); while( Threshold < Get_Change(nCells) && Process_Get_Okay() ); } m_Mask.Destroy(); m_Dist.Destroy(); //----------------------------------------------------- CSG_Grid *pBase = Parameters("BASELEVEL")->asGrid(); for(sLong n=0; nis_NoData(n) || m_pDTM->is_NoData(n) ) { m_pDistance->Set_NoData(n); if( pBase ) { pBase->Set_NoData(n); } } else { double z = m_pDistance->asDouble(n); m_pDistance->Set_Value(n, m_pDTM->asDouble(n) - z); if( pBase ) { pBase->Set_Value(n, z); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CChannelNetwork_Altitude::Set_Surface(int nCells) { m_Dist.Assign_NoData(); m_Mask.Assign(0.0); //----------------------------------------------------- for(int y=0; yis_InGrid(ix, iy) && !m_pDTM->is_NoData(ix, iy) ) { z += m_pDTM->asDouble(ix, iy); nz ++; } } } //--------------------------------------------- if( nz > 0 ) { m_Mask.Set_Value(x, y, 1.0); m_Dist.Set_Value(x, y, z / nz); } else { m_Mask.Set_Value(x, y, 0.0); if( m_pDistance->is_NoData(x, y) ) { for(i=0; i<8; i++) { ix = x + nCells * Get_xTo(i); iy = y + nCells * Get_yTo(i); if( m_pDistance->is_InGrid(ix, iy) ) { z += m_pDistance->asDouble(ix, iy); nz ++; } } m_Dist.Set_Value(x, y, nz > 0 ? z / nz : m_pDTM->asDouble(x, y)); } else { m_Dist.Set_Value(x, y, m_pDistance->asDouble(x, y)); } } } } //----------------------------------------------------- m_pDistance->Assign(&m_Dist); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CChannelNetwork_Altitude::Get_Change(int nCells) { int x, y; double d, dMax; //----------------------------------------------------- for(y=0; yasDouble(x, y))) ) { dMax = d; } m_pDistance->Set_Value(x, y, m_Dist.asDouble(x, y)); } } } return( dMax ); } //--------------------------------------------------------- double CChannelNetwork_Altitude::Get_Change(int nCells, int x, int y) { int i, ix, iy; double n, d, dz; for(i=0, d=0.0, n=0.0; i<8; i++) { ix = x + nCells * Get_xTo(i); iy = y + nCells * Get_yTo(i); if( m_pDistance->is_InGrid(ix, iy) ) { dz = 1.0 / Get_UnitLength(i); d += dz * m_pDistance->asDouble(ix, iy); n += dz; } } if( n > 0.0 ) { d /= n; return( m_bNoUnderground && !m_pDTM->is_NoData(x, y) && d > m_pDTM->asDouble(x, y) ? m_pDTM->asDouble(x, y) : d ); } return( m_pDistance->asDouble(x, y) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CValley_Depth::CValley_Depth(void) { //----------------------------------------------------- Set_Name (_TL("Valley Depth")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Valley depth is calculated here vertical distance to a channel network base level. " "The algorithm consists of two major steps:\n" " 1. Interpolation of a channel network base level elevation\n" " 2. Subtraction of this base level from the original elevations\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "VALLEY_DEPTH" , _TL("Valley Depth"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "RIDGE_LEVEL" , _TL("Ridge Level"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "THRESHOLD" , _TL("Tension Threshold [Percentage of Cell Size]"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL , "NOUNDERGROUND" , _TL("Keep Ridge Level above Surface"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "ORDER" , _TL("Ridge Detection Threshold"), _TL(""), PARAMETER_TYPE_Int, 4, 1, true, 7, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define RUN_MODULE(LIBRARY, MODULE, CONDITION) {\ bool bResult;\ SG_RUN_MODULE(bResult, LIBRARY, MODULE, CONDITION)\ if( !bResult ) return( false );\ } #define SET_PARAMETER(IDENTIFIER, VALUE) pModule->Get_Parameters()->Set_Parameter(SG_T(IDENTIFIER), VALUE) //--------------------------------------------------------- bool CValley_Depth::On_Execute(void) { CSG_Grid Inverse(*Get_System(), SG_DATATYPE_Float); CSG_Grid Ridges (*Get_System(), SG_DATATYPE_Int); //----------------------------------------------------- RUN_MODULE("grid_tools" , 19, // grid orientation SET_PARAMETER("INPUT" , Parameters("ELEVATION")) && SET_PARAMETER("RESULT" , &Inverse) && SET_PARAMETER("METHOD" , 3) // invert ) RUN_MODULE("ta_channels" , 6, // strahler order SET_PARAMETER("DEM" , &Inverse) && SET_PARAMETER("STRAHLER" , &Ridges) ) Ridges.Set_NoData_Value_Range(0, Parameters("ORDER")->asInt()); RUN_MODULE("ta_channels" , 3, // vertical channel network distance SET_PARAMETER("ELEVATION" , &Inverse) && SET_PARAMETER("CHANNELS" , &Ridges) && SET_PARAMETER("DISTANCE" , Parameters("VALLEY_DEPTH")) && SET_PARAMETER("BASELEVEL" , Parameters("RIDGE_LEVEL")) && SET_PARAMETER("THRESHOLD" , Parameters("THRESHOLD")) && SET_PARAMETER("NOUNDERGROUND" , Parameters("NOUNDERGROUND")) ) //----------------------------------------------------- if( Parameters("RIDGE_LEVEL")->asGrid() ) { Parameters("RIDGE_LEVEL")->asGrid()->Invert(); } DataObject_Set_Colors(Parameters("VALLEY_DEPTH")->asGrid(), 10, SG_COLORS_YELLOW_BLUE, false); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_channels/ChannelNetwork_Altitude.h0000664000175000017500000001173512565125414030616 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ChannelNetwork_Altitude.h 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // ChannelNetwork_Altitude.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ChannelNetwork_Altitude_H #define HEADER_INCLUDED__ChannelNetwork_Altitude_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_channels_EXPORT CChannelNetwork_Altitude : public CSG_Module_Grid { public: CChannelNetwork_Altitude(void); protected: virtual bool On_Execute (void); private: bool m_bNoUnderground; CSG_Grid *m_pDTM, *m_pChannels, *m_pDistance, m_Mask, m_Dist; void Set_Surface (int nCells); double Get_Change (int nCells); double Get_Change (int nCells, int x, int y); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_channels_EXPORT CValley_Depth : public CSG_Module_Grid { public: CValley_Depth(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ChannelNetwork_Altitude_H saga-2.2.3/src/modules/terrain_analysis/ta_channels/Strahler.cpp0000664000175000017500000000567112565125414026162 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Strahler.cpp 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /******************************************************************************* Strahler.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ //--------------------------------------------------------- #include "Strahler.h" //--------------------------------------------------------- CStrahler::CStrahler(void){ Set_Name (_TL("Strahler Order")); Set_Author (_TL("Copyrights (c) 2004 by Victor Olaya")); Set_Description (_TW( "(c) 2004 by Victor Olaya. Strahler Order Calculation" )); Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "STRAHLER" , _TL("Strahler Order"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Short ); } //--------------------------------------------------------- CStrahler::~CStrahler(void) {} //--------------------------------------------------------- int CStrahler::getStrahlerOrder(int x, int y) { int Order = m_pStrahler->asInt(x, y); if( Order == 0 ) { int i, ix, iy, n; for(i=0, n=0, Order=1; i<8; i++) { if( Get_System()->Get_Neighbor_Pos(i + 4, x, y, ix, iy) && m_pDEM->Get_Gradient_NeighborDir(ix, iy) == i ) { int iOrder = getStrahlerOrder(ix, iy); if( Order < iOrder ) { Order = iOrder; n = 1; } else if( Order == iOrder ) { n++; } } } if( n > 1 ) { Order++; } m_pStrahler->Set_Value(x, y, Order); } return( Order ); } //--------------------------------------------------------- bool CStrahler::On_Execute(void) { m_pDEM = Parameters("DEM") ->asGrid(); m_pStrahler = Parameters("STRAHLER") ->asGrid(); m_pStrahler ->Set_NoData_Value(0.0); m_pStrahler ->Assign(0.0); DataObject_Set_Colors(m_pStrahler, 10, SG_COLORS_WHITE_BLUE); for(int y=0; yis_NoData(x, y) ) { getStrahlerOrder(x, y); } } } return( true ); } //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_channels/Watersheds_ext.cpp0000664000175000017500000005276612565125414027376 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Watersheds_ext.cpp 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /******************************************************************************* Watersheds.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Watersheds_ext.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { FIELD_ID = 0, FIELD_ID_MAIN, FIELD_MOUTH_X, FIELD_MOUTH_Y, FIELD_PERIMETER, FIELD_AREA, FIELD_CENTROID_X, FIELD_CENTROID_Y, FIELD_Z_MEAN, FIELD_Z_RANGE, FIELD_DIST_MEAN, FIELD_DIST_MAX, FIELD_CONCTIME, FIELD_BASINS_UP, FIELD_BASINS_DOWN, FIELD_BASIN_TYPE, FIELD_EQVRECT_A, FIELD_EQVRECT_B, FIELD_OROG_IDX, FIELD_MASS_IDX }; //--------------------------------------------------------- #define BASIN_ADD_FIELDS(pBasins) {\ pBasins->Add_Field(_TL("ID") , SG_DATATYPE_Int);\ pBasins->Add_Field(_TL("Main Basin ID") , SG_DATATYPE_Int);\ pBasins->Add_Field(_TL("Outlet X") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Outlet Y") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Perimeter") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Area") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Centroid X") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Centroid Y") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Mean Elevation") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Elevation Range") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Mean Flow Distance") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Maximum Flow Distance") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Concentration time (h)") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Upslope Basins") , SG_DATATYPE_String);\ pBasins->Add_Field(_TL("Downslope Basins") , SG_DATATYPE_Int);\ pBasins->Add_Field(_TL("Basin Type (Gravelius)") , SG_DATATYPE_String);\ pBasins->Add_Field(_TL("Equivalent Rectangle (A)") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Equivalent Rectangle (B)") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Orographic Coefficient") , SG_DATATYPE_Double);\ pBasins->Add_Field(_TL("Massivity Coefficient") , SG_DATATYPE_Double);\ } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWatersheds_ext::CWatersheds_ext(void) { Set_Name (_TL("Watershed Basins (Extended)")); Set_Author (SG_T("V.Olaya (c) 2004, O.Conrad (c) 2011")); Set_Description (_TW( "Extended watershed basin analysis. " )); Parameters.Add_Grid( NULL , "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CHANNELS" , _TL("Drainage Network"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "BASINS" , _TL("Basins"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "SUBBASINS" , _TL("Subbasins"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "V_BASINS" , _TL("Basins"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "V_SUBBASINS" , _TL("Subbasins"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "HEADS" , _TL("River Heads"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "MOUTHS" , _TL("River Mouths"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "DISTANCE" , _TL("Flow Distances"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWatersheds_ext::On_Execute(void) { int x, y; CSG_Grid *pBasins, *pSubBasins, Inflows; CSG_Shapes *pHeads, *pMouths, *pVBasins, *pVSubBasins; m_pDEM = Parameters("DEM") ->asGrid(); m_pChannels = Parameters("CHANNELS") ->asGrid(); pBasins = Parameters("BASINS") ->asGrid(); pSubBasins = Parameters("SUBBASINS") ->asGrid(); pVBasins = Parameters("V_BASINS") ->asShapes(); pVSubBasins = Parameters("V_SUBBASINS") ->asShapes(); pHeads = Parameters("HEADS") ->asShapes(); pMouths = Parameters("MOUTHS") ->asShapes(); //----------------------------------------------------- Inflows .Create(*Get_System(), SG_DATATYPE_Char); m_Direction .Create(*Get_System(), SG_DATATYPE_Char); m_Direction .Set_NoData_Value(-1); m_Distance .Create(*Get_System(), SG_DATATYPE_Float); m_Distance .Set_NoData_Value(-1); m_Distance .Assign_NoData(); pBasins ->Assign(0.0); pBasins ->Set_NoData_Value(0.0); pSubBasins ->Assign(0.0); pSubBasins ->Set_NoData_Value(0.0); pHeads ->Create(SHAPE_TYPE_Point , _TL("Heads")); pHeads ->Add_Field("ID" , SG_DATATYPE_Int); pHeads ->Add_Field("MAIN_ID" , SG_DATATYPE_Int); pHeads ->Add_Field("ELEVATION" , SG_DATATYPE_Double); pHeads ->Add_Field("DISTANCE" , SG_DATATYPE_Double); pMouths ->Create(SHAPE_TYPE_Point , _TL("Mouths")); pMouths ->Add_Field("ID" , SG_DATATYPE_Int); pMouths ->Add_Field("MAIN_ID" , SG_DATATYPE_Int); pMouths ->Add_Field("ELEVATION" , SG_DATATYPE_Double); pVBasins ->Create(SHAPE_TYPE_Polygon , _TL("Basins")); BASIN_ADD_FIELDS(pVBasins); pVSubBasins ->Create(SHAPE_TYPE_Polygon , _TL("Subbasins")); BASIN_ADD_FIELDS(pVSubBasins); //----------------------------------------------------- Process_Set_Text(_TL("flow directions...")); for(y=0; yis_InGrid(x, y) ) { double dMax = 0.0; for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && !m_pChannels->is_NoData(ix, iy) ) { double dz = (m_pDEM->asDouble(x, y) - m_pDEM->asDouble(ix, iy)) / Get_Length(i); if( dMax < dz ) { dMax = dz; Direction = i; } } } if( !m_pChannels->is_NoData(x, y) ) { if( Direction >= 0 ) { int ix = Get_xTo(Direction, x); int iy = Get_yTo(Direction, y); if( m_pDEM->is_InGrid(ix, iy) ) { Inflows.Add_Value(ix, iy, 1); } } } else if( Direction < 0 ) { Direction = m_pDEM->Get_Gradient_NeighborDir(x, y); } } m_Direction.Set_Value(x, y, Direction); } } //----------------------------------------------------- Process_Set_Text(_TL("main basins...")); for(y=0; yis_InGrid(x, y) && is_Outlet(x, y) ) { Get_Basin(pBasins, pVBasins, x, y, -1); CSG_Shape *pMouth = pMouths->Add_Shape(); pMouth->Add_Point(Get_System()->Get_Grid_to_World(x, y)); pMouth->Set_Value(0, pVBasins->Get_Count()); // ID pMouth->Set_Value(1, pVBasins->Get_Count()); // MAIN_ID pMouth->Set_Value(2, m_pDEM->asDouble(x, y)); // ELEVATION } } } if( Parameters("DISTANCE")->asBool() ) { m_Distance.Set_Name(_TL("Flow Distance")); DataObject_Add(SG_Create_Grid(m_Distance)); } //----------------------------------------------------- Process_Set_Text(_TL("heads and mouths...")); for(y=0; yis_InGrid(x, y) ) { //----------------------------------------- if( Inflows.asInt(x, y) > 1 ) // mouth, linking channels of subcatchments { CSG_Shape *pMouth = pMouths->Add_Shape(); pMouth->Add_Point(Get_System()->Get_Grid_to_World(x, y)); pMouth->Set_Value(0, pMouths->Get_Count()); // ID pMouth->Set_Value(1, pBasins->asDouble(x, y)); // MAIN_ID pMouth->Set_Value(2, m_pDEM->asDouble(x, y)); // ELEVATION } //----------------------------------------- else if( Inflows.asInt(x, y) == 0 ) // head { CSG_Shape *pHead = pHeads->Add_Shape(); pHead->Add_Point(Get_System()->Get_Grid_to_World(x, y)); pHead->Set_Value(0, pHeads->Get_Count() + 1); pHead->Set_Value(1, m_Distance.asDouble(x, y)); } } } } //----------------------------------------------------- Process_Set_Text(_TL("subbasins...")); pMouths->Set_Index(1, TABLE_INDEX_Ascending, 2, TABLE_INDEX_Descending); for(int iMouth=0; iMouthGet_Count() && Set_Progress(iMouth, pMouths->Get_Count()); iMouth++) { CSG_Shape *pMouth = pMouths->Get_Shape_byIndex(iMouth); if( Get_System()->Get_World_to_Grid(x, y, pMouth->Get_Point(0)) ) { if( pMouth->asInt(0) == pMouth->asInt(1) ) { Get_Basin(pSubBasins, pVSubBasins, x, y, pMouth->asInt(1)); } else { for(int i=0; i<8; i++) { int ix = Get_xFrom(i, x); int iy = Get_yFrom(i, y); if( m_pChannels->is_InGrid(ix, iy) && m_Direction.asInt(ix, iy) == i ) { Get_Basin(pSubBasins, pVSubBasins, ix, iy, pMouth->asInt(1)); } } } } } if( Parameters("DISTANCE")->asBool() ) { m_Distance.Set_Name(_TL("Subbasin Flow Distance")); DataObject_Add(SG_Create_Grid(m_Distance)); } //----------------------------------------------------- m_Distance .Destroy(); m_Direction .Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CWatersheds_ext::is_Outlet(int x, int y) { int Direction = m_Direction.asInt(x, y); if( Direction >= 0 ) { int ix = Get_xTo(Direction, x); int iy = Get_yTo(Direction, y); if( m_pDEM->is_InGrid(ix, iy) ) { return( false ); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWatersheds_ext::Get_Basin(CSG_Grid *pBasins, CSG_Shapes *pPolygons, int xMouth, int yMouth, int Main_ID) { int x, y, Basin_ID = 1 + pPolygons->Get_Count(); CSG_Shape *pPolygon; CSG_Grid_Stack Stack; CSG_Simple_Statistics s_Height, s_Distance; //----------------------------------------------------- Stack.Push(x = xMouth, y = yMouth); pBasins ->Set_Value(x, y, Basin_ID); m_Distance .Set_Value(x, y, 0.0); s_Height += m_pDEM->asDouble(x, y); s_Distance += 0.0; //----------------------------------------------------- while( Stack.Get_Size() > 0 && Process_Get_Okay() ) { Stack.Pop(x, y); double d = m_Distance.asDouble(x, y); //------------------------------------------------- for(int i=0; i<8; i++) { int ix = Get_xFrom(i, x); int iy = Get_yFrom(i, y); if( is_InGrid(ix, iy) && pBasins->is_NoData(ix, iy) && i == m_Direction.asInt(ix, iy) ) { Stack.Push(ix, iy); pBasins ->Set_Value(ix, iy, Basin_ID); m_Distance .Set_Value(ix, iy, d + Get_Length(i)); s_Height += m_pDEM->asDouble(ix, iy); s_Distance += d + Get_Length(i); } } } //----------------------------------------------------- if( s_Height.Get_Count() > 1 && (pPolygon = Get_Basin(pBasins, pPolygons)) != NULL ) { double d, Area, Perimeter, Side_A, Side_B; CSG_String Gravelius; // Area = s_Height.Get_Count() * Get_System()->Get_Cellarea(); Area = ((CSG_Shape_Polygon*)pPolygon)->Get_Area(); Perimeter = ((CSG_Shape_Polygon*)pPolygon)->Get_Perimeter(); d = 0.28 * Perimeter / sqrt(Area); Gravelius = d > 1.75 ? _TL("rectangular") : d > 1.5 ? _TL("ovalooblonga-rectangularoblonga") : d > 1.25 ? _TL("ovaloredonda-ovalooblonga") : _TL("redonda-ovaloredonda"); d = pow(Perimeter, 2.0) - 8.0 * Area; Side_A = d > 0.0 ? (Perimeter + sqrt(d)) / 4.0 : -1.0; Side_B = d > 0.0 ? (Perimeter - 2.0 * Side_A) / 2.0 : -1.0; pPolygon->Set_Value(FIELD_ID , Basin_ID); pPolygon->Set_Value(FIELD_ID_MAIN , Main_ID); pPolygon->Set_Value(FIELD_MOUTH_X , Get_System()->Get_xGrid_to_World(xMouth)); pPolygon->Set_Value(FIELD_MOUTH_Y , Get_System()->Get_yGrid_to_World(yMouth)); pPolygon->Set_Value(FIELD_PERIMETER , Perimeter); pPolygon->Set_Value(FIELD_AREA , Area); pPolygon->Set_Value(FIELD_CENTROID_X , ((CSG_Shape_Polygon*)pPolygon)->Get_Centroid().x); pPolygon->Set_Value(FIELD_CENTROID_Y , ((CSG_Shape_Polygon*)pPolygon)->Get_Centroid().y); pPolygon->Set_Value(FIELD_Z_MEAN , s_Height .Get_Mean()); pPolygon->Set_Value(FIELD_Z_RANGE , s_Height .Get_Range()); pPolygon->Set_Value(FIELD_DIST_MEAN , s_Distance.Get_Mean()); pPolygon->Set_Value(FIELD_DIST_MAX , s_Distance.Get_Maximum()); pPolygon->Set_Value(FIELD_CONCTIME , s_Height.Get_Range() <= 0.0 ? -1.0 : pow(0.87 * pow(s_Distance.Get_Maximum() / 1000.0, 3.0) / s_Height.Get_Range(), 0.385) ); pPolygon->Set_Value(FIELD_BASIN_TYPE , Gravelius); pPolygon->Set_Value(FIELD_EQVRECT_A , Side_A); pPolygon->Set_Value(FIELD_EQVRECT_B , Side_B); pPolygon->Set_Value(FIELD_OROG_IDX , SG_Get_Square(s_Height.Get_Mean()) / (0.0001 * Area)); // Orographic index, defined as the mean catchment altitude times the ratio of the mean catchment altitude to the orthogonal projection of drainage area (Alcázar, Palau (2010): Establishing environmental flow regimes in a Mediterranean watershed based on a regional classification. Journal of Hydrology, V. 388 pPolygon->Set_Value(FIELD_MASS_IDX , Perimeter / (0.0001 * Area)); // Perimeter / (0.0001 * Area) ??!! pPolygon->Set_Value(FIELD_BASINS_UP , 0.0); // Upslope Basins pPolygon->Set_Value(FIELD_BASINS_DOWN , 0.0); // Downslope Basins return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shape * CWatersheds_ext::Get_Basin(CSG_Grid *pBasins, CSG_Shapes *pPolygons) { int x, y, nEdges, Basin_ID; CSG_Grid Edge; CSG_Shape *pPolygon = NULL; Basin_ID = 1 + pPolygons->Get_Count(); //----------------------------------------------------- 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()); Edge.Set_NoData_Value(0); for(y=0, nEdges=0; yasInt(x, y) == Basin_ID ) { for(int i=0; i<8; i+=2) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( !is_InGrid(ix, iy) || pBasins->asInt(ix, iy) != Basin_ID ) { ix = 1 + 2 * x; iy = 1 + 2 * y; Edge.Set_Value( ix, iy , 1); Edge.Set_Value(Get_xTo(i , ix), Get_yTo(i , iy), -1); Edge.Set_Value(Get_xTo(i - 1, ix), Get_yTo(i - 1, iy), -1); nEdges++; } } } } } //----------------------------------------------------- if( nEdges > 0 ) { for(int yEdge=0; yEdgeAdd_Shape(); } int iPart = pPolygon->Get_Part_Count(); int xFirst = x = Get_xTo(i, xEdge); int yFirst = y = Get_yTo(i, yEdge); i = i + 2; pPolygon ->Add_Point(Edge.Get_System().Get_Grid_to_World(x, y), iPart); do { int ix = Get_xTo(i + 2, x); int iy = Get_yTo(i + 2, y); if( Edge.is_InGrid(ix, iy) && Edge.asInt(ix, iy) == -1 ) // go right ? { pPolygon->Add_Point(Edge.Get_System().Get_Grid_to_World(x, y), iPart); i = (i + 2) % 8; } else { if( Edge.asInt(ix, iy) == 1 ) { Edge.Set_NoData(ix, iy); // erase class id in right cells } ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( Edge.is_InGrid(ix, iy) && Edge.asInt(ix, iy) == -1 ) // go ahead ? { // nop } else { ix = Get_xTo(i + 6, x); iy = Get_yTo(i + 6, y); if( Edge.is_InGrid(ix, iy) && Edge.asInt(ix, iy) == -1 ) // go left ? { pPolygon->Add_Point(Edge.Get_System().Get_Grid_to_World(x, y), iPart); i = (i + 6) % 8; } else { return( false ); } } } x = ix; y = iy; } while( x != xFirst || y != yFirst ); pPolygon->Add_Point(Edge.Get_System().Get_Grid_to_World(x, y), iPart); } } } //----------------------------------------------------- return( pPolygon ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// /*/--------------------------------------------------------- void CWatersheds_ext::CreateShapesLayer(void) { //first shape (0) is the whole basin. CSG_Table_Record *pRecord, *pRecord2; CSG_Shape *pSubbasin; TSG_Point Point; double fArea=0, fPerim=0; double fSide1, fSide2; double fConcTime; double fMinHeight; int i,j,k; int x,y; int iNextX, iNextY; int iX, iY; int iXOrig, iYOrig; int iIndex; int iUpstreamBasin; int iDownstreamBasin; int iCode; CSG_String sSubbasins; CSG_Points_Int m_Heads; //----------------------------------------------------- //upstream and downstream basins CSG_Shapes *pBasins = Parameters("V_BASINS")->asShapes(); //----------------------------------------------------- TSG_Point_Int m_Closing; for(i=0; iasInt(Next .x, Next .y); iUpstreamBasin = m_pBasins->asInt(Point.x, Point.y); if( iUpstreamBasin != iDownstreamBasin && iDownstreamBasin != 0 && iUpstreamBasin != 0 ) { for(j=0; jGet_Count(); j++) { pRecord = pBasins->Get_Record(j); iCode = pRecord->asInt(0); if( iCode == iUpstreamBasin ) { pRecord->Set_Value(9, iDownstreamBasin); pRecord->Set_Value(1, Point.x * m_pDEM->Get_Cellsize() + m_pDEM->Get_XMin()); pRecord->Set_Value(2, Point.y * m_pDEM->Get_Cellsize() + m_pDEM->Get_YMin()); } } } } while( !(Point.x == m_Closing.x && Point.y == m_Closing.y) && (Point.x != Next.x || Point.y != Next.y) ); }// for //----------------------------------------------------- for (i = 1; iGet_Count(); i++) { pBasins->Get_Record(i)->Set_Value(8,SG_T(" --- ")); iCode = pBasins->Get_Record(i)->asInt(0); for (j = 0; jGet_Count(); j++) { iDownstreamBasin = pBasins->Get_Record(j)->asInt(9); if (iDownstreamBasin == iCode) { sSubbasins = CSG_String(pBasins->Get_Record(i)->asString(8)) + SG_T(" ") + SG_Get_String(pBasins->Get_Record(j)->asInt(0)); pBasins->Get_Record(i)->Set_Value(8, sSubbasins.c_str()); }//if }//for }//for //----------------------------------------------------- }//*/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_channels/ChannelNetwork_Distance.h0000664000175000017500000001173512565125414030575 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ChannelNetwork_Distance.h 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // ChannelNetwork_Distance.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ChannelNetwork_Distance_H #define HEADER_INCLUDED__ChannelNetwork_Distance_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CChannelNetwork_Distance : public CSG_Module_Grid { public: CChannelNetwork_Distance(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: double m_Flow_B, m_Flow_K, m_Flow_R; CSG_Grid *m_pDEM, *m_pRoute, m_Dir, m_Flow[9], *m_pFlow_K, *m_pFlow_R, *m_pDistance, *m_pDistVert, *m_pDistHorz, *m_pFields, *m_pPasses, *m_pTime, *m_pSDR; double Get_Travel_Time (int x, int y, int Direction); void Initialize_D8 (void); void Initialize_D8 (int x, int y); void Execute_D8 (int x, int y); void Initialize_MFD (void); void Initialize_MFD (int x, int y); void Execute_MFD (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ChannelNetwork_Distance_H saga-2.2.3/src/modules/terrain_analysis/ta_channels/ChannelNetwork.cpp0000664000175000017500000004545212565125414027321 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ChannelNetwork.cpp 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // ChannelNetwork.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ChannelNetwork.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CChannelNetwork::CChannelNetwork(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name(_TL("Channel Network")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (_TW( "This module derives a channel network based on gridded digital elevation data.\n" "Use the initiation options to determine under which conditions channels shall start.\n" "\n") ); //----------------------------------------------------- // Input... Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL("A grid that contains elevation data."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SINKROUTE" , _TL("Flow Direction"), _TW( "An optional grid that provides information about flow directions. \n" "Values between 1 to 8 force the flow of a cell to be given to one its adjacent neighbor cells " "(1->NE, 2->E, 3->SE, 4->S, 5->SW, 6->W, 7->NW, 8->N). " "In case of other values the algorithm will use its own routing scheme. \n" "This option is in particular useful to supply the algorithm with routes that lead the flow through closed depression. "), PARAMETER_INPUT_OPTIONAL ); //----------------------------------------------------- // Output... Parameters.Add_Grid( NULL , "CHNLNTWRK" , _TL("Channel Network"), _TW("If a cell is part of a channel its value equals the channel order. " "Otherwise the cell is marked as no-data."), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "CHNLROUTE" , _TL("Channel Direction"), _TW("If a cell is part of a channel then its value shows the flow direction of the channel " "(1->NE, 2->E, 3->SE, 4->S, 5->SW, 6->W, 7->NW, 8->N). " "Otherwise the cell is marked as no-data."), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Channel Network"), _TL("This shapes layer will contain the resulting channel network in vector format (lines)."), PARAMETER_OUTPUT , SHAPE_TYPE_Line ); //----------------------------------------------------- // Initiation... pNode = Parameters.Add_Grid( NULL , "INIT_GRID" , _TL("Initiation Grid"), _TW("Dependent on the chosen 'Initiation Type' and 'Initiation Threshold' " "the values of this grid control where a channel is initiated."), PARAMETER_INPUT ); Parameters.Add_Choice( pNode , "INIT_METHOD" , _TL("Initiation Type"), _TL("Options:\n - Less than\n - Equals\n - Greater than\nControls under which condition a channel is initiated."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Less than"), _TL("Equals"), _TL("Greater than") ), 2 ); Parameters.Add_Value( pNode , "INIT_VALUE" , _TL("Initiation Threshold"), _TL("Dependent on the chosen 'Initiation Grid' and 'Initiation Type' this value controls under which condition a channel is initiated."), PARAMETER_TYPE_Double , 0.0 ); //----------------------------------------------------- pNode = Parameters.Add_Grid( NULL , "DIV_GRID" , _TL("Divergence"), _TL("Tracing: Convergence"), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "DIV_CELLS" , _TL("Tracing: Max. Divergence"), _TL("Tracing: Stop after x cells with divergent flow"), PARAMETER_TYPE_Int , 5, 1, true ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "TRACE_WEIGHT", _TL("Tracing: Weight"), _TL("Tracing: Weight"), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( NULL , "MINLEN" , _TL("Min. Segment Length"), _TL("Minimum Segment Length (Cells)"), PARAMETER_TYPE_Int , 10 ); } //--------------------------------------------------------- CChannelNetwork::~CChannelNetwork(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CChannelNetwork::On_Execute(void) { int x, y, ID, Trace_Method, Init_Method; sLong n; double Init_Threshold; CSG_Grid *Trace_pRoute, *Trace_pWeight, *Init_pGrid; //----------------------------------------------------- pDTM = Parameters("ELEVATION")->asGrid(); pConvergence = Parameters("DIV_GRID" )->asGrid(); pChannels = Parameters("CHNLNTWRK")->asGrid(); pChannelRoute = Parameters("CHNLROUTE")->asGrid(); pShapes = Parameters("SHAPES" )->asShapes(); minLength = Parameters("MINLEN" )->asInt(); maxDivCells = Parameters("DIV_GRID" )->asGrid() ? Parameters("DIV_CELLS")->asInt() : -1; if( !pDTM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } //----------------------------------------------------- // 1. Flow Direction... Process_Set_Text(_TL("Channel Network: Pass 1")); pChannels->Assign(); Trace_pRoute = Parameters("SINKROUTE") ->asGrid(); Trace_pWeight = Parameters("TRACE_WEIGHT")->asGrid(); Trace_Method = Trace_pWeight ? 1 : 0; for(y=0; yasChar(x, y)) >= 1 && ID <= 8 ) { pChannels->Set_Value(x, y, ID); } else { switch( Trace_Method ) { default: Set_Route_Standard(x, y); break; case 1: Set_Route_Weighted(x, y, Trace_pWeight, 0.0); break; } } } } //----------------------------------------------------- // 2. Initiation... Process_Set_Text(_TL("Channel Network: Pass 2")); pStart = SG_Create_Grid(pDTM, SG_DATATYPE_Char); Init_pGrid = Parameters("INIT_GRID") ->asGrid(); Init_Method = Parameters("INIT_METHOD") ->asInt(); Init_Threshold = Parameters("INIT_VALUE") ->asDouble(); for(n=0; nasDouble(n) <= Init_Threshold ) pStart->Set_Value(n, 1); break; case 1: if( Init_pGrid->asDouble(n) == Init_Threshold ) pStart->Set_Value(n, 1); break; case 2: if( Init_pGrid->asDouble(n) >= Init_Threshold ) pStart->Set_Value(n, 1); break; } } //----------------------------------------------------- // 3. Trace Channel Routes... Process_Set_Text(_TL("Channel Network: Pass 3")); pChannelRoute->Assign(); Direction = NULL; Direction_Buffer = 0; for(n=0; nGet_Sorted(n,x,y) ) { Set_Channel_Route(x,y); } } if( Direction ) { SG_Free( Direction ); } pChannels->Assign(); delete(pStart); //----------------------------------------------------- Process_Set_Text(_TL("Channel Network: Pass 4")); for(y=0; yCreate(SHAPE_TYPE_Line, _TL("Channel Network")); pShapes->Add_Field("SegmentID" ,SG_DATATYPE_Int); pShapes->Add_Field("Order" ,SG_DATATYPE_Int); pShapes->Add_Field("Length" ,SG_DATATYPE_Double); Lock_Create(); for(y=0, ID=1; yasInt(n) == 0 ) { pChannels->Set_NoData(n); pChannelRoute->Set_NoData(n); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CChannelNetwork::Set_Route_Standard(int x, int y) { int i, ix, iy, iMin; double z, dz, dzMin; z = pDTM->asDouble(x,y); iMin = 0; for(i=1; i<=8; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( !pDTM->is_InGrid(ix,iy) ) { iMin = i; break; } else { dz = (z - pDTM->asDouble(ix,iy)) / Get_Length(i); if( iMin <= 0 || dzMin < dz ) { iMin = i; dzMin = dz; } } } pChannels->Set_Value(x,y, iMin ); } //--------------------------------------------------------- void CChannelNetwork::Set_Route_Weighted(int x, int y, CSG_Grid *pWeight, double Weight_Threshold) { bool bMin; int i, ix, iy, iMin; double z, dz, dzMin, w, wMin; z = pDTM->asDouble(x,y); iMin = 0; for(i=1; i<=8; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( !pDTM->is_InGrid(ix, iy) ) { iMin = i; break; } else { dz = (z - pDTM->asDouble(ix,iy)) / Get_Length(i); if( dz > 0 ) { bMin = false; w = pWeight->asDouble(ix,iy); if( iMin <= 0 ) { bMin = true; } else if( Weight_Threshold > 0 ) { if( w > Weight_Threshold && wMin > Weight_Threshold ) { if( dzMin < dz ) { bMin = true; } } else if( wMin < w ) { bMin = true; } } else if( wMin < w ) { bMin = true; } if( bMin ) { iMin = i; wMin = w; dzMin = dz; } } } } pChannels->Set_Value(x,y, iMin ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CChannelNetwork::Set_Channel_Route(int x, int y) { const int BUFFER_GROWSIZE = 256; int xStart, yStart, i, ix, iy, goDir, m, n, nDiv; double z, dz, dzMin, Length; //----------------------------------------------------- if( pStart->asChar(x,y) && !pChannelRoute->asChar(x,y) ) { Lock_Create(); n = 0; nDiv = 0; Length = 0; xStart = x; yStart = y; do { //--------------------------------------------- // 1. Divergence ?!... if( pConvergence ) { if( pConvergence->asDouble(x,y) > -1.0 ) { nDiv++; } else { nDiv = 0; } } if( pConvergence && nDiv > maxDivCells ) { goDir = -1; } else { //----------------------------------------- // 2. Is there any channel around ?!... goDir = 0; z = pDTM->asDouble(x,y); for(i=1; i<=8; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( pDTM->is_InGrid(ix,iy) && !is_Locked(ix,iy) && pChannelRoute->asChar(ix,iy) ) { dz = (z - pDTM->asDouble(ix,iy)) / Get_Length(i); if( goDir <= 0 || dzMin < dz ) { goDir = i; dzMin = dz; } } } if( goDir <= 0 ) // ...if not then go as usual... { goDir = pChannels->asInt(x,y); } //----------------------------------------- // 3. Go to Drainage Direction !... if( goDir > 0 ) { Lock_Set(x,y); x = Get_xTo(goDir,x); y = Get_yTo(goDir,y); Length += Get_UnitLength(goDir); if( n >= Direction_Buffer ) { Direction_Buffer += BUFFER_GROWSIZE; Direction = (int *)SG_Realloc(Direction, Direction_Buffer * sizeof(int)); } Direction[n++] = goDir; } } } while( goDir > 0 && pDTM->is_InGrid(x,y) && !is_Locked(x,y) && !pChannelRoute->asChar(x,y) ); //------------------------------------------------- if( Length >= minLength ) { x = xStart; y = yStart; if( goDir < 0 ) { n -= nDiv; } for(m=0; mSet_Value(x,y,goDir); for(i=0; i<8; i++) // Don't start new channels beside existing ones... { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( pDTM->is_InGrid(ix,iy) ) { pStart->Set_Value(ix,iy,0); } } x = Get_xTo(goDir,x); y = Get_yTo(goDir,y); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CChannelNetwork::Set_Channel_Order(int x, int y) { int i, ix, iy, j, n; //----------------------------------------------------- if( pChannelRoute->asChar(x,y) > 0 ) { for(i=n=0, j=4; i<8; i++, j=(j+1)%8) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( pDTM->is_InGrid(ix,iy) && pChannelRoute->asChar(ix,iy) && j == pChannelRoute->asChar(ix,iy) % 8 ) { n++; } } //----------------------------------------------------- if( n == 0 ) { Lock_Create(); do { Lock_Set(x,y); pChannels->Add_Value(x,y, 1 ); i = pChannelRoute->asChar(x,y); if( i > 0 ) { x = Get_xTo(i,x); y = Get_yTo(i,y); } } while( pDTM->is_InGrid(x,y) && i > 0 && !is_Locked(x,y) ); } } } //--------------------------------------------------------- void CChannelNetwork::Set_Channel_Mouth(int x, int y) { int Order, goDir, ix, iy; Order = pChannels->asInt(x,y); if( Order > 0 ) { goDir = pChannelRoute->asChar(x,y); if( goDir > 0 ) { ix = Get_xTo(goDir,x); iy = Get_yTo(goDir,y); if( !pDTM->is_InGrid(ix,iy) || (pChannels->asInt(ix,iy) > 0 && Order != pChannels->asInt(ix,iy)) ) { pChannels->Set_Value(x,y, -1 ); } } else { pChannels->Set_Value(x,y, -1 ); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CChannelNetwork::Set_Vector(int x, int y, int ID) { bool bContinue; int i, ix, iy, j, Order; double xMin, yMin, Length; CSG_Shape *pShape; //----------------------------------------------------- if( (Order = pChannels->asInt(x,y)) > 0 ) { bContinue = true; for(i=0, j=4; i<8 && bContinue; i++, j=(j+1)%8) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( pDTM->is_InGrid(ix,iy) && pChannels->asInt(ix,iy) == Order && pChannelRoute->asChar(ix,iy) && j == pChannelRoute->asChar(ix,iy) % 8 ) { bContinue = false; } } //------------------------------------------------- if( bContinue ) // Startpunkt gefunden... { xMin = pDTM->Get_XMin(), yMin = pDTM->Get_YMin(); ID = 1; pShape = pShapes->Add_Shape(); do { bContinue = false; Length = 0; Lock_Set(x,y); pShape->Add_Point(xMin + x * Get_Cellsize(), yMin + y * Get_Cellsize()); i = pChannelRoute->asChar(x,y); if( i > 0 ) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); Length += Get_Length(i); if( pDTM->is_InGrid(ix,iy) ) { if( !is_Locked(ix,iy) && ( pChannels->asInt(ix,iy) == Order || pChannels->asInt(ix,iy) < 0) ) { x = ix; y = iy; bContinue = true; } else { pShape->Add_Point(xMin + ix * Get_Cellsize(), yMin + iy * Get_Cellsize()); } } } } while( bContinue ); pShape->Set_Value(0, ID ); pShape->Set_Value(1, Order ); pShape->Set_Value(2, Length ); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_channels/Makefile.in0000664000175000017500000005602412622651175025737 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/ta_channels DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libta_channels_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libta_channels_la_OBJECTS = ChannelNetwork.lo \ ChannelNetwork_Altitude.lo ChannelNetwork_Distance.lo \ D8_Flow_Analysis.lo MLB_Interface.lo Strahler.lo Watersheds.lo \ Watersheds_ext.lo libta_channels_la_OBJECTS = $(am_libta_channels_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libta_channels_la_SOURCES) DIST_SOURCES = $(libta_channels_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 911 2011-02-14 16:38:15Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_channels.la libta_channels_la_SOURCES = \ ChannelNetwork.cpp\ ChannelNetwork_Altitude.cpp\ ChannelNetwork_Distance.cpp\ D8_Flow_Analysis.cpp\ MLB_Interface.cpp\ Strahler.cpp\ Watersheds.cpp\ Watersheds_ext.cpp\ ChannelNetwork.h\ ChannelNetwork_Altitude.h\ ChannelNetwork_Distance.h\ D8_Flow_Analysis.h\ MLB_Interface.h\ Strahler.h\ Watersheds.h\ Watersheds_ext.h libta_channels_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) --foreign src/modules/terrain_analysis/ta_channels/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/terrain_analysis/ta_channels/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libta_channels.la: $(libta_channels_la_OBJECTS) $(libta_channels_la_DEPENDENCIES) $(EXTRA_libta_channels_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libta_channels_la_OBJECTS) $(libta_channels_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChannelNetwork.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChannelNetwork_Altitude.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChannelNetwork_Distance.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/D8_Flow_Analysis.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Strahler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Watersheds.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Watersheds_ext.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/terrain_analysis/ta_channels/Watersheds.cpp0000664000175000017500000001575412565125414026512 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Watersheds.cpp 2447 2015-03-19 14:43:42Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // Watersheds.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Watersheds.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWatersheds::CWatersheds(void) { Set_Name(_TL("Watershed Basins")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description(_TL("")); Parameters.Add_Grid( NULL, "ELEVATION" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "CHANNELS" , _TL("Channel Network"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "SINKROUTE" , _TL("Sink Route"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL, "BASINS" , _TL("Watershed Basins"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL, "MINSIZE" , _TL("Min. Size"), _TL("Minimum size of basin (cells)"), PARAMETER_TYPE_Int ); } //--------------------------------------------------------- CWatersheds::~CWatersheds(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define NO_BASIN -1 //--------------------------------------------------------- bool CWatersheds::On_Execute(void) { int x, y, nCells, nCells_Min, nBasins; sLong n; CSG_Grid *pDTM, *pSeed, *pRoute; //----------------------------------------------------- pDTM = Parameters("ELEVATION")->asGrid(); pSeed = Parameters("CHANNELS" )->asGrid(); pRoute = Parameters("SINKROUTE")->asGrid(); nCells_Min = Parameters("MINSIZE" )->asInt(); m_pBasins = Parameters("BASINS" )->asGrid(); m_pBasins->Set_NoData_Value(NO_BASIN); m_pBasins->Assign_NoData(); if( !pDTM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } m_Direction.Create(m_pBasins, SG_DATATYPE_Char); for(y=0; yis_NoData(x, y) ) { m_Direction.Set_NoData(x, y); } else { if( !pRoute || (n = pRoute->asChar(x, y)) <= 0 ) { n = pDTM->Get_Gradient_NeighborDir(x, y); } m_Direction.Set_Value(x, y, (int)(n < 0 ? -1 : (n + 4) % 8)); } } } //----------------------------------------------------- for(n=0, m_nBasins=0; nGet_Sorted(n, x, y, true, false); if( !pSeed->is_NoData(x, y) && pSeed->asInt(x, y) < 0 ) { m_nBasins++; if( (nCells = Get_Basin(x, y)) < nCells_Min ) { nBasins = m_nBasins - 1; m_nBasins = NO_BASIN; Get_Basin(x, y); m_nBasins = nBasins; } } } //----------------------------------------------------- m_Direction.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CWatersheds::Get_Basin(int x, int y) { int i, ix, iy, nCells; if( m_pBasins->is_NoData(x, y) && !m_Direction.is_NoData(x, y) ) { m_pBasins->Set_Value(x, y, m_nBasins); for(i=0, nCells=1; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix,iy) && m_Direction.asInt(ix, iy) == i ) { nCells += Get_Basin(ix, iy); } } return( nCells ); } return( -1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_channels/ChannelNetwork.h0000664000175000017500000001153612565125414026762 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ChannelNetwork.h 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // ChannelNetwork.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ChannelNetwork_H #define HEADER_INCLUDED__ChannelNetwork_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class ta_channels_EXPORT CChannelNetwork : public CSG_Module_Grid { public: CChannelNetwork(void); virtual ~CChannelNetwork(void); protected: virtual bool On_Execute (void); private: int *Direction, Direction_Buffer, minLength, maxDivCells; CSG_Grid *pDTM, *pStart, *pTrace, *pConvergence, *pChannels, *pChannelRoute; CSG_Shapes *pShapes; void Set_Route_Standard (int x, int y); void Set_Route_Weighted (int x, int y, CSG_Grid *pWeight, double Weight_Threshold); void Set_Channel_Route (int x, int y); void Set_Channel_Order (int x, int y); void Set_Channel_Mouth (int x, int y); void Set_Vector (int x, int y, int ID); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ChannelNetwork_H saga-2.2.3/src/modules/terrain_analysis/ta_channels/MLB_Interface.cpp0000664000175000017500000001160412565125414026761 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Channels") ); case MLB_INFO_Category: return( _TL("Terrain Analysis") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Olaya (c) 2002-4") ); case MLB_INFO_Description: return( _TL("Tools for (grid based) digital terrain analysis.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Terrain Analysis|Channels") ); } } //--------------------------------------------------------- #include "ChannelNetwork.h" #include "Watersheds.h" #include "Watersheds_ext.h" #include "ChannelNetwork_Altitude.h" #include "ChannelNetwork_Distance.h" #include "D8_Flow_Analysis.h" #include "Strahler.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CChannelNetwork ); case 1: return( new CWatersheds ); case 2: return( new CWatersheds_ext ); case 3: return( new CChannelNetwork_Altitude ); case 4: return( new CChannelNetwork_Distance ); case 5: return( new CD8_Flow_Analysis ); case 6: return( new CStrahler ); case 7: return( new CValley_Depth ); default: return( NULL ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/terrain_analysis/ta_channels/Makefile.am0000664000175000017500000000154512565125414025722 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 911 2011-02-14 16:38:15Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libta_channels.la libta_channels_la_SOURCES =\ ChannelNetwork.cpp\ ChannelNetwork_Altitude.cpp\ ChannelNetwork_Distance.cpp\ D8_Flow_Analysis.cpp\ MLB_Interface.cpp\ Strahler.cpp\ Watersheds.cpp\ Watersheds_ext.cpp\ ChannelNetwork.h\ ChannelNetwork_Altitude.h\ ChannelNetwork_Distance.h\ D8_Flow_Analysis.h\ MLB_Interface.h\ Strahler.h\ Watersheds.h\ Watersheds_ext.h libta_channels_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/terrain_analysis/ta_channels/MLB_Interface.h0000664000175000017500000000771612565125414026437 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_channels_H #define HEADER_INCLUDED__ta_channels_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef ta_channels_EXPORTS #define ta_channels_EXPORT _SAGA_DLL_EXPORT #else #define ta_channels_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ta_channels_H saga-2.2.3/src/modules/terrain_analysis/ta_channels/Strahler.h0000664000175000017500000000323312565125414025617 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Strahler.h 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /******************************************************************************* Strahler.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ //--------------------------------------------------------- #ifndef HEADER_INCLUDED__RGB_Composite_H #define HEADER_INCLUDED__RGB_Composite_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CStrahler : public CSG_Module_Grid { private: CSG_Grid *m_pDEM; CSG_Grid *m_pStrahler; int getStrahlerOrder(int, int); public: CStrahler(void); virtual ~CStrahler(void); protected: virtual bool On_Execute(void); }; #endif // #ifndef HEADER_INCLUDED__Strahler_H saga-2.2.3/src/modules/terrain_analysis/ta_channels/D8_Flow_Analysis.cpp0000664000175000017500000003426712565125414027506 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: D8_Flow_Analysis.cpp 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // D8_Flow_Analysis.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "D8_Flow_Analysis.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define NODE_SPRING 1 #define NODE_JUNCTION 2 #define NODE_OUTLET 3 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CD8_Flow_Analysis::CD8_Flow_Analysis(void) { //----------------------------------------------------- Set_Name (_TL("Channel Network and Drainage Basins")); Set_Author (SG_T("O.Conrad (c) 2003")); Set_Description (_TW( "Deterministic 8 based flow network analysis\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "DIRECTION" , _TL("Flow Direction"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, true, SG_DATATYPE_Char ); Parameters.Add_Grid( NULL , "CONNECTION" , _TL("Flow Connectivity"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, true, SG_DATATYPE_Char ); Parameters.Add_Grid( NULL , "ORDER" , _TL("Strahler Order"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, true, SG_DATATYPE_Short ); Parameters.Add_Grid( NULL , "BASIN" , _TL("Drainage Basins"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, true, SG_DATATYPE_Short ); Parameters.Add_Shapes( NULL , "SEGMENTS" , _TL("Channels"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "BASINS" , _TL("Drainage Basins"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "NODES" , _TL("Junctions"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "THRESHOLD" , _TL("Threshold"), _TL("Strahler order to begin a channel."), PARAMETER_TYPE_Int, 5, 1, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CD8_Flow_Analysis::On_Execute(void) { CSG_Grid Dir, Order, Basins; m_pDEM = Parameters("DEM") ->asGrid(); m_pDir = Parameters("DIRECTION") ->asGrid(); if( !m_pDir ) { m_pDir = &Dir ; Dir .Create(*Get_System(), SG_DATATYPE_Char ); Dir .Set_Name(_TL("Flow Direction" )); } m_pOrder = Parameters("ORDER") ->asGrid(); if( !m_pOrder ) { m_pOrder = &Order ; Order .Create(*Get_System(), SG_DATATYPE_Short); Order .Set_Name(_TL("Strahler Order" )); } m_pBasins = Parameters("BASIN") ->asGrid(); if( !m_pBasins ) { m_pBasins = &Basins; Basins.Create(*Get_System(), SG_DATATYPE_Short); Basins.Set_Name(_TL("Drainage Basins")); } m_Threshold = Parameters("THRESHOLD") ->asInt(); //----------------------------------------------------- Get_Direction(); Get_Order(); Get_Nodes(); Get_Basins(); Get_Segments(); //----------------------------------------------------- m_pOrder->Add(1 - m_Threshold); m_Nodes.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CD8_Flow_Analysis::Get_Direction(void) { Process_Set_Text(_TL("Flow Direction")); m_pDir->Set_NoData_Value(-1); CSG_Grid *pCon = Parameters("CONNECTION") ->asGrid(); if( pCon ) { pCon->Assign(0.0); } for(int y=0; yGet_Gradient_NeighborDir(x, y)) >= 0 && m_pDEM->is_InGrid(ix = Get_xTo(i, x), iy = Get_yTo(i, y)) ) { m_pDir->Set_Value(x, y, i); if( pCon ) { pCon->Add_Value(ix, iy, 1); } } else { m_pDir->Set_NoData(x, y); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CD8_Flow_Analysis::Get_Order(void) { Process_Set_Text(_TL("Stream Order")); m_pOrder->Set_NoData_Value_Range(1 - m_Threshold, 0); m_pOrder->Assign(0.0); for(int y=0; yis_NoData(x, y) ) { Get_Order(x, y); } } } } //--------------------------------------------------------- int CD8_Flow_Analysis::Get_Order(int x, int y) { int Order = m_pOrder->asInt(x, y); if( Order == 0 ) { int i, ix, iy, n; for(i=0, n=0, Order=1; i<8; i++) { if( Get_System()->Get_Neighbor_Pos(i + 4, x, y, ix, iy) && m_pDir->asInt(ix, iy) == i ) { int iOrder = Get_Order(ix, iy); if( Order < iOrder ) { Order = iOrder; n = 1; } else if( Order == iOrder ) { n++; } } } if( n > 1 ) { Order++; } m_pOrder->Set_Value(x, y, Order); } return( Order ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CD8_Flow_Analysis::Get_Nodes(void) { Process_Set_Text(_TL("Junctions")); CSG_Shapes *pNodes = Parameters("NODES")->asShapes(); if( pNodes ) { pNodes ->Create(SHAPE_TYPE_Point, _TL("Junctions"), NULL, SG_VERTEX_TYPE_XYZ); pNodes ->Add_Field(_TL("NODE_ID") , SG_DATATYPE_Int); pNodes ->Add_Field(_TL("TYPE") , SG_DATATYPE_String); } m_Nodes.Create(*Get_System(), SG_DATATYPE_Int); m_pBasins->Set_NoData_Value(0); m_pBasins->Assign_NoData(); for(int y=0, nNodes=0, nBasins=0; yasInt(x, y); if( Order >= m_Threshold ) { if( (i = m_pDir->asInt(x, y)) >= 0 ) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( !m_Nodes.asInt(ix, iy) && m_pOrder->asInt(ix, iy) > Order && m_pDir->asInt(ix, iy) >= 0 ) { Set_Node(ix, iy, ++nNodes, NODE_JUNCTION, pNodes ? pNodes->Add_Shape() : NULL); } if( Order == m_Threshold ) { bool bSpring = true; for(i=0; i<8 && bSpring; i++) { if( Get_System()->Get_Neighbor_Pos(i + 4, x, y, ix, iy) && m_pDir->asInt(ix, iy) == i ) { bSpring = m_pOrder->asInt(ix, iy) < m_Threshold; } } if( bSpring ) { Set_Node(x, y, ++nNodes, NODE_SPRING, pNodes ? pNodes->Add_Shape() : NULL); } } } else { Set_Node(x, y, ++nNodes, NODE_OUTLET, pNodes ? pNodes->Add_Shape() : NULL); m_pBasins->Set_Value(x, y, ++nBasins); } } } } } //--------------------------------------------------------- void CD8_Flow_Analysis::Set_Node(int x, int y, int id, int type, CSG_Shape *pNode) { m_Nodes.Set_Value(x, y, id); if( pNode ) { pNode->Set_Value(0, id); pNode->Set_Value(1, type == NODE_SPRING ? _TL("Spring") : type == NODE_OUTLET ? _TL("Outlet") : _TL("Junction")); pNode->Add_Point(Get_System()->Get_Grid_to_World(x, y)); pNode->Set_Z(m_pDEM->asDouble(x, y), 0); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CD8_Flow_Analysis::Get_Basins(void) { Process_Set_Text(_TL("Drainage Basins")); for(int y=0; yasShapes(); if( pBasins ) { bool bResult; SG_RUN_MODULE(bResult, "shapes_grid", 6, pModule->Get_Parameters()->Set_Parameter(SG_T("GRID") , m_pBasins) && pModule->Get_Parameters()->Set_Parameter(SG_T("POLYGONS"), pBasins) ) pBasins->Set_Name(_TL("Drainage Basins")); } } //--------------------------------------------------------- int CD8_Flow_Analysis::Get_Basin(int x, int y) { int i, Basin = m_pBasins->asInt(x, y); if( Basin <= 0 && (i = m_pDir->asInt(x, y)) >= 0 && (Basin = Get_Basin(Get_xTo(i, x), Get_yTo(i, y))) > 0 ) { m_pBasins->Set_Value(x, y, Basin); } return( Basin ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CD8_Flow_Analysis::Get_Segments(void) { Process_Set_Text(_TL("Channels")); m_pSegments = Parameters("SEGMENTS")->asShapes(); m_pSegments ->Create(SHAPE_TYPE_Line, _TL("Channels"), NULL, SG_VERTEX_TYPE_XYZ); m_pSegments ->Add_Field(SG_T("SEGMENT_ID") , SG_DATATYPE_Int); m_pSegments ->Add_Field(SG_T("NODE_A") , SG_DATATYPE_Int); m_pSegments ->Add_Field(SG_T("NODE_B") , SG_DATATYPE_Int); m_pSegments ->Add_Field(SG_T("BASIN") , SG_DATATYPE_Int); m_pSegments ->Add_Field(SG_T("ORDER") , SG_DATATYPE_Int); m_pSegments ->Add_Field(SG_T("ORDER_CELL") , SG_DATATYPE_Int); m_pSegments ->Add_Field(SG_T("LENGTH") , SG_DATATYPE_Double); for(int y=0; yasInt(x, y); if( i >= 0 ) { CSG_Shape *pSegment = m_pSegments->Add_Shape(); pSegment->Set_Value(0, m_pSegments->Get_Count()); // SEGMENT_ID pSegment->Set_Value(1, m_Nodes.asInt(x, y)); // NODE_A pSegment->Set_Value(3, m_pBasins->asInt(x, y)); // BASIN pSegment->Set_Value(4, m_pOrder->asInt(x, y) + 1 - m_Threshold); // ORDER pSegment->Set_Value(5, m_pOrder->asInt(x, y)); // ORDER_CELL pSegment->Add_Point(Get_System()->Get_Grid_to_World(x, y)); pSegment->Set_Z(m_pDEM->asDouble(x, y), pSegment->Get_Point_Count() - 1); do { x += Get_xTo(i); y += Get_yTo(i); pSegment->Add_Point(Get_System()->Get_Grid_to_World(x, y)); pSegment->Set_Z(m_pDEM->asDouble(x, y), pSegment->Get_Point_Count() - 1); if( m_Nodes.asInt(x, y) ) { pSegment->Set_Value(2, m_Nodes.asInt(x, y)); // NODE_B pSegment->Set_Value(6, ((CSG_Shape_Line *)pSegment)->Get_Length()); // LENGTH return; } } while( (i = m_pDir->asInt(x, y)) >= 0 ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/terrain_analysis/ta_channels/ChannelNetwork_Distance.cpp0000664000175000017500000004577312565125414031141 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ChannelNetwork_Distance.cpp 2342 2014-11-26 13:41:35Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ta_channels // // // //-------------------------------------------------------// // // // ChannelNetwork_Distance.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ChannelNetwork_Distance.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CChannelNetwork_Distance::CChannelNetwork_Distance(void) { //----------------------------------------------------- Set_Name (_TL("Overland Flow Distance to Channel Network")); Set_Author (SG_T("O.Conrad (c) 2001-14")); Set_Description (_TW( "This module calculates overland flow distances to a channel network " "based on gridded digital elevation data and channel network information. " "The flow algorithm may be either Deterministic 8 (O'Callaghan & Mark 1984) " "or Multiple Flow Direction (Freeman 1991). Sediment Delivery Rates (SDR) " "according to Ali & De Boer (2010) can be computed optionally. " "\n\nReferences:\n" "- Ali, K. F., De Boer, D. H. (2010): Spatially distributed erosion and sediment yield modeling in the upper Indus River basin." " Water Resources Research, 46(8), W08504. doi:10.1029/2009WR008762\n" "- Freeman, G.T., 1991: Calculating catchment area with divergent flow based on a regular grid." " Computers and Geosciences, 17:413-22.\n" "- O'Callaghan, J.F., Mark, D.M., 1984: The extraction of drainage networks from digital elevation data." " Computer Vision, Graphics and Image Processing, 28:323-344.\n" "- Nobre, A.D., Cuartas, L.A., Hodnett, M., Renno, C.D., Rodrigues, G., Silveira, A., Waterloo, M., Saleska S. (2011): Height Above the Nearest Drainage - a hydrologically relevant new terrain model." " Journal of Hydrology, Vol. 404, Issues 1-2, pp. 13-29, ISSN 0022-1694, 10.1016/j.jhydrol.2011.03.051." " online\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation"), _TL("A grid that contains elevation data."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CHANNELS" , _TL("Channel Network"), _TW("A grid providing information about the channel network. It is assumed that no-data cells are not part " "of the channel network. Vice versa all others cells are recognised as channel network members."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "ROUTE" , _TL("Preferred Routing"), _TL("Downhill flow is bound to preferred routing cells, where these are not no-data. Helps to model e.g. small ditches, that are not well represented in the elevation data."), PARAMETER_INPUT_OPTIONAL ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DISTANCE" , _TL("Overland Flow Distance"), _TW("The overland flow distance in map units. " "It is assumed that the (vertical) elevation data use the same units as the (horizontal) grid coordinates."), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "DISTVERT" , _TL("Vertical Overland Flow Distance"), _TL("This is the vertical component of the overland flow"), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "DISTHORZ" , _TL("Horizontal Overland Flow Distance"), _TL("This is the horizontal component of the overland flow"), PARAMETER_OUTPUT ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "TIME" , _TL("Flow Travel Time"), _TL("flow travel time to channel expressed in hours based on Manning's Equation"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "SDR" , _TL("Sediment Yield Delivery Ratio"), _TL("This is the horizontal component of the overland flow"), PARAMETER_OUTPUT_OPTIONAL ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "FIELDS" , _TL("Fields"), _TL("If set, output is given about the number of fields a flow path visits downhill. For D8 only."), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "PASSES" , _TL("Fields Visited"), _TL("Number of fields a flow path visits downhill starting at a cell. For D8 only."), PARAMETER_OUTPUT, true, SG_DATATYPE_Short ); //----------------------------------------------------- Parameters.Add_Choice( NULL , "METHOD" , _TL("Flow Algorithm"), _TL("Choose a flow routing algorithm that shall be used for the overland flow distance calculation:\n- D8\n- MFD"), CSG_String::Format(SG_T("%s|%s|"), _TL("D8"), _TL("MFD") ), 1 ); Parameters.Add_Value( NULL , "FLOW_B" , _TL("Beta"), _TL("catchment specific parameter for sediment delivery ratio calculation"), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Grid_or_Const( NULL , "FLOW_K" , _TL("Manning-Strickler Coefficient"), _TL("Manning-Strickler coefficient for flow travel time estimation (reciprocal of Manning's Roughness Coefficient)"), 20.0, 0.0, true ); Parameters.Add_Grid_or_Const( NULL , "FLOW_R" , _TL("Flow Depth"), _TL("flow depth [m] for flow travel time estimation"), 0.05, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CChannelNetwork_Distance::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Get_Parameter("FIELDS")->Set_Enabled(pParameter->asInt() == 0); pParameters->Get_Parameter("PASSES")->Set_Enabled(pParameter->asInt() == 0 && pParameters->Get_Parameter("FIELDS")->asGrid() != NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "FIELDS") ) { pParameters->Get_Parameter("PASSES")->Set_Enabled(pParameter->is_Enabled() && pParameter->asGrid() != NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "TIME") || !SG_STR_CMP(pParameter->Get_Identifier(), "SDR") ) { bool bEnable = pParameters->Get_Parameter("TIME")->asGrid() != NULL || pParameters->Get_Parameter("SDR" )->asGrid() != NULL; pParameters->Get_Parameter("FLOW_B")->Set_Enabled(bEnable); pParameters->Get_Parameter("FLOW_K")->Set_Enabled(bEnable); pParameters->Get_Parameter("FLOW_R")->Set_Enabled(bEnable); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CChannelNetwork_Distance::On_Execute(void) { CSG_Grid *pChannels; //----------------------------------------------------- m_pDEM = Parameters("ELEVATION")->asGrid(); m_pRoute = Parameters("ROUTE" )->asGrid(); pChannels = Parameters("CHANNELS" )->asGrid(); m_pDistance = Parameters("DISTANCE" )->asGrid(); m_pDistVert = Parameters("DISTVERT" )->asGrid(); m_pDistHorz = Parameters("DISTHORZ" )->asGrid(); m_pTime = Parameters("TIME" )->asGrid(); m_pSDR = Parameters("SDR" )->asGrid(); m_Flow_B = Parameters("FLOW_B" )->asDouble(); m_Flow_K = Parameters("FLOW_K" )->asDouble(); m_Flow_R = Parameters("FLOW_R" )->asDouble(); m_pFlow_K = Parameters("FLOW_K" )->asGrid(); m_pFlow_R = Parameters("FLOW_R" )->asGrid(); int Method = Parameters("METHOD" )->asInt(); //----------------------------------------------------- if( m_pDistance ) m_pDistance->Assign_NoData(); if( m_pDistVert ) m_pDistVert->Assign_NoData(); if( m_pDistHorz ) m_pDistHorz->Assign_NoData(); if( m_pTime ) m_pTime ->Assign_NoData(); if( m_pSDR ) m_pSDR ->Assign_NoData(); switch( Method ) { default: Initialize_D8 (); break; case 1: Initialize_MFD(); break; } if( !m_pDEM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } //----------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y, false, true) && !(pChannels->is_NoData(x, y) && m_pDistance->is_NoData(x, y)) ) { if( !pChannels->is_NoData(x, y) ) { if( m_pDistance ) m_pDistance->Set_Value(x, y, 0.0); if( m_pDistVert ) m_pDistVert->Set_Value(x, y, 0.0); if( m_pDistHorz ) m_pDistHorz->Set_Value(x, y, 0.0); if( m_pTime ) m_pTime ->Set_Value(x, y, 0.0); if( m_pSDR ) m_pSDR ->Set_Value(x, y, 0.0); if( m_pFields ) m_pPasses ->Set_Value(x, y, 0.0); } switch( Method ) { default: Execute_D8 (x, y); break; case 1: Execute_MFD(x, y); break; } } } //----------------------------------------------------- m_Dir.Destroy(); for(int i=0; i<=8; i++) { m_Flow[i].Destroy(); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CChannelNetwork_Distance::Get_Travel_Time(int x, int y, int i) { double dz = m_pDEM->asDouble(Get_xTo(i, x), Get_yTo(i, y)) - m_pDEM->asDouble(x, y); double dx = Get_Length(i); double k = m_pFlow_K && !m_pFlow_K->is_NoData(x, y) ? m_pFlow_K->asDouble(x, y) : m_Flow_K; double R = m_pFlow_R && !m_pFlow_R->is_NoData(x, y) ? m_pFlow_R->asDouble(x, y) : m_Flow_R; double v = k * pow(R, 2.0 / 3.0) * sqrt(dz / dx); // [m / s], simplified Manning equation return( dx / (v * 3600.0) ); // return travel time in hours } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CChannelNetwork_Distance::Initialize_D8(void) { m_Dir.Create(*Get_System(), SG_DATATYPE_Char); if( (m_pFields = Parameters("FIELDS")->asGrid()) != NULL ) { m_pPasses = Parameters("PASSES")->asGrid(); m_pPasses ->Set_NoData_Value(-1.0); m_pPasses ->Assign_NoData(); } #pragma omp parallel for for(int y=0; yis_NoData(x, y) ) { Initialize_D8(x, y); } } } } //--------------------------------------------------------- void CChannelNetwork_Distance::Initialize_D8(int x, int y) { int i, iMax, iRoute; double z, dz, dzMax, dzRoute; for(i=0, iMax=-1, dzMax=0.0, iRoute=-1, dzRoute=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && (dz = (z - m_pDEM->asDouble(ix, iy)) / Get_Length(i)) > 0.0 ) { if( dz > dzMax ) { iMax = i; dzMax = dz; } if( m_pRoute && !m_pRoute->is_NoData(ix, iy) && dz > dzRoute ) { iRoute = i; dzRoute = dz; } } } m_Dir.Set_Value(x, y, iRoute >= 0 ? iRoute : iMax); } //--------------------------------------------------------- void CChannelNetwork_Distance::Execute_D8(int x, int y) { int nPasses = m_pFields ? m_pPasses->asInt (x, y) : 0; double Field = m_pFields ? m_pFields->asDouble(x, y) : 0; double sz = m_pDistVert->asDouble(x, y); double sx = m_pDistHorz->asDouble(x, y); double sd = m_pDistance->asDouble(x, y); for(int i=0; i<8; i++) { int ix = Get_xFrom(i, x); int iy = Get_yFrom(i, y); if( m_pDEM->is_InGrid(ix, iy) && m_Dir.asInt(ix, iy) == i ) { double dz = m_pDEM->asDouble(ix, iy) - m_pDEM->asDouble(x, y); double dx = Get_Length(i); if( m_pDistVert ) m_pDistVert->Set_Value(ix, iy, sz + dz); if( m_pDistHorz ) m_pDistHorz->Set_Value(ix, iy, sx + dx); if( m_pDistance ) m_pDistance->Set_Value(ix, iy, sd + sqrt(dz*dz + dx*dx)); if( m_pTime ) m_pTime ->Set_Value(ix, iy, m_pTime->asDouble(x, y) + Get_Travel_Time(x, y, i)); if( m_pSDR ) m_pSDR ->Set_Value(ix, iy, m_pSDR ->asDouble(x, y) + Get_Travel_Time(x, y, i)); if( m_pFields ) m_pPasses ->Set_Value(ix, iy, Field != m_pFields->asDouble(ix, iy) ? nPasses + 1 : nPasses); } } if( m_pSDR ) { m_pSDR->Set_Value(x, y, exp(-m_Flow_B * m_pSDR->asDouble(x, y))); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CChannelNetwork_Distance::Initialize_MFD(void) { m_pFields = NULL; m_pPasses = NULL; for(int i=0; i<=8; i++) { m_Flow[i].Create(*Get_System(), SG_DATATYPE_Float); } #pragma omp parallel for for(int y=0; yis_NoData(x, y) ) { Initialize_MFD(x, y); } } } } //--------------------------------------------------------- void CChannelNetwork_Distance::Initialize_MFD(int x, int y) { const double MFD_Convergence = 1.1; double Flow[8], dz, zSum = 0.0, z = m_pDEM->asDouble(x, y); if( m_pRoute ) { for(int i=0, ix, iy; i<8; i++) { if( m_pDEM->is_InGrid(ix=Get_xTo(i, x), iy=Get_yTo(i, y)) && !m_pRoute->is_NoData(ix, iy) && (dz = z - m_pDEM->asDouble(ix, iy)) > 0.0 ) { zSum += (Flow[i] = pow(dz / Get_Length(i), MFD_Convergence)); } else { Flow[i] = 0.0; } } } if( zSum == 0.0 ) { for(int i=0, ix, iy; i<8; i++) { if( m_pDEM->is_InGrid(ix=Get_xTo(i, x), iy=Get_yTo(i, y)) && (dz = z - m_pDEM->asDouble(ix, iy)) > 0.0 ) { zSum += (Flow[i] = pow(dz / Get_Length(i), MFD_Convergence)); } else { Flow[i] = 0.0; } } } if( zSum > 0.0 ) { m_Flow[8].Set_Value(x, y, zSum); for(int i=0; i<8; i++) { if( Flow[i] > 0.0 ) { m_Flow[i].Set_Value(x, y, Flow[i] / zSum); } } } } //--------------------------------------------------------- void CChannelNetwork_Distance::Execute_MFD(int x, int y) { double df = m_Flow[8].asDouble(x, y); if( df > 0.0 ) { if( m_pDistance ) m_pDistance->Mul_Value(x, y, 1.0 / df); if( m_pDistVert ) m_pDistVert->Mul_Value(x, y, 1.0 / df); if( m_pDistHorz ) m_pDistHorz->Mul_Value(x, y, 1.0 / df); if( m_pTime ) m_pTime ->Mul_Value(x, y, 1.0 / df); if( m_pSDR ) m_pSDR ->Mul_Value(x, y, 1.0 / df); } double sz = m_pDistVert->asDouble(x, y); double sx = m_pDistHorz->asDouble(x, y); double sd = m_pDistance->asDouble(x, y); for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && (df = m_Flow[(i + 4) % 8].asDouble(ix, iy)) > 0.0 ) { double dz = m_pDEM->asDouble(ix, iy) - m_pDEM->asDouble(x, y); double dx = Get_Length(i); double dt = m_pTime || m_pSDR ? Get_Travel_Time(x, y, i) : 1.0; if( m_pDistance->is_NoData(ix, iy) ) { m_Flow[8].Set_Value(ix, iy, df); if( m_pDistVert ) m_pDistVert->Set_Value(ix, iy, df * (sz + dz)); if( m_pDistHorz ) m_pDistHorz->Set_Value(ix, iy, df * (sx + dx)); if( m_pDistance ) m_pDistance->Set_Value(ix, iy, df * (sd + sqrt(dz*dz + dx*dx))); if( m_pTime ) m_pTime ->Set_Value(ix, iy, df * (m_pTime->asDouble(x, y) + dt)); if( m_pSDR ) m_pSDR ->Set_Value(ix, iy, df * (m_pSDR ->asDouble(x, y) + dt)); } else { m_Flow[8].Add_Value(ix, iy, df); if( m_pDistVert ) m_pDistVert->Add_Value(ix, iy, df * (sz + dz)); if( m_pDistHorz ) m_pDistHorz->Add_Value(ix, iy, df * (sx + dx)); if( m_pDistance ) m_pDistance->Add_Value(ix, iy, df * (sd + sqrt(dz*dz + dx*dx))); if( m_pTime ) m_pTime ->Add_Value(ix, iy, df * (m_pTime->asDouble(x, y) + dt)); if( m_pSDR ) m_pSDR ->Add_Value(ix, iy, df * (m_pSDR ->asDouble(x, y) + dt)); } } } if( m_pSDR ) { m_pSDR->Set_Value(x, y, exp(-m_Flow_B * m_pSDR->asDouble(x, y))); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/0000775000175000017500000000000012634325751017125 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/table/table_calculus/0000775000175000017500000000000012634325751022107 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/table/table_calculus/table_pca.h0000664000175000017500000001063012565125412024165 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_pca.h 1928 2014-01-10 12:10:05Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_calculus // // // //-------------------------------------------------------// // // // table_pca.h // // // // Copyright (C) 2010 by // // Jan Papmeier // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_pca_H #define HEADER_INCLUDED__table_pca_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_PCA : public CSG_Module { public: CTable_PCA(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_Method, m_nFeatures, *m_Features; CSG_Table *m_pTable; bool Get_Fields (void); bool is_NoData (int iElement); double Get_Value (int iFeature, int iElement); bool Get_Matrix (CSG_Matrix &Matrix); bool Get_Components (CSG_Matrix &Eigen_Vectors, CSG_Vector &Eigen_Values); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_pca_H saga-2.2.3/src/modules/table/table_calculus/table_field_analyzer.cpp0000664000175000017500000001667712565125412026766 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_field_analyzer.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // table_field_analyzer.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_field_analyzer.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Field_Extreme::CTable_Field_Extreme(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Find Field of Extreme Value")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Identifies from the selected attributes that one, " "which has the maximum or respectively the minimum value. " )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("") ); Parameters.Add_Table_Field( pNode , "EXTREME_ID" , _TL("Attribute"), _TL(""), true ); Parameters.Add_Table_Field( pNode , "EXTREME_VALUE" , _TL("Value"), _TL(""), true ); Parameters.Add_Table( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "TYPE" , _TL("TYPE"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("minimum"), _TL("maximum") ), 1 ); Parameters.Add_Choice( NULL , "IDENTIFY" , _TL("Attribute Identification"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("name"), _TL("index") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Field_Extreme::On_Execute(void) { //----------------------------------------------------- int *Fields = (int *)Parameters("FIELDS")->asPointer(); int nFields = Parameters("FIELDS")->asInt (); if( nFields <= 1 ) { Error_Set(_TL("needs at least two attributes in selection")); return( false ); } //----------------------------------------------------- CSG_Table *pTable = Parameters("INPUT")->asTable(); if( !pTable->is_Valid() ) { Error_Set(_TL("invalid table")); return( false ); } if( Parameters("OUTPUT")->asTable() && Parameters("OUTPUT")->asTable() != pTable ) { pTable = Parameters("OUTPUT")->asTable(); pTable ->Create( *Parameters("INPUT")->asTable()); pTable ->Set_Name(Parameters("INPUT")->asTable()->Get_Name()); } //----------------------------------------------------- int fID, fValue; bool bMaximum = Parameters("TYPE" )->asInt() == 1; bool bName = Parameters("IDENTIFY")->asInt() == 0; if( (fID = Parameters("EXTREME_ID")->asInt()) < 0 ) { fID = pTable->Get_Field_Count(); pTable->Add_Field(bMaximum ? "MAX_FIELD" : "MIN_FIELD", SG_DATATYPE_String); } else if( bName == true && pTable->Get_Field_Type(fID) != SG_DATATYPE_String ) { pTable->Set_Field_Type(fID, SG_DATATYPE_String); } else if( bName == false && pTable->Get_Field_Type(fID) != SG_DATATYPE_Int ) { pTable->Set_Field_Type(fID, SG_DATATYPE_Int); } if( (fValue = Parameters("EXTREME_VALUE")->asInt()) < 0 ) { fValue = pTable->Get_Field_Count(); pTable->Add_Field(bMaximum ? "MAX_VALUE" : "MIN_VALUE", SG_DATATYPE_Double); } //----------------------------------------------------- for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); int xField = Fields[0]; double xValue = pRecord->asDouble(xField); for(int iField=1; iFieldasDouble(Fields[iField])) || (!bMaximum && xValue > pRecord->asDouble(Fields[iField])) ) { xField = Fields[iField]; xValue = pRecord->asDouble(xField); } } if( bName ) pRecord->Set_Value(fID, pTable->Get_Field_Name(xField)); else pRecord->Set_Value(fID, xField); pRecord->Set_Value(fValue, xValue); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_calculus/table_field_statistics.h0000664000175000017500000001064312565125412026763 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_field_statistics.h 2345 2014-11-27 11:27:59Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_calculus // // // //-------------------------------------------------------// // // // table_field_statistics.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_field_statistics_H #define HEADER_INCLUDED__table_field_statistics_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Field_Statistics : public CSG_Module { public: CTable_Field_Statistics(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_field_statistics_H saga-2.2.3/src/modules/table/table_calculus/table_field_analyzer.h0000664000175000017500000001004112565125412026406 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_field_analyzer.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // table_field_analyzer.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_field_analyzer_H #define HEADER_INCLUDED__table_field_analyzer_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Field_Extreme : public CSG_Module { public: CTable_Field_Extreme(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_field_analyzer_H saga-2.2.3/src/modules/table/table_calculus/LMFit.h0000664000175000017500000001110312565125412023222 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: LMFit.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // LMFit.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@gwdg.de // // // // contact: Andre Ringeler // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef LMFitH #define LMFitH #include #include #define SWAP(a,b) {temp=(a);(a)=(b);(b)=temp;} using namespace std; class TLMFit{ public: TLMFit (vector Xdata, vector Ydata, vector Param, void (*CfuncP)(double x, vector ca, double &y, vector &dyda, int na)); ~TLMFit (){}; void Fit(); // Accessors: vector< vector > Alpha() const {return alpha;}; vector< vector > Covar() const {return covar;}; double Chisq() const {return chisq;}; vector Param() const {return a;}; int Ndata() const {return ndata;}; int Nparam() const {return nparam;}; double Alamda() const {return alamda;}; private: void gaussj(vector< vector > &a, int m, vector< vector > &b, int n); void covsrt(int mfit); void mrqcof(vector &a, vector< vector > &alpha, vector &beta); void mrqmin(void); double chisq, alamda; vector x, y, a; //x-, y-Values, Fit-Parameters a, Sigmas vector ia; //Use Fit-Parameter for fit (1) or not (0) vector< vector > covar, alpha; //Covarianz-Matrix int ndata, nparam; //Number of Points, Number of Parameters void (*funcP)(double x, vector ca, double &y, vector &dyda, int na); }; class ESingularMatrix {// Error Handling public : int Type; ESingularMatrix (int i); }; #endif saga-2.2.3/src/modules/table/table_calculus/LMFit.cpp0000664000175000017500000002072312565125412023565 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: LMFit.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // LMFit.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@gwdg.de // // // // contact: Andre Ringeler // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "LMFit.h" TLMFit::TLMFit(vector Xdata, vector Ydata, vector Param, void(*CfuncP)(double x, vector ca, double &y, vector < double> &dyda, int na)) { int i, mfit = 0; chisq = 0; alamda = -1; ndata = Xdata.size(); nparam = Param.size(); x.resize(ndata); y.resize(ndata); for (i = 0; i < ndata; i++) { x[i] = Xdata[i]; y[i] = Ydata[i]; } a.resize(nparam); ia.resize(nparam); for (i = 0; i < nparam; i++) { a[i] = Param[i]; ia[i] = 1; if (ia[i]) mfit++; } alpha.resize(mfit); covar.resize(mfit); for (i = 0; i < mfit; i++) { covar[i].resize(mfit); alpha[i].resize(mfit); } funcP = CfuncP; } //---------------------------------------------------------------------------- void TLMFit::Fit(void) { mrqmin(); } void TLMFit::gaussj(vector< vector > &aa, int n, vector< vector < double> > &b, int m) { vector < int> indxc, indxr, ipiv; int i, icol, irow, j, k, l, ll; double big, dum, pivinv, temp, test; indxc.resize(n); indxr.resize(n); ipiv.resize(n); for (j = 0; j < n; j++) ipiv[j] = 0; for (i = 0; i < n; i++) { big = 0.0; for (j = 0; j < n; j++) if (ipiv[j] != 1) for (k = 0; k < n; k++) { if (ipiv[k] == 0) { if (fabs(aa[j][k]) >= big) { big = fabs(aa[j][k]); irow = j; icol = k; } } else if (ipiv[k] > 1) { throw ESingularMatrix(1); } } ++(ipiv[icol]); if (irow != icol) { for (l = 0; l < n; l++) SWAP(aa[irow][l], aa[icol][l]); for (l = 0; l < m; l++) SWAP(b[irow][l], b[icol][l]); } indxr[i] = irow; indxc[i] = icol; if (fabs(aa[icol][icol]) < 1E-300) { throw ESingularMatrix(2); } // else test = aa[icol][icol]; pivinv = 1.0/test; aa[icol][icol] = 1.0; for (l = 0; l < n; l++) aa[icol][l] *= pivinv; for (l = 0; l < m; l++) b[icol][l] *= pivinv; for (ll = 0; ll < n; ll++) if (ll != icol) { dum = aa[ll][icol]; aa[ll][icol] = 0.0; for (l = 0; l < n; l++) aa[ll][l] -= aa[icol][l]*dum; for (l = 0; l < m; l++) b[ll][l] -= b[icol][l]*dum; } } for (l =(n - 1); l > -1; l--) { if (indxr[l] != indxc[l]) for (k = 0; k < n; k++) SWAP(aa[k][indxr[l]], aa[k][indxc[l]]); } } //----------------------------------------------------------------------- void TLMFit::covsrt(int mfit) { int i, j, k; double temp; for (i = mfit; i < nparam; i++) for (j = 0; j < i; j++) covar[i][j] = 0.0; k = mfit; for (j = (nparam - 1); j>-1; j--) { if (ia[j]) { for (i = 0; i < nparam; i++) SWAP(covar[i][k], covar[i][j]); for (i = 0; i < nparam; i++) SWAP(covar[k][i], covar[j][i]); k--; } } } //----------------------------------------------------------------------- void TLMFit::mrqcof(vector &ba, vector< vector > &balpha, vector < double> &bbeta) { vector < double> dyda(nparam, 0); int i, j, k, l, m, mfit = 0; double ymod, wt, dy; for (j = 0; j < nparam; j++) if (ia[j] > 0) mfit++; for (j = 0; j < mfit; j++) { for (k = 0; k <=j; k++) balpha[j][k] = 0.0; bbeta[j] = 0.0; } chisq = 0.0; for (i = 0; i < ndata; i++) { (*funcP)(x[i], ba, ymod, dyda, nparam); dy = y[i] - ymod; for (j=-1, l = 0; l < nparam; l++) { if (ia[l]) { wt = dyda[l]; for (j++, k=-1, m = 0; m <= l; m++) { if (ia[m]) balpha[j][++k] += wt*dyda[m]; } bbeta[j] += dy*wt; } } chisq += dy*dy; } for (j = 1; j < mfit; j++) for (k = 0; k < j; k++) balpha[k][j] = balpha[j][k]; } //----------------------------------------------------------------------- void TLMFit::mrqmin() { static vector < double> atry, beta, da; int j, k, l; static int mfit; static double ochisq; static vector< vector < double> > oneda; if (alamda < 0.0) { atry.resize(nparam); beta.resize(nparam); da.resize(nparam); for (mfit = 0, j = 0; j < nparam; j++) if (ia[j]) mfit++; oneda.resize(mfit); for (unsigned int i = 0; i < oneda.size(); i++) oneda[i].resize(1); alamda = 0.001; mrqcof(a, alpha, beta); ochisq = (chisq); for (j = 0; j < nparam; j++) atry[j] =(a[j]); } for (j = 0; j < mfit; j++) { for (k = 0; k < mfit; k++) covar[j][k] = alpha[j][k]; covar[j][j] = alpha[j][j]*(1.0 + (alamda)); oneda[j][0] = beta[j]; } try {gaussj(covar, mfit, oneda, 1);} catch (ESingularMatrix &E) { throw; } for (j = 0; j < mfit; j++) { da[j] = oneda[j][0]; } if (alamda == 0.0) { covsrt(mfit); return; } for (j = 0, l = 0; l < nparam; l++) if (ia[l]) atry[l] = a[l] + da[j++]; mrqcof(atry, covar, da); if (chisq < ochisq) { alamda *= 0.1; ochisq = (chisq); for (j = 0; j < mfit; j++) { for (k = 0; k < mfit; k++) alpha[j][k] = covar[j][k]; beta[j] = da[j]; } for (j = 0; j < nparam; j++) // Achtung!! in aelteren Versionen war hier ein Fehler a[j] = atry[j]; } else { alamda *= 10.0; chisq = ochisq; } } //---------------------------------------------------------------------------- // Implementation ESinglularMatrix (error handling for singular matrix) //---------------------------------------------------------------------------- ESingularMatrix::ESingularMatrix(int i) { Type = i; } //---------------------------------------------------------------------------- saga-2.2.3/src/modules/table/table_calculus/table_fill_record_gaps.h0000664000175000017500000001152312565125412026722 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_fill_record_gaps.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_calculus // // // //-------------------------------------------------------// // // // table_fill_record_gaps.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_fill_record_gaps_H #define HEADER_INCLUDED__table_fill_record_gaps_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Fill_Record_Gaps : public CSG_Module { public: CTable_Fill_Record_Gaps(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: int m_fOrder; CSG_Table *m_pNoGaps; bool Set_Nearest (int iOffset, int iField, CSG_Table_Record *pA, CSG_Table_Record *pB); bool Set_Linear (int iOffset, int iField, CSG_Table_Record *pA, CSG_Table_Record *pB); bool Set_Spline (int iOffset, int iField, CSG_Table_Record *pAA, CSG_Table_Record *pA, CSG_Table_Record *pB, CSG_Table_Record *pBB); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_fill_record_gaps_H saga-2.2.3/src/modules/table/table_calculus/Makefile.in0000664000175000017500000005670212622651175024165 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/table/table_calculus DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libtable_calculus_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libtable_calculus_la_OBJECTS = Fit.lo LMFit.lo MLB_Interface.lo \ Table_Calculator.lo table_cluster_analysis.lo \ table_field_analyzer.lo table_field_statistics.lo \ table_fill_record_gaps.lo table_mRMR.lo table_pca.lo \ table_running_average.lo libtable_calculus_la_OBJECTS = $(am_libtable_calculus_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libtable_calculus_la_SOURCES) DIST_SOURCES = $(libtable_calculus_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 2345 2014-11-27 11:27:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libtable_calculus.la libtable_calculus_la_SOURCES = \ Fit.cpp\ LMFit.cpp\ MLB_Interface.cpp\ Table_Calculator.cpp\ table_cluster_analysis.cpp\ table_field_analyzer.cpp\ table_field_statistics.cpp\ table_fill_record_gaps.cpp\ table_mRMR.cpp\ table_pca.cpp\ table_running_average.cpp\ Fit.h\ LMFit.h\ MLB_Interface.h\ Table_Calculator.h\ table_cluster_analysis.h\ table_field_analyzer.h\ table_field_statistics.h\ table_fill_record_gaps.h\ table_mRMR.h\ table_pca.h\ table_running_average.h libtable_calculus_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) --foreign src/modules/table/table_calculus/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/table/table_calculus/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libtable_calculus.la: $(libtable_calculus_la_OBJECTS) $(libtable_calculus_la_DEPENDENCIES) $(EXTRA_libtable_calculus_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libtable_calculus_la_OBJECTS) $(libtable_calculus_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Fit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LMFit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Table_Calculator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_cluster_analysis.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_field_analyzer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_field_statistics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_fill_record_gaps.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_mRMR.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_pca.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_running_average.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/table/table_calculus/table_running_average.cpp0000664000175000017500000001436612565125412027141 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_running_average.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // table_running_average.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_running_average.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Running_Average::CTable_Running_Average(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Running Average")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "\n" )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("") ); Parameters.Add_Table( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "COUNT" , _TL("Number of Records"), _TL(""), PARAMETER_TYPE_Int, 10, 2, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Running_Average::On_Execute(void) { int iValue, nValues; CSG_Table *pTable; //----------------------------------------------------- pTable = Parameters("INPUT") ->asTable(); iValue = Parameters("FIELD") ->asInt(); nValues = Parameters("COUNT") ->asInt(); if( Parameters("OUTPUT")->asTable() && Parameters("OUTPUT")->asTable() != pTable ) { pTable = Parameters("OUTPUT") ->asTable(); pTable->Create(*Parameters("INPUT")->asTable()); } //----------------------------------------------------- if( pTable->is_Valid() ) { int i, iLo, iHi, nRange, iAverage; double sValues; iAverage = pTable->Get_Field_Count(); pTable->Add_Field(CSG_String::Format(SG_T("%s [%s]"), pTable->Get_Field_Name(iValue), _TL("Average")), SG_DATATYPE_Double); nRange = nValues / 2; sValues = 0.0; for(iLo=-nValues, i=-nRange, iHi=0; iGet_Count() && Set_Progress(i, pTable->Get_Count() + nRange); iLo++, i++, iHi++) { sValues += pTable->Get_Record(iHi < pTable->Get_Count() ? iHi : pTable->Get_Count() - 1)->asDouble(iValue); if( i < 0 ) { sValues += pTable->Get_Record( 0 )->asDouble(iValue); } else { if( iLo < 0 ) { sValues -= pTable->Get_Record( 0 )->asDouble(iValue); } else if( iLo >= 0 ) { sValues -= pTable->Get_Record(iLo)->asDouble(iValue); } pTable->Get_Record(i)->Set_Value(iAverage, sValues / (double)nValues); } } return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_calculus/table_mRMR.cpp0000664000175000017500000001445312565125412024601 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: mrmr.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_calculus // // // //-------------------------------------------------------// // // // table_mRMR.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_mRMR.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_mRMR::CTable_mRMR(void) { //----------------------------------------------------- Set_Name (_TL("Minimum Redundancy Feature Selection")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "Identify the most relevant features for subsequent classification of tabular data.\n" "\n" ) + CSG_mRMR::Get_Description()); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Table( NULL , "DATA" , _TL("Data"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "CLASS" , _TL("Class Identifier"), _TL("") ); Parameters.Add_Table( NULL , "SELECTION" , _TL("Feature Selection"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "VERBOSE" , _TL("Verbose Output"), _TL("output of intermediate results to execution message window"), PARAMETER_TYPE_Bool, true ); CSG_mRMR::Parameters_Add(&Parameters); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTable_mRMR::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CSG_mRMR::Parameters_Enable(pParameters, pParameter); return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_mRMR::On_Execute(void) { //----------------------------------------------------- CSG_mRMR mRMR; mRMR.Set_Verbose(Parameters("VERBOSE")->asBool()); CSG_Table *pData = Parameters("DATA")->asTable(); if( !mRMR.Set_Data(*pData, Parameters("CLASS")->asInt(), &Parameters) ) { return( false ); } if( !mRMR.Get_Selection(&Parameters) ) { return( false ); } //----------------------------------------------------- CSG_Table *pSelection = Parameters("SELECTION")->asTable(); pSelection->Destroy(); pSelection->Set_Name(CSG_String::Format(SG_T("%s (%s)"), _TL("Feature Selection"), pData->Get_Name())); pSelection->Add_Field("RANK" , SG_DATATYPE_Int); pSelection->Add_Field("INDEX", SG_DATATYPE_Int); pSelection->Add_Field("NAME" , SG_DATATYPE_String); pSelection->Add_Field("SCORE", SG_DATATYPE_Double); for(int i=0; iAdd_Record(); pFeature->Set_Value(0, i + 1); pFeature->Set_Value(1, mRMR.Get_Index(i)); pFeature->Set_Value(2, mRMR.Get_Name (i)); pFeature->Set_Value(3, mRMR.Get_Score(i)); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_calculus/table_field_statistics.cpp0000664000175000017500000001620712625645113027322 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_field_statistics.cpp 2704 2015-11-26 14:46:25Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_calculus // // // //-------------------------------------------------------// // // // table_field_statistics.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_field_statistics.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Field_Statistics::CTable_Field_Statistics(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Field Statistics")); Set_Author (SG_T("V. Wichmann (c) 2014")); Set_Description (_TW( "The modules allows one to calculate statistics (n, min, max, range, sum, " "mean, variance and standard deviation) for attribute fields of tables, " "shapefiles or point clouds.\n\n" )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL("The input table."), PARAMETER_INPUT ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("The (numeric) fields to calculate the statistics for.") ); Parameters.Add_Table( NULL , "STATISTICS" , _TL("Statistics"), _TL("The calculated statistics."), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Field_Statistics::On_Execute(void) { CSG_Table *pTab_in, *pTab_out; int nFeatures, *Features; //----------------------------------------------------- pTab_in = Parameters("TABLE")->asTable(); pTab_out = Parameters("STATISTICS")->asTable(); Features = (int *)Parameters("FIELDS")->asPointer(); nFeatures = Parameters("FIELDS")->asInt (); //----------------------------------------------------- if( !Features || nFeatures <= 0 ) { Error_Set(_TL("No attribute fields selected!")); return( false ); } //----------------------------------------------------- pTab_out->Destroy(); pTab_out->Set_Name(CSG_String::Format(_TL("%s_stats"), pTab_in->Get_Name())); pTab_out->Add_Field(_TL("Field") , SG_DATATYPE_String); pTab_out->Add_Field(_TL("n") , SG_DATATYPE_Long); pTab_out->Add_Field(_TL("min") , SG_DATATYPE_Double); pTab_out->Add_Field(_TL("max") , SG_DATATYPE_Double); pTab_out->Add_Field(_TL("range") , SG_DATATYPE_Double); pTab_out->Add_Field(_TL("sum") , SG_DATATYPE_Double); pTab_out->Add_Field(_TL("mean") , SG_DATATYPE_Double); pTab_out->Add_Field(_TL("variance") , SG_DATATYPE_Double); pTab_out->Add_Field(_TL("stddev") , SG_DATATYPE_Double); //----------------------------------------------------- for(int iFeature=0; iFeatureGet_Field_Type(Features[iFeature])) ) { CSG_Table_Record *pRecord = pTab_out->Add_Record(); pRecord->Set_Value(0, pTab_in->Get_Field_Name(Features[iFeature])); pRecord->Set_Value(1, pTab_in->Get_N(Features[iFeature])); pRecord->Set_Value(2, pTab_in->Get_Minimum(Features[iFeature])); pRecord->Set_Value(3, pTab_in->Get_Maximum(Features[iFeature])); pRecord->Set_Value(4, pTab_in->Get_Range(Features[iFeature])); pRecord->Set_Value(5, pTab_in->Get_Sum(Features[iFeature])); pRecord->Set_Value(6, pTab_in->Get_Mean(Features[iFeature])); pRecord->Set_Value(7, pTab_in->Get_Variance(Features[iFeature])); pRecord->Set_Value(8, pTab_in->Get_StdDev(Features[iFeature])); } else { SG_UI_Msg_Add(CSG_String::Format(_TL("WARNING: skipping non-numeric field '%s'!"), pTab_in->Get_Field_Name(Features[iFeature])), true); } } //----------------------------------------------------- DataObject_Update(pTab_out); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_calculus/Table_Calculator.cpp0000664000175000017500000001647612565125412026024 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Table_Calculator.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* TableCalculator.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Table_Calculator.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Calculator_Base::CTable_Calculator_Base(void) { Set_Author (SG_T("V.Olaya (c) 2004, O.Conrad (c) 2011")); CSG_String s(_TW( "The table calculator calculates a new attribute from existing attributes based on a mathematical formula. " "Attributes are addressed by the character 'f' (for 'field') followed by the field number (i.e.: f1, f2, ..., fn) " "or by the field name in square brackets (e.g.: [Field Name]).\n" "Examples:\n" "sin(f1) * f2 + f3\n" "[Population] / [Area]\n" "\nThe following operators are available for the formula definition:\n" )); s += CSG_Formula::Get_Help_Operators(); Set_Description(s); Parameters.Add_String (NULL, "FORMULA", _TL("Formula") , _TL(""), SG_T("f1 + f2")); Parameters.Add_String (NULL, "NAME" , _TL("Field Name") , _TL(""), SG_T("Calculation")); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Calculator_Base::On_Execute(void) { //----------------------------------------------------- CSG_Table *pTable = Parameters("TABLE")->asTable(); if( !pTable->is_Valid() || pTable->Get_Field_Count() <= 0 || pTable->Get_Record_Count() <= 0 ) { Error_Set(_TL("invalid table")); return( false ); } //----------------------------------------------------- CSG_Formula Formula; int nFields = pTable->Get_Field_Count(); int *Fields = new int[nFields]; if( !Formula.Set_Formula(Get_Formula(Parameters("FORMULA")->asString(), pTable, Fields, nFields)) ) { CSG_String Message; Formula.Get_Error(Message); Error_Set(Message); delete[](Fields); return( false ); } if( nFields == 0 ) { SG_UI_Msg_Add_Error(_TL("No attribute fields specified!")); delete[](Fields); return( false ); } //----------------------------------------------------- if( Parameters("RESULT")->asTable() && Parameters("RESULT")->asTable() != pTable ) { pTable = Parameters("RESULT")->asTable(); pTable->Create(*Parameters("TABLE")->asTable()); } int fResult = Parameters("FIELD")->asInt(); // pTable->Set_Name(CSG_String::Format(SG_T("%s [%s]"), Parameters("TABLE")->asTable()->Get_Name(), Parameters("NAME")->asString())); pTable->Set_Name(Parameters("TABLE")->asTable()->Get_Name()); if( fResult < 0 || fResult >= pTable->Get_Field_Count() ) { fResult = pTable->Get_Field_Count(); pTable->Add_Field(Parameters("NAME")->asString(), SG_DATATYPE_Double); } //----------------------------------------------------- CSG_Vector Values(nFields); for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); bool bOkay = true; for(int iField=0; iFieldis_NoData(iField) ) { Values[iField] = pRecord->asDouble(Fields[iField]); } else { bOkay = false; } } if( bOkay ) { pRecord->Set_Value(fResult, Formula.Get_Value(Values.Get_Data(), nFields)); } else { pRecord->Set_NoData(fResult); } } //----------------------------------------------------- delete[](Fields); if( pTable == Parameters("TABLE")->asTable() ) { DataObject_Update(pTable); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CTable_Calculator_Base::Get_Formula(CSG_String sFormula, CSG_Table *pTable, int *Fields, int &nFields) { const SG_Char vars[27] = SG_T("abcdefghijklmnopqrstuvwxyz"); int iField; for(iField=pTable->Get_Field_Count()-1, nFields=0; iField>=0 && nFields<26; iField--) { bool bUse = false; CSG_String sField; sField.Printf(SG_T("f%d"), iField + 1); if( sFormula.Find(sField) >= 0 ) { sFormula.Replace(sField, CSG_String(vars[nFields])); bUse = true; } sField.Printf(SG_T("[%s]"), pTable->Get_Field_Name(iField)); if( sFormula.Find(sField) >= 0 ) { sFormula.Replace(sField, CSG_String(vars[nFields])); bUse = true; } if( bUse ) { Fields[nFields++] = iField; } } return( sFormula ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Calculator::CTable_Calculator(void) : CTable_Calculator_Base() { Set_Name (_TL("Table Calculator")); Parameters.Add_Table (NULL, "TABLE" , _TL("Table") , _TL(""), PARAMETER_INPUT); Parameters.Add_Table (NULL, "RESULT" , _TL("Result") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Table_Field(Parameters("TABLE"), "FIELD", _TL("Field"), _TL(""), true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Calculator_Shapes::CTable_Calculator_Shapes(void) : CTable_Calculator_Base() { Set_Name (_TL("Table Calculator (Shapes)")); Parameters.Add_Shapes (NULL, "TABLE" , _TL("Shapes") , _TL(""), PARAMETER_INPUT); Parameters.Add_Shapes (NULL, "RESULT" , _TL("Result") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Table_Field(Parameters("TABLE"), "FIELD", _TL("Field"), _TL(""), true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_calculus/table_cluster_analysis.h0000664000175000017500000001046312565125412027012 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_cluster_analysis.h 2270 2014-10-02 15:39:13Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // table_cluster_analysis.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_cluster_analysis_H #define HEADER_INCLUDED__table_cluster_analysis_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Cluster_Analysis : public CSG_Module { public: CTable_Cluster_Analysis(bool bShapes); virtual CSG_String Get_MenuPath (void) { return( m_bShapes ? _TL("A:Shapes|Table") : _TL("") ); } protected: virtual bool On_Execute (void); private: bool m_bShapes; void Save_Statistics (CSG_Table *pTable, int *Features, bool bNormalize, const CSG_Cluster_Analysis &Analysis); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_cluster_analysis_H saga-2.2.3/src/modules/table/table_calculus/Table_Calculator.h0000664000175000017500000000475712565125412025470 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Table_Calculator.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* TableCalculator.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Calculator_Base : public CSG_Module { public: CTable_Calculator_Base(void); protected: virtual bool On_Execute (void); CSG_String Get_Formula (CSG_String sFormula, CSG_Table *pTable, int *Fields, int &nFields); }; //--------------------------------------------------------- class CTable_Calculator : public CTable_Calculator_Base { public: CTable_Calculator(void); }; //--------------------------------------------------------- class CTable_Calculator_Shapes : public CTable_Calculator_Base { public: CTable_Calculator_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Table") ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_calculus/Fit.h0000664000175000017500000001014312565125412022774 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Fit.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // Fit.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@gwdg.de // // // // contact: Andre Ringeler // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__CFit_H #define HEADER_INCLUDED__CFit_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFit : public CSG_Module { public: CFit(void); virtual ~CFit(void); protected: virtual bool On_Execute(void); virtual int On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Initialize_Parameters(void) { return( true ); } virtual void On_Finalize_Parameters(void) { } private: }; #endif // #ifndef HEADER_INCLUDED__CFit_H saga-2.2.3/src/modules/table/table_calculus/table_fill_record_gaps.cpp0000664000175000017500000002122512565125412027255 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_fill_record_gaps.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_calculus // // // //-------------------------------------------------------// // // // table_fill_record_gaps.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_fill_record_gaps.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Fill_Record_Gaps::CTable_Fill_Record_Gaps(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Fill Gaps in Records")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- // 2. Parameters... pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ORDER" , _TL("Order"), _TL("") ); pNode = Parameters.Add_Table( NULL , "NOGAPS" , _TL("Table without Gaps"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Interpolation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Nearest Neighbour"), _TL("Linear"), _TL("Spline") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Fill_Record_Gaps::On_Execute(void) { int Method; CSG_Table *pTable; //----------------------------------------------------- pTable = Parameters("TABLE") ->asTable(); m_pNoGaps = Parameters("NOGAPS") ->asTable(); m_fOrder = Parameters("ORDER") ->asInt(); Method = Parameters("METHOD") ->asInt(); if( pTable->Get_Count() == 0 || !pTable->Set_Index(m_fOrder, TABLE_INDEX_Ascending) ) { return( false ); } //----------------------------------------------------- CSG_Table_Record *pA, *pB; m_pNoGaps->Create(pTable); m_pNoGaps->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pTable->Get_Name(), _TL("no gaps"))); m_pNoGaps->Add_Record(pB = pTable->Get_Record(0)); //----------------------------------------------------- for(int iRecord=1; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()-1); iRecord++) { pA = pB; pB = pTable->Get_Record(iRecord); int iA = pA->asInt(m_fOrder); int iB = pB->asInt(m_fOrder); if( iB - iA > 1 ) { int iStart = m_pNoGaps->Get_Count(); for(int i=iA+1; iAdd_Record()->Set_Value(m_fOrder, i); } for(int iField=0; iFieldGet_Field_Count(); iField++) { if( iField != m_fOrder && ::SG_Data_Type_is_Numeric(pTable->Get_Field_Type(iField)) ) { switch( Method ) { case 0: Set_Nearest (iStart, iField, pA, pB); break; case 1: Set_Linear (iStart, iField, pA, pB); break; case 2: Set_Spline (iStart, iField, pTable->Get_Record(iRecord - 2), pA, pB, pTable->Get_Record(iRecord + 1)); break; } } } } m_pNoGaps->Add_Record(pB); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Fill_Record_Gaps::Set_Nearest(int iOffset, int iField, CSG_Table_Record *p1, CSG_Table_Record *p2) { double z1 = p1->asDouble(iField); double z2 = p2->asDouble(iField); int n = iOffset + (m_pNoGaps->Get_Count() - iOffset) / 2; for(int iRecord=iOffset; iRecordGet_Count(); iRecord++) { m_pNoGaps->Get_Record(iRecord)->Set_Value(iField, iOffset < n ? z1 : z2); } return( true ); } //--------------------------------------------------------- bool CTable_Fill_Record_Gaps::Set_Linear(int iOffset, int iField, CSG_Table_Record *p1, CSG_Table_Record *p2) { double z1 = p1->asDouble(iField); double dz = (p2->asDouble(iField) - z1) / abs(p2->asInt(m_fOrder) - p1->asInt(m_fOrder)); for(int iRecord=iOffset, iX=1; iRecordGet_Count(); iRecord++, iX++) { m_pNoGaps->Get_Record(iRecord)->Set_Value(iField, z1 + iX * dz); } return( true ); } //--------------------------------------------------------- bool CTable_Fill_Record_Gaps::Set_Spline(int iOffset, int iField, CSG_Table_Record *p0, CSG_Table_Record *p1, CSG_Table_Record *p2, CSG_Table_Record *p3) { CSG_Spline Spline; int i0 = p0 ? p0->asInt(m_fOrder) : p1->asInt(m_fOrder) - 1; int i1 = p1->asInt(m_fOrder); int i2 = p2->asInt(m_fOrder); int i3 = p3 ? p3->asInt(m_fOrder) : p2->asInt(m_fOrder) + 1; Spline.Add(i0 - i1, p0 ? p0->asDouble(iField) : p1->asDouble(iField)); Spline.Add(0 , p1->asDouble(iField)); Spline.Add(i2 - i1, p2->asDouble(iField)); Spline.Add(i3 - i1, p3 ? p3->asDouble(iField) : p2->asDouble(iField)); if( !Spline.Create() ) { return( Set_Linear(iOffset, iField, p1, p2) ); } for(int iRecord=iOffset, i=1; iRecordGet_Count(); iRecord++, i++) { m_pNoGaps->Get_Record(iRecord)->Set_Value(iField, Spline.Get_Value(i)); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_calculus/table_running_average.h0000664000175000017500000001024212565125412026573 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_running_average.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // table_running_average.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_running_average_H #define HEADER_INCLUDED__table_running_average_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Running_Average : public CSG_Module { public: CTable_Running_Average(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_running_average_H saga-2.2.3/src/modules/table/table_calculus/MLB_Interface.cpp0000664000175000017500000001263112565125412025203 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2345 2014-11-27 11:27:59Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // MLB_Interface.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@gwdg.de // // // // contact: Andre Ringeler // // 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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Calculus") ); case MLB_INFO_Category: return( _TL("Table") ); case MLB_INFO_Author: return( _TL("SAGA User Group Associaton (c) 2002-2014") ); case MLB_INFO_Description: return( _TL("Tools for table based analyses and calculations.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Table|Calculus") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Fit.h" #include "Table_Calculator.h" #include "table_running_average.h" #include "table_cluster_analysis.h" #include "table_pca.h" #include "table_fill_record_gaps.h" #include "table_field_analyzer.h" #include "table_mRMR.h" #include "table_field_statistics.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CFit ); case 1: return( new CTable_Calculator ); case 2: return( new CTable_Calculator_Shapes ); case 5: return( new CTable_Running_Average ); case 6: return( new CTable_Cluster_Analysis(false) ); case 14: return( new CTable_Cluster_Analysis(true) ); case 7: return( new CTable_PCA ); case 8: return( new CTable_Fill_Record_Gaps ); case 11: return( new CTable_Field_Extreme ); case 12: return( new CTable_mRMR ); case 15: return( new CTable_Field_Statistics() ); //----------------------------------------------------- case 19: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/table/table_calculus/Makefile.am0000664000175000017500000000174112565125412024141 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 2345 2014-11-27 11:27:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libtable_calculus.la libtable_calculus_la_SOURCES =\ Fit.cpp\ LMFit.cpp\ MLB_Interface.cpp\ Table_Calculator.cpp\ table_cluster_analysis.cpp\ table_field_analyzer.cpp\ table_field_statistics.cpp\ table_fill_record_gaps.cpp\ table_mRMR.cpp\ table_pca.cpp\ table_running_average.cpp\ Fit.h\ LMFit.h\ MLB_Interface.h\ Table_Calculator.h\ table_cluster_analysis.h\ table_field_analyzer.h\ table_field_statistics.h\ table_fill_record_gaps.h\ table_mRMR.h\ table_pca.h\ table_running_average.h libtable_calculus_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/table/table_calculus/MLB_Interface.h0000664000175000017500000000773712565125412024663 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@gwdg.de // // // // contact: Andre Ringeler // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_calculus_H #define HEADER_INCLUDED__table_calculus_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef table_calculus_EXPORTS #define table_calculus_EXPORT _SAGA_DLL_EXPORT #else #define table_calculus_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_calculus_H saga-2.2.3/src/modules/table/table_calculus/table_cluster_analysis.cpp0000664000175000017500000002563312565125412027352 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_cluster_analysis.cpp 2343 2014-11-26 16:21:11Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // table_cluster_analysis.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_cluster_analysis.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Cluster_Analysis::CTable_Cluster_Analysis(bool bShapes) { m_bShapes = bShapes; CSG_Parameter *pNode; //----------------------------------------------------- Set_Author ("O. Conrad (c) 2010"); Set_Description (_TW( "Cluster Analysis for tables.\n\nReferences:\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" )); //----------------------------------------------------- if( m_bShapes ) { Set_Name (_TL("Cluster Analysis (Shapes)")); pNode = Parameters.Add_Shapes(NULL, "INPUT" , _TL("Shapes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Shapes(NULL, "RESULT", _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL); } else { Set_Name (_TL("Cluster Analysis")); pNode = Parameters.Add_Table(NULL, "INPUT" , _TL("Table" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Table(NULL, "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL); } Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("") ); Parameters.Add_Table_Field( pNode , "CLUSTER" , _TL("Cluster"), _TL(""), true ); Parameters.Add_Table( NULL , "STATISTICS" , _TL("Statistics"), _TL(""), PARAMETER_OUTPUT ); 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 grids by standard deviation before clustering."), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Cluster_Analysis::On_Execute(void) { bool bNormalize; int iFeature, nFeatures, *Features, iElement, nElements, Cluster; CSG_Cluster_Analysis Analysis; CSG_Table *pTable; //----------------------------------------------------- pTable = Parameters("RESULT" )->asTable(); bNormalize = Parameters("NORMALISE")->asBool(); Cluster = Parameters("CLUSTER" )->asInt(); Features = (int *)Parameters("FIELDS")->asPointer(); nFeatures = Parameters("FIELDS")->asInt (); if( !Features || nFeatures <= 0 ) { Error_Set(_TL("no features in selection")); return( false ); } if( !Analysis.Create(nFeatures) ) { Error_Set(_TL("could not initialize cluster engine")); return( false ); } if( pTable && pTable != Parameters("INPUT")->asTable() ) { if( m_bShapes ) { ((CSG_Shapes *)pTable)->Create(*Parameters("INPUT")->asShapes()); } else { pTable->Create(*Parameters("INPUT")->asTable()); } } else { pTable = Parameters("INPUT")->asTable(); } if( Cluster < 0 ) { Cluster = pTable->Get_Field_Count(); pTable->Add_Field(_TL("CLUSTER"), SG_DATATYPE_Int); } //----------------------------------------------------- for(iElement=0, nElements=0; iElementGet_Count() && Set_Progress(iElement, pTable->Get_Count()); iElement++) { CSG_Table_Record *pRecord = pTable->Get_Record(iElement); bool bNoData = false; for(iFeature=0; iFeatureis_NoData(Features[iFeature]) ) { bNoData = true; } } if( bNoData || !Analysis.Add_Element() ) { pRecord->Set_NoData(Cluster); } else { pRecord->Set_Value(Cluster, 0.0); for(iFeature=0; iFeatureasDouble(Features[iFeature]); if( bNormalize ) { d = (d - pTable->Get_Mean(Features[iFeature])) / pTable->Get_StdDev(Features[iFeature]); } Analysis.Set_Feature(nElements, iFeature, d); } nElements++; } } if( nElements <= 1 ) { return( false ); } //----------------------------------------------------- bool bResult = Analysis.Execute(Parameters("METHOD")->asInt(), Parameters("NCLUSTER")->asInt()); for(iElement=0, nElements=0; iElementGet_Count(); iElement++) { Set_Progress(iElement, pTable->Get_Count()); CSG_Table_Record *pRecord = pTable->Get_Record(iElement); if( !pRecord->is_NoData(Cluster) ) { pRecord->Set_Value(Cluster, Analysis.Get_Cluster(nElements++)); } } Save_Statistics(pTable, Features, bNormalize, Analysis); // Save_LUT(pCluster, Analysis.Get_nClusters()); DataObject_Update(pTable); return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTable_Cluster_Analysis::Save_Statistics(CSG_Table *pTable, int *Features, bool bNormalize, const CSG_Cluster_Analysis &Analysis) { int iCluster, iFeature; CSG_String s; CSG_Table *pStatistics; pStatistics = Parameters("STATISTICS")->asTable(); pStatistics->Destroy(); pStatistics->Set_Name(_TL("Cluster Analysis")); pStatistics->Add_Field(_TL("ClusterID") , SG_DATATYPE_Int); pStatistics->Add_Field(_TL("Elements") , SG_DATATYPE_Int); pStatistics->Add_Field(_TL("Std.Dev.") , SG_DATATYPE_Double); s.Printf(SG_T("\n%s:\t%ld \n%s:\t%d \n%s:\t%d \n%s:\t%f\n\n%s\t%s\t%s"), _TL("Number of Elements") , Analysis.Get_nElements(), _TL("Number of Variables") , Analysis.Get_nFeatures(), _TL("Number of Clusters") , Analysis.Get_nClusters(), _TL("Value of Target Function") , Analysis.Get_SP(), _TL("Cluster"), _TL("Elements"), _TL("Std.Dev.") ); for(iFeature=0; iFeatureGet_Field_Name(Features[iFeature])); pStatistics->Add_Field(pTable->Get_Field_Name(Features[iFeature]), SG_DATATYPE_Double); } Message_Add(s); for(iCluster=0; iClusterAdd_Record(); pRecord->Set_Value(0, iCluster); pRecord->Set_Value(1, Analysis.Get_nMembers(iCluster)); pRecord->Set_Value(2, sqrt(Analysis.Get_Variance(iCluster))); for(iFeature=0; iFeatureGet_Mean(Features[iFeature]) + Centroid * pTable->Get_StdDev(Features[iFeature]); } s += CSG_String::Format(SG_T("\t%f"), Centroid); pRecord->Set_Value(iFeature + 3, Centroid); } Message_Add(s, false); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_calculus/Fit.cpp0000664000175000017500000002251612565125412023336 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Fit.cpp 2447 2015-03-19 14:43:42Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Calculus // // // //-------------------------------------------------------// // // // Fit.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@gwdg.de // // // // contact: Andre Ringeler // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "LMFit.h" #include #include #include #include "Fit.h" #define EPS 0.001 CSG_Formula Formel; char vars[26]; double NUG(double x) { if (x > 0) return 1.0; else return 0.0; } double SPH(double x, double a) { if (x < 0) return 0.0; if (x > a) return 1.0; double val = x/a; return (1.5 - 0.5*val*val)*val; } double EXP(double x, double a) { if (x < 0) return 0.0; return 1.0 - exp(-x/a); } double LIN(double x, double a) { if (a == 0.0) return x; if (x < a) return x/a; return x; } CFit::CFit(void) { Set_Name(_TL("Function Fit")); Set_Description(_TL("CFit\n(created by SAGA Wizard).")); CSG_Parameter *pNode; pNode = Parameters.Add_Table(NULL , "SOURCE" , _TL("Source") , _TL(""), PARAMETER_INPUT); Parameters.Add_Table_Field(pNode , "YFIELD" , _TL("y - Values") , _TL("")); Parameters.Add_Choice(pNode, "USE_X", _TL("Use x -Values"), _TL(""), _TL("No|Yes|")); Parameters.Add_Table_Field(pNode , "XFIELD" , _TL("x - Values") , _TL("")); Parameters.Add_String(NULL, "FORMEL", _TL("Formula"), _TW( "The following operators are available for the formula definition:\n" "+ Addition\n" "- Subtraction\n" "* Multiplication\n" "/ Division\n" "^ power\n" "sin(x)\n" "cos(x)\n" "tan(x)\n" "asin(x)\n" "acos(x)\n" "atan(x)\n" "abs(x)\n" "sqrt(x)\n\n" "For Variogram - Fitting you can use the folowing Variogram - Models:\n" "NUG(x)\n" "SPH(x,a)\n" "EXP(x,a)\n" "LIN(x,a)\n" "The Fitting variables are single characters like a,b,m .. " "alphabetical order with the grid list order ('a'= first var, 'b' = second grid, ...)\n" "Example: m*x+a \n"), SG_T("m*x+c")); Parameters.Add_Value(NULL, "ITER", _TL("Iterationen"), _TL(""), PARAMETER_TYPE_Int, 1000, 1, true); Parameters.Add_Value(NULL, "LAMDA", _TL("Max Lamda"), _TL(""), PARAMETER_TYPE_Double, 10000, 1, true); } int CFit::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if (!SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FORMEL")) ) { CSG_String Msg; Formel.Set_Formula(pParameters->Get_Parameter("FORMEL")->asString()); if( Formel.Get_Error(Msg) ) { Error_Set (Msg); Message_Dlg(Msg); return( -1 ); } } return( 0 ); } CFit::~CFit(void) {} void FitFunc(double x, vector < double> ca, double &y, vector < double> &dyda, int na) { int i; for(i = 0; i < na; i++) { Formel.Set_Variable(vars[i], ca[i]); } y= Formel.Get_Value(x); for (i = 0; i < na; i++) { Formel.Set_Variable(vars[i], ca[i] + EPS); dyda[i] = Formel.Get_Value(x); dyda[i] -= y; dyda[i] /= EPS; Formel.Set_Variable(vars[i], ca[i] - EPS); } } // MinGW Error !!! // Fit.cpp:199: error: name lookup of `i' changed for new ISO `for' scoping // Fit.cpp:192: error: using obsolete binding at `i' bool CFit::On_Execute(void) { int i, j, NrVars; vector < double> x, y, StartValue, Result; CSG_String msg; CSG_Parameters StartParameters; const SG_Char *formel = Parameters("FORMEL")->asString(); Formel.Add_Function(SG_T("NUG"), (TSG_PFNC_Formula_1) NUG, 1, 0); Formel.Add_Function(SG_T("SPH"), (TSG_PFNC_Formula_1) SPH, 2, 0); Formel.Add_Function(SG_T("EXP"), (TSG_PFNC_Formula_1) EXP, 2, 0); Formel.Add_Function(SG_T("LIN"), (TSG_PFNC_Formula_1) LIN, 2, 0); Formel.Set_Formula(formel); if (Formel.Get_Error(msg)) { Message_Add(msg); return false; } const SG_Char *uservars = NULL; uservars = Formel.Get_Used_Variables(); NrVars = 0; for (i = 0; i < SG_STR_LEN(uservars); i++) { if (uservars[i] >='a' && uservars[i] <= 'z') { if (uservars[i] != 'x') vars[NrVars++] = (char)(uservars[i]); } } vars[NrVars] =(char) 0; StartParameters.Add_Info_String(NULL, _TL(""), _TL("Formula"), _TL("Formula"), formel); for (i = 0; i < strlen(vars); i++) { CSG_String c(vars[i]); StartParameters.Add_Value(NULL, c, c, _TL("Start Value"), PARAMETER_TYPE_Double, 1.0); } Dlg_Parameters(&StartParameters, _TL("Start Values")); for (i = 0; i < strlen(vars); i++) { char c[3]; sprintf(c, "%c", vars[i]); StartValue.push_back(StartParameters(c)->asDouble()); } CSG_Table *pTable = Parameters("SOURCE")->asTable(); int Record_Count = pTable->Get_Record_Count(); int yField = Parameters("YFIELD")->asInt(); int xField = Parameters("XFIELD")->asInt(); bool Use_X = Parameters("USE_X")->asBool(); pTable->Add_Field(_TL("Fit") , SG_DATATYPE_Double); for (i = 0; i < Record_Count; i++) { CSG_Table_Record * Record = pTable->Get_Record(i); if (Use_X) { x.push_back(Record->asDouble(xField)); } else { x.push_back(i); } y.push_back(Record->asDouble(yField)); } TLMFit *Fit; Fit = new TLMFit(x, y, StartValue, FitFunc); int max_iter = Parameters("ITER")->asInt(); double Max_lamda = Parameters("LAMDA")->asInt(); int iter = 0; try { Fit->Fit(); while ((Fit->Alamda() < Max_lamda) &&(iter < max_iter) &&Process_Get_Okay(true)) { Fit->Fit(); iter++; } } catch (ESingularMatrix &E) { if (E.Type == 1 || E.Type == 2) { msg.Printf(_TL("Matrix signular\n")); Message_Add(msg); return false; } } Result = Fit->Param(); for (i = 0; i < NrVars; i++) { Formel.Set_Variable(vars[i], (double) Result[i]); } msg.Printf(_TL("Model Parameters:")); Message_Add(msg); for (i = 0; i < NrVars; i++) { msg.Printf(SG_T("%c = %f\n"), vars[i], Result[i]); Message_Add(msg); } msg.Printf(_TL("\nRMS of Residuals (stdfit):\t%f\n"), sqrt(Fit->Chisq()/x.size())); Message_Add(msg); msg.Printf(_TL("Correlation Matrix of the Fit Parameters:\n")); Message_Add(msg); vector< vector < double> > covar = Fit->Covar(); msg.Printf(_TL("")); for (j = 0; j < NrVars; j++) msg.Printf(SG_T("%s\t%c"), msg.c_str(), vars[j]); msg.Printf(SG_T("%s\n"), msg.c_str()); Message_Add(msg); for (i = 0; i < NrVars; i++) { msg.Printf(SG_T("%c"), vars[i]); for (j = 0; j <= i; j++) { msg.Printf(SG_T("%s\t%f"), msg.c_str(), covar[i][j]/covar[i][i]); } msg.Printf(SG_T("%s\n"), msg.c_str()); Message_Add(msg); } int Field_Count = pTable->Get_Field_Count(); for (i = 0; i < Record_Count; i++) { CSG_Table_Record * Record = pTable->Get_Record(i); Record->Set_Value(Field_Count - 1, Formel.Get_Value(x[i])); } // API_FREE (uservars); return (true); } saga-2.2.3/src/modules/table/table_calculus/table_mRMR.h0000664000175000017500000001173312565125412024244 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: mrmr.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_calculus // // // //-------------------------------------------------------// // // // table_mRMR.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_mRMR_H #define HEADER_INCLUDED__table_mRMR_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_mRMR : public CSG_Module { public: ////// public members and functions: ////////////// CTable_mRMR(void); protected: /// protected members and functions: /////////// virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: ///// private members and functions: ///////////// }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_mRMR_H saga-2.2.3/src/modules/table/table_calculus/table_pca.cpp0000664000175000017500000003204512565125412024524 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_pca.cpp 1928 2014-01-10 12:10:05Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_calculus // // // //-------------------------------------------------------// // // // table_pca.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_pca.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_PCA::CTable_PCA(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Principle Components Analysis")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "Principle Components Analysis (PCA) for tables. " "Implementation based on F. Murtagh's " "code " "as provided by the " "StatLib web site.\n" "\n" "References:\n" "Bahrenberg, G., Giese, E., Nipper, J. (1992): Statistische Methoden in der Geographie 2 - Multivariate Statistik. pp.198-277.\n" )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Parameters( pNode , "FIELDS" , _TL("Attributes"), _TL("") ); Parameters.Add_Table( NULL , "PCA" , _TL("Principle Components"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("correlation matrix"), _TL("variance-covariance matrix"), _TL("sums-of-squares-and-cross-products matrix") ), 1 ); Parameters.Add_Value( NULL , "NFIRST" , _TL("Number of Components"), _TL("maximum number of calculated first components; set to zero to get all"), PARAMETER_TYPE_Int, 3, 0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTable_PCA::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("TABLE")) ) { CSG_Table *pTable = pParameter->asTable(); CSG_Parameters *pFields = pParameters->Get_Parameter("FIELDS")->asParameters(); pFields->Del_Parameters(); if( pTable && pTable->Get_Field_Count() > 0 ) { for(int i=0; iGet_Field_Count(); i++) { if( SG_Data_Type_is_Numeric(pTable->Get_Field_Type(i)) ) { pFields->Add_Value(NULL, CSG_String::Format(SG_T("%d"), i), pTable->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false); } } } } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_PCA::On_Execute(void) { CSG_Vector Eigen_Values; CSG_Matrix Eigen_Vectors, Matrix; //----------------------------------------------------- m_pTable = Parameters("TABLE") ->asTable(); m_Method = Parameters("METHOD") ->asInt(); //----------------------------------------------------- if( !Get_Fields() ) { Error_Set(_TL("invalid field selection")); SG_FREE_SAFE(m_Features); return( false ); } if( !Get_Matrix(Matrix) ) { Error_Set(_TL("matrix initialisation failed")); SG_FREE_SAFE(m_Features); return( false ); } if( !SG_Matrix_Eigen_Reduction(Matrix, Eigen_Vectors, Eigen_Values) ) { Error_Set(_TL("Eigen reduction failed")); SG_FREE_SAFE(m_Features); return( false ); } //----------------------------------------------------- Get_Components(Eigen_Vectors, Eigen_Values); //----------------------------------------------------- SG_FREE_SAFE(m_Features); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_PCA::Get_Fields(void) { CSG_Parameters *pFields = Parameters("FIELDS")->asParameters(); m_Features = (int *)SG_Calloc(pFields->Get_Count(), sizeof(int)); m_nFeatures = 0; for(int iFeature=0; iFeatureGet_Count(); iFeature++) { if( pFields->Get_Parameter(iFeature)->asBool() ) { CSG_String s(pFields->Get_Parameter(iFeature)->Get_Identifier()); m_Features[m_nFeatures++] = s.asInt(); } } return( m_nFeatures > 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CTable_PCA::is_NoData(int iElement) { CSG_Table_Record *pElement = m_pTable->Get_Record(iElement); for(int iFeature=0; iFeatureis_NoData(m_Features[iFeature]) ) { return( true ); } } return( false ); } //--------------------------------------------------------- inline double CTable_PCA::Get_Value(int iFeature, int iElement) { CSG_Table_Record *pElement = m_pTable->Get_Record(iElement); switch( m_Method ) { default: case 0: // Correlation matrix: Center and reduce the column vectors. return( (pElement->asDouble(iFeature) - m_pTable->Get_Mean(iFeature)) / (sqrt(m_pTable->Get_Count() * m_pTable->Get_Variance(iFeature))) ); case 1: // Variance-covariance matrix: Center the column vectors. return( (pElement->asDouble(iFeature) - m_pTable->Get_Mean(iFeature)) ); case 2: // Sums-of-squares-and-cross-products matrix return( (pElement->asDouble(iFeature)) ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_PCA::Get_Matrix(CSG_Matrix &Matrix) { int i, j1, j2; Matrix.Create(m_nFeatures, m_nFeatures); Matrix.Set_Zero(); switch( m_Method ) { //----------------------------------------------------- default: case 0: // Correlation matrix: Center and reduce the column vectors. for(j1=0; j1Get_Count() && Set_Progress(i, m_pTable->Get_Count()); i++) { if( !is_NoData(i) ) { for(j1=0; j1Get_Count() && Set_Progress(i, m_pTable->Get_Count()); i++) { if( !is_NoData(i) ) { for(j1=0; j1 0.0 ? 100.0 / Sum : 0.0; Message_Add(CSG_String::Format(SG_T("\n%s, %s, %s\n"), _TL("explained variance"), _TL("explained cumulative variance"), _TL("Eigenvalue")), false); for(j=m_nFeatures-1, Cum=0.0; j>=0; j--) { Cum += Eigen_Values[j] * Sum; Message_Add(CSG_String::Format(SG_T("%6.2f\t%6.2f\t%18.5f\n"), Eigen_Values[j] * Sum, Cum, Eigen_Values[j]), false); } Message_Add(CSG_String::Format(SG_T("\n%s:\n"), _TL("Eigenvectors")), false); for(j=0; jasInt(); if( n <= 0 || n > m_nFeatures ) { n = m_nFeatures; } //----------------------------------------------------- CSG_Table *pPCA = Parameters("PCA")->asTable(); if( pPCA == NULL ) { pPCA = m_pTable; } if( pPCA != m_pTable ) { pPCA->Destroy(); pPCA->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pTable->Get_Name(), _TL("Principal Components"))); } //----------------------------------------------------- field0 = pPCA->Get_Field_Count(); for(i=0; iAdd_Field(CSG_String::Format(SG_T("%s %d"), _TL("Component"), i + 1), SG_DATATYPE_Double); } //----------------------------------------------------- for(int iElement=0; iElementGet_Count() && Set_Progress(iElement, m_pTable->Get_Count()); iElement++) { if( !is_NoData(iElement) ) { CSG_Table_Record *pElement = pPCA == m_pTable ? pPCA->Get_Record(iElement) : pPCA->Add_Record(); for(i=0, j=m_nFeatures-1; iSet_Value(field0 + i, d); } } } //----------------------------------------------------- if( pPCA == m_pTable ) { DataObject_Update(m_pTable); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/0000775000175000017500000000000012634325751021434 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/table/table_tools/Join_Tables.cpp0000664000175000017500000003237312565125412024334 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Join_Tables.cpp 1010 2011-04-26 11:52:02Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // Join_Tables.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad & 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Join_Tables.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CJoin_Tables_Base::Initialise(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Author (SG_T("V.Olaya (c) 2005, O.Conrad (c) 2011")); Set_Description (_TW( "Joins two tables using key attributes." )); //----------------------------------------------------- pNode = Parameters("TABLE_A"); Parameters.Add_Table_Field( pNode , "ID_A" , _TL("Identifier"), _TL("") ); pNode = Parameters("TABLE_B"); Parameters.Add_Table_Field( pNode , "ID_B" , _TL("Identifier"), _TL("") ); Parameters.Add_Value( pNode , "FIELDS_ALL" , _TL("Add All Fields"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Fields"), _TL("") ); Parameters.Add_Value( NULL , "KEEP_ALL" , _TL("Keep All"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CJoin_Tables_Base::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FIELDS_ALL")) ) { pParameters->Get_Parameter("FIELDS")->Set_Enabled(pParameter->asBool() == false); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CJoin_Tables_Base::On_Execute(void) { //----------------------------------------------------- int id_A, id_B; CSG_Table *pT_A, *pT_B; pT_A = Parameters("TABLE_A")->asTable(); id_A = Parameters("ID_A" )->asInt(); pT_B = Parameters("TABLE_B")->asTable(); id_B = Parameters("ID_B" )->asInt(); if( id_A < 0 || id_A >= pT_A->Get_Field_Count() || pT_A->Get_Count() <= 0 || id_B < 0 || id_B >= pT_B->Get_Field_Count() || pT_B->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- if( Parameters("RESULT")->asTable() && Parameters("RESULT")->asTable() != pT_A ) { pT_A = Parameters("RESULT")->asTable(); if( Parameters("RESULT")->asTable()->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ) { ((CSG_Shapes *)pT_A)->Create(*Parameters("TABLE_A")->asShapes()); } else { pT_A->Create(*Parameters("TABLE_A")->asTable()); } } //----------------------------------------------------- int nJoins, *Join, Offset = pT_A->Get_Field_Count(); if( Parameters("FIELDS_ALL")->asBool() ) { if( (nJoins = pT_B->Get_Field_Count() - 1) <= 0 ) { Error_Set(_TL("no fields to add")); return( false ); } Join = new int[nJoins]; for(int i=0, j=0; iGet_Field_Count(); i++) { if( i != id_B ) { pT_A->Add_Field(pT_B->Get_Field_Name(i), pT_B->Get_Field_Type(i)); Join[j++] = i; } } } else { CSG_Parameter_Table_Fields *pFields = Parameters("FIELDS")->asTableFields(); if( (nJoins = pFields->Get_Count()) <= 0 ) { Error_Set(_TL("no fields to add")); return( false ); } Join = new int[nJoins]; for(int j=0; jGet_Count(); j++) { int i = pFields->Get_Index(j); pT_A->Add_Field(pT_B->Get_Field_Name(i), pT_B->Get_Field_Type(i)); Join[j] = i; } } pT_A->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pT_A->Get_Name(), pT_B->Get_Name())); //----------------------------------------------------- bool bCmpNumeric = SG_Data_Type_is_Numeric(pT_A->Get_Field_Type(id_A)) || SG_Data_Type_is_Numeric(pT_B->Get_Field_Type(id_B)); CSG_Table Delete; if( !Parameters("KEEP_ALL")->asBool() ) Delete.Add_Field("ID", SG_DATATYPE_Int); pT_A->Set_Index(id_A, TABLE_INDEX_Ascending); pT_B->Set_Index(id_B, TABLE_INDEX_Ascending); CSG_Table_Record *pRecord_B = pT_B->Get_Record_byIndex(0); for(int a=0, b=0, Cmp; pRecord_B && aGet_Count() && Set_Progress(a, pT_A->Get_Count()); a++) { CSG_Table_Record *pRecord_A = pT_A->Get_Record_byIndex(a); while( pRecord_B && (Cmp = Cmp_Keys(pRecord_A->Get_Value(id_A), pRecord_B->Get_Value(id_B), bCmpNumeric)) < 0 ) { pRecord_B = pT_B->Get_Record_byIndex(++b); } if( pRecord_B && Cmp == 0 ) { for(int i=0; iGet_Value(Offset + i) = *pRecord_B->Get_Value(Join[i]); } } else if( Delete.Get_Field_Count() == 0 ) { for(int i=0; iSet_NoData(Offset + i); } } else { Delete.Add_Record()->Set_Value(0, pRecord_A->Get_Index()); } } //----------------------------------------------------- delete[](Join); pT_A->Set_Index(id_A, TABLE_INDEX_None); pT_B->Set_Index(id_B, TABLE_INDEX_None); if( Delete.Get_Count() > 0 ) { Delete.Set_Index(0, TABLE_INDEX_Descending); for(int i=0; iDel_Shape(Delete[i].asInt(0)); pT_A->Del_Record(Delete[i].asInt(0)); } Message_Add(CSG_String::Format(SG_T("%d %s"), pT_A->Get_Selection_Count(), _TL("unjoined records have been removed"))); } if( pT_A == Parameters("TABLE_A")->asTable() ) { DataObject_Update(pT_A); } return( pT_A->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline int CJoin_Tables_Base::Cmp_Keys(CSG_Table_Value *pA, CSG_Table_Value *pB, bool bCmpNumeric) { if( pB == NULL ) { return( 1 ); } if( bCmpNumeric ) { double d = pB->asDouble() - pA->asDouble(); return( d < 0.0 ? -1 : d > 0.0 ? 1 : 0 ); } CSG_String Key(pB->asString()); return( Key.CmpNoCase(pA->asString()) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CJoin_Tables::CJoin_Tables(void) { Set_Name (_TL("Join Attributes from a Table")); Parameters.Add_Table( NULL , "TABLE_A" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "TABLE_B" , _TL("Join Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Initialise(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CJoin_Tables_Shapes::CJoin_Tables_Shapes(void) { Set_Name (_TL("Join Attributes from a Table (Shapes)")); Parameters.Add_Shapes( NULL , "TABLE_A" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "TABLE_B" , _TL("Join Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Initialise(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Append_Cols::CTable_Append_Cols(void) { Set_Name (_TL("Append Fields from another Table")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description(_TW( "" )); Parameters.Add_Table( NULL , "INPUT" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "APPEND" , _TL("Append Rows from ..."), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "OUTPUT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Append_Cols::On_Execute(void) { CSG_Table *pTable, *pOutput, *pAppend; //----------------------------------------------------- pTable = Parameters("INPUT" )->asTable(); pOutput = Parameters("OUTPUT")->asTable(); pAppend = Parameters("APPEND")->asTable(); //----------------------------------------------------- if( pTable->Get_Record_Count() <= 0 ) { Error_Set(_TL("no records in data set")); return( false ); } if( pAppend->Get_Record_Count() <= 0 ) { Error_Set(_TL("no records to append")); return( false ); } //----------------------------------------------------- if( pOutput && pOutput != pTable ) { pOutput->Create (*pTable); pOutput->Set_Name ( pTable->Get_Name()); pTable = pOutput; } //----------------------------------------------------- int iField, jField, aField, nRecords; nRecords = pTable->Get_Count() < pAppend->Get_Count() ? pTable->Get_Count() : pAppend->Get_Count(); aField = pTable->Get_Field_Count(); for(iField=0; iFieldGet_Field_Count(); iField++) { pTable->Add_Field(pAppend->Get_Field_Name(iField), pAppend->Get_Field_Type(iField)); } //----------------------------------------------------- for(int iRecord=0; iRecordGet_Record(iRecord); CSG_Table_Record *pAdd = pAppend->Get_Record(iRecord); for(iField=0, jField=aField; iFieldGet_Field_Count(); iField++) { *pRec->Get_Value(jField++) = *pAdd->Get_Value(iField); } } //----------------------------------------------------- if( pTable == Parameters("INPUT")->asTable() ) { DataObject_Update(pTable); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/table_field_deletion.cpp0000664000175000017500000002043312565125412026252 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_field_deletion.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_field_deletion.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_field_deletion.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Field_Deletion::CTable_Field_Deletion(void) { //----------------------------------------------------- Set_Name (_TL("Delete Fields")); Set_Author (_TL("O.Conrad (c) 2013")); Set_Description (_TW( "Deletes selected fields from a table or shapefile. " )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL("Input table or shapefile"), PARAMETER_INPUT ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Fields"), _TL("") ); Parameters.Add_Table( NULL , "OUT_TABLE" , _TL("Output table with field(s) deleted"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Shapes( NULL , "OUT_SHAPES" , _TL("Output shapes with field(s) deleted"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTable_Field_Deletion::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TABLE") ) { CSG_Data_Object *pObject = pParameter->asDataObject(); pParameters->Get_Parameter("OUT_TABLE" )->Set_Enabled(pObject && pObject->Get_ObjectType() == DATAOBJECT_TYPE_Table ); pParameters->Get_Parameter("OUT_SHAPES")->Set_Enabled(pObject && pObject->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Field_Deletion::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Table_Fields *pFields = Parameters("FIELDS")->asTableFields(); if( pFields->Get_Count() <= 0 ) { Error_Set(_TL("no fields in selection")); return( false ); } //----------------------------------------------------- CSG_Table *pTable = Parameters("TABLE")->asTable(); CSG_Table *pOutput = NULL; if( pTable->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ) { if( (pOutput = Parameters("OUT_SHAPES")->asShapes()) != NULL && pOutput != pTable ) { ((CSG_Shapes *)pOutput)->Create(((CSG_Shapes *)pTable)->Get_Type(), (const wchar_t*)0, (CSG_Table *)0, ((CSG_Shapes *)pTable)->Get_Vertex_Type()); } } else // if( pTable->Get_ObjectType() == DATAOBJECT_TYPE_Table ) { if( (pOutput = Parameters("OUT_TABLE" )->asTable()) != NULL && pOutput != pTable ) { pOutput->Destroy(); } } //----------------------------------------------------- if( pOutput ) { int nFields = pTable->Get_Field_Count() - pFields->Get_Count(); int *pFieldsOut = new int[nFields]; int iField = 0; for(int i=0; iGet_Field_Count(); i++) { bool bDelete = false; for(int j=0; jGet_Count(); j++) { if( i == pFields->Get_Index(j) ) { bDelete = true; break; } } if( !bDelete ) { pFieldsOut[iField] = i; iField++; } } pOutput->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pTable->Get_Name(), _TL("Changed"))); for(iField=0; iFieldAdd_Field(pTable->Get_Field_Name(pFieldsOut[iField]), pTable->Get_Field_Type(pFieldsOut[iField])); } for(int iRecord=0; iRecordGet_Count(); iRecord++) { CSG_Table_Record *pOut, *pIn = pTable->Get_Record(iRecord); if( pOutput->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ) { pOut = ((CSG_Shapes *)pOutput)->Add_Shape(pIn, SHAPE_COPY_GEOM); if( ((CSG_Shapes *)pOutput)->Get_Vertex_Type() > SG_VERTEX_TYPE_XY ) { for(int iPart=0; iPart<((CSG_Shape *)pIn)->Get_Part_Count(); iPart++) { for(int iPoint=0; iPoint<((CSG_Shape *)pIn)->Get_Point_Count(iPart); iPoint++) { ((CSG_Shape *)pOut)->Set_Z(((CSG_Shape *)pIn)->Get_Z(iPoint, iPart), iPoint, iPart); if( ((CSG_Shapes *)pOutput)->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { ((CSG_Shape *)pOut)->Set_M(((CSG_Shape *)pIn)->Get_M(iPoint, iPart), iPoint, iPart); } } } } } else { pOut = pOutput->Add_Record(); } for(iField=0; iFieldGet_Value(iField) = *pIn->Get_Value(pFieldsOut[iField]); } } delete[] pFieldsOut; } else { for(int iField=pFields->Get_Count()-1; iField>=0; iField--) { pTable->Del_Field(pFields->Get_Index(pFields->Get_Index(iField))); } DataObject_Update(pTable); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/table_categories_to_indicators.cpp0000664000175000017500000002057412565125412030360 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_categories_to_indicators.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_categories_to_indicators.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_categories_to_indicators.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Categories_to_Indicators::CTable_Categories_to_Indicators(void) { //----------------------------------------------------- Set_Name (_TL("Add Indicator Fields for Categories")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "Adds for each unique value found in the category field " "an indicator field that will show a value of one (1) " "for all records with this category value and zero (0) " "for all others. This might be used e.g. for subsequent " "indicator kriging. " )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL("Input table or shapefile"), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Categories"), _TL("") ); Parameters.Add_Table( NULL , "OUT_TABLE" , _TL("Output table with field(s) deleted"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Shapes( NULL , "OUT_SHAPES" , _TL("Output shapes with field(s) deleted"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTable_Categories_to_Indicators::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TABLE") ) { CSG_Data_Object *pObject = pParameter->asDataObject(); pParameters->Get_Parameter("OUT_TABLE" )->Set_Enabled(pObject && pObject->Get_ObjectType() == DATAOBJECT_TYPE_Table ); pParameters->Get_Parameter("OUT_SHAPES")->Set_Enabled(pObject && pObject->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Categories_to_Indicators::On_Execute(void) { //----------------------------------------------------- int iCategory = Parameters("FIELD")->asInt(); CSG_Table *pTable = Parameters("TABLE")->asTable(); //----------------------------------------------------- if( pTable->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ) { if( Parameters("OUT_SHAPES")->asShapes() != NULL && Parameters("OUT_SHAPES")->asShapes() != pTable ) { CSG_Shapes *pOutput = Parameters("OUT_SHAPES")->asShapes(); pOutput->Create(((CSG_Shapes *)pTable)->Get_Type(), NULL, (CSG_Table *)0, ((CSG_Shapes *)pTable)->Get_Vertex_Type()); pOutput->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pTable->Get_Name(), pTable->Get_Field_Name(iCategory))); pOutput->Add_Field(pTable->Get_Field_Name(iCategory), pTable->Get_Field_Type(iCategory)); for(int i=0; iGet_Count(); i++) { CSG_Table_Record *pRecord = pOutput->Add_Shape((CSG_Shape *)pTable->Get_Record(i), SHAPE_COPY_GEOM); *(pRecord->Get_Value(0)) = *(pTable->Get_Record(i)->Get_Value(iCategory)); } pTable = pOutput; iCategory = 0; } } //----------------------------------------------------- else // if( pTable->Get_ObjectType() == DATAOBJECT_TYPE_Table ) { if( Parameters("OUT_TABLE" )->asTable() != NULL && Parameters("OUT_TABLE" )->asTable() != pTable ) { CSG_Table *pOutput = Parameters("OUT_SHAPES")->asTable(); pOutput->Destroy(); pOutput->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pTable->Get_Name(), pTable->Get_Field_Name(iCategory))); pOutput->Add_Field(pTable->Get_Field_Name(iCategory), pTable->Get_Field_Type(iCategory)); for(int i=0; iGet_Count(); i++) { CSG_Table_Record *pRecord = pOutput->Add_Record(); *(pRecord->Get_Value(0)) = *(pTable->Get_Record(i)->Get_Value(iCategory)); } pTable = pOutput; iCategory = 0; } } //----------------------------------------------------- TSG_Table_Index_Order old_Order = pTable->Get_Index_Order(0); int old_Field = pTable->Get_Index_Field(0); pTable->Set_Index(iCategory, TABLE_INDEX_Descending); int nCategories = 0; CSG_String Value; for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record_byIndex(iRecord); if( iRecord == 0 || Value.Cmp(pRecord->asString(iCategory)) ) { Value = pRecord->asString(iCategory); pTable->Add_Field(Value, SG_DATATYPE_Int); nCategories++; } pRecord->Set_Value(pTable->Get_Field_Count() - 1, 1.0); } pTable->Set_Index(old_Field, old_Order); Message_Add(CSG_String::Format("\n%s: %d\n", _TL("number of categories"), nCategories), false); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/table_change_date_format.cpp0000664000175000017500000003406412565125412027103 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_change_date_format.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_change_date_format.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_change_date_format.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Change_Date_Format::CTable_Change_Date_Format(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Change Date Format")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- // 2. Parameters... pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Date Field"), _TL("") ); Parameters.Add_Table( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "FMT_IN" , _TL("Input Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("dd.mm.yy"), _TL("yy.mm.dd"), _TL("dd:mm:yy"), _TL("yy:mm:dd"), _TL("ddmmyyyy, fix size"), _TL("yyyymmdd, fix size"), _TL("ddmmyy, fix size"), _TL("yymmdd, fix size"), _TL("Julian Day") ), 0 ); Parameters.Add_Choice( NULL , "FMT_OUT" , _TL("Output Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("dd.mm.yy"), _TL("yy.mm.dd"), _TL("dd:mm:yy"), _TL("yy:mm:dd"), _TL("ddmmyyyy, fix size"), _TL("yyyymmdd, fix size"), _TL("ddmmyy, fix size"), _TL("yymmdd, fix size"), _TL("Julian Day") ), 7 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Change_Date_Format::On_Execute(void) { //----------------------------------------------------- int fmt_In = Parameters("FMT_IN" )->asInt(); int fmt_Out = Parameters("FMT_OUT")->asInt(); if( fmt_In == fmt_Out ) { Error_Set(_TL("nothing to do: input format is same as output format")); return( false ); } //----------------------------------------------------- CSG_Table *pTable = Parameters("OUTPUT")->asTable(); if( pTable && pTable != Parameters("TABLE")->asTable() ) { pTable->Assign (Parameters("TABLE")->asTable()); pTable->Set_Name(Parameters("TABLE")->asTable()->Get_Name()); } else { pTable = Parameters("TABLE")->asTable(); } //----------------------------------------------------- int fDate = Parameters("FIELD" )->asInt(); switch( fmt_Out ) { case 0: case 1: case 2: case 3: pTable->Set_Field_Type(fDate, SG_DATATYPE_String); break; default: pTable->Set_Field_Type(fDate, SG_DATATYPE_Int); break; } //----------------------------------------------------- SG_Char sep_In = fmt_In == 0 || fmt_In == 1 ? SG_T('.') : SG_T(':'); //----------------------------------------------------- for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); CSG_String sDate = pRecord->asString(fDate); int y, m, d; switch( fmt_In ) { case 0: // dd.mm.yy case 2: // dd:mm:yy d = sDate.BeforeFirst(sep_In).asInt(); m = sDate.AfterFirst (sep_In).asInt(); y = sDate.AfterLast (sep_In).asInt(); break; case 1: // yy.mm.dd case 3: // yy:mm:dd y = sDate.BeforeFirst(sep_In).asInt(); m = sDate.AfterFirst (sep_In).asInt(); d = sDate.AfterLast (sep_In).asInt(); break; case 4: // ddmmyyyy d = sDate.Left (2) .asInt(); m = sDate.Mid (2, 2).asInt(); y = sDate.Right(4) .asInt(); break; case 5: // yyyymmdd y = sDate.Left (4) .asInt(); m = sDate.Mid (4, 2).asInt(); d = sDate.Right(2) .asInt(); break; case 6: // ddmmyy d = sDate.Left (2) .asInt(); m = sDate.Mid (2, 2).asInt(); y = sDate.Right(2) .asInt(); break; case 7: // yymmdd y = sDate.Left (2) .asInt(); m = sDate.Mid (2, 2).asInt(); d = sDate.Right(2) .asInt(); break; case 8: // Julian Day { d = sDate.asInt(); if( d >= 2299161 ) // Gregorian, else Julian { y = (int)((d - 1867216.25) / 36524.25); d = d + 1 + y - (int)(y / 4.0); } int B = d + 1524; y = (int)((B - 122.1) / 365.25); d = (int)(365.25 * y); m = (int)((B - d) / 30.6001); d = B - d - (int)(30.6001 * m); // day, without day fraction df m = m < 14 ? m - 1 : m - 13; // month y = m > 2 ? y - 4716 : y - 4715; // year } break; } switch( fmt_Out ) { case 0: sDate.Printf(SG_T("%02d.%02d.%02d"), d, m, y); break; // dd:mm:yy case 1: sDate.Printf(SG_T("%02d.%02d.%02d"), y, m, d); break; // yy:mm:dd case 2: sDate.Printf(SG_T("%02d:%02d:%02d"), d, m, y); break; // dd:mm:yy case 3: sDate.Printf(SG_T("%02d:%02d:%02d"), y, m, d); break; // yy:mm:dd case 4: sDate.Printf(SG_T("%02d%02d%04d") , d, m, y); break; // ddmmyyyy case 5: sDate.Printf(SG_T("%04d%02d%02d") , y, m, d); break; // yyyymmdd case 6: sDate.Printf(SG_T("%02d%02d%02d") , d, m, y - 100 * (int)(y / 100.0)); break; // ddmmyy case 7: sDate.Printf(SG_T("%02d%02d%02d") , y - 100 * (int)(y / 100.0), m, d); break; // yymmdd case 8: // Julian Day { double Y = y + (m - 2.85) / 12.0; d = (int)((int)((int)(367.0 * Y) - 1.75 * (int)(Y) + d) - 0.75 * (int)(Y / 100.0)) + 1721115; sDate.Printf(SG_T("%d"), d); } break; } pRecord->Set_Value(fDate, sDate); } //----------------------------------------------------- if( pTable == Parameters("TABLE")->asTable() ) { DataObject_Update(pTable); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Change_Time_Format::CTable_Change_Time_Format(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Change Time Format")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- // 2. Parameters... pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Time Field"), _TL("") ); Parameters.Add_Table( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "FMT_IN" , _TL("Input Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("hh.mm.ss"), _TL("hh:mm:ss"), _TL("hhmmss, fix size"), _TL("hours"), _TL("minutes"), _TL("seconds") ), 1 ); Parameters.Add_Choice( NULL , "FMT_OUT" , _TL("Output Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("hh.mm.ss"), _TL("hh:mm:ss"), _TL("hhmmss, fix size"), _TL("hours"), _TL("minutes"), _TL("seconds") ), 5 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Change_Time_Format::On_Execute(void) { //----------------------------------------------------- int fmt_In = Parameters("FMT_IN" )->asInt(); int fmt_Out = Parameters("FMT_OUT")->asInt(); if( fmt_In == fmt_Out ) { Error_Set(_TL("nothing to do: input format is same as output format")); return( false ); } //----------------------------------------------------- CSG_Table *pTable = Parameters("OUTPUT")->asTable(); if( pTable && pTable != Parameters("TABLE")->asTable() ) { pTable->Assign (Parameters("TABLE")->asTable()); pTable->Set_Name(Parameters("TABLE")->asTable()->Get_Name()); } else { pTable = Parameters("TABLE")->asTable(); } //----------------------------------------------------- int fTime = Parameters("FIELD" )->asInt(); pTable->Set_Field_Type(fTime, SG_DATATYPE_String); //----------------------------------------------------- SG_Char sep_In = fmt_In == 0 ? SG_T('.') : SG_T(':'); //----------------------------------------------------- for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); CSG_String sTime = pRecord->asString(fTime); double s; switch( fmt_In ) { case 0: // hh.mm.ss case 1: // hh:mm:ss s = sTime.BeforeFirst(sep_In).asInt() * 3600; s += sTime.AfterFirst (sep_In).asInt() * 60; s += sTime.AfterLast (sep_In).asDouble(); break; case 2: // hhmmss s = sTime.Left (2) .asInt() * 3600; s += sTime.Mid (2, 2).asInt() * 60; s += sTime.Right(2) .asDouble(); break; case 3: // hours s = sTime.asDouble() * 3600; break; case 4: // minutes s = sTime.asDouble() * 60; break; case 5: // seconds s = sTime.asDouble(); break; } switch( fmt_Out ) { case 0: case 1: case 2: { int h = (int)(s / 3600); s = s - h * 3600; int m = (int)(s / 60); s = s - m * 60; switch( fmt_Out ) { // case 0: sTime.Printf(SG_T("%02d.%02d.%02.*f"), h, m, SG_Get_Significant_Decimals(s), s); break; // hh:mm:ss.s // case 1: sTime.Printf(SG_T("%02d:%02d:%02.*f"), h, m, SG_Get_Significant_Decimals(s), s); break; // hh:mm:ss.s case 0: sTime.Printf(SG_T("%02d.%02d.%02d" ), h, m, (int)(s + 0.5)); break; // hh:mm:ss case 1: sTime.Printf(SG_T("%02d:%02d:%02d" ), h, m, (int)(s + 0.5)); break; // hh:mm:ss case 2: sTime.Printf(SG_T("%02d%02d%02d" ), h, m, (int)(s + 0.5)); break; // hhmmss } } break; case 3: case 4: case 5: { switch( fmt_Out ) { case 3: s = s / 3600; break; // hours case 4: s = s / 60; break; // minutes // case 5: s = s ; break; // seconds } sTime.Printf(SG_T("%.*f"), SG_Get_Significant_Decimals(s), s); } break; } pRecord->Set_Value(fTime, sTime); } //----------------------------------------------------- if( pTable == Parameters("TABLE")->asTable() ) { DataObject_Update(pTable); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/Makefile.in0000664000175000017500000005732512622651175023514 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/table/table_tools DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libtable_tools_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libtable_tools_la_OBJECTS = Join_Tables.lo MLB_Interface.lo \ table_categories_to_indicators.lo table_change_color_format.lo \ table_change_date_format.lo table_change_field_type.lo \ Table_Create_Empty.lo Table_Enumerate.lo \ table_field_deletion.lo Table_Rotate.lo table_selection.lo \ table_text_replacer.lo libtable_tools_la_OBJECTS = $(am_libtable_tools_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libtable_tools_la_SOURCES) DIST_SOURCES = $(libtable_tools_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 2366 2015-01-09 15:13:32Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libtable_tools.la libtable_tools_la_SOURCES = \ Join_Tables.cpp\ MLB_Interface.cpp\ table_categories_to_indicators.cpp\ table_change_color_format.cpp\ table_change_date_format.cpp\ table_change_field_type.cpp\ Table_Create_Empty.cpp\ Table_Enumerate.cpp\ table_field_deletion.cpp\ Table_Rotate.cpp\ table_selection.cpp\ table_text_replacer.cpp\ Join_Tables.h\ MLB_Interface.h\ table_categories_to_indicators.h\ table_change_color_format.h\ table_change_date_format.h\ table_change_field_type.h\ Table_Create_Empty.h\ Table_Enumerate.h\ table_field_deletion.h\ Table_Rotate.h\ table_selection.h\ table_text_replacer.h libtable_tools_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) --foreign src/modules/table/table_tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/table/table_tools/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libtable_tools.la: $(libtable_tools_la_OBJECTS) $(libtable_tools_la_DEPENDENCIES) $(EXTRA_libtable_tools_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libtable_tools_la_OBJECTS) $(libtable_tools_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Join_Tables.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Table_Create_Empty.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Table_Enumerate.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Table_Rotate.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_categories_to_indicators.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_change_color_format.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_change_date_format.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_change_field_type.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_field_deletion.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_selection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_text_replacer.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/table/table_tools/table_change_date_format.h0000664000175000017500000001161712565125412026547 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_change_date_format.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_change_date_format.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_change_date_format_H #define HEADER_INCLUDED__table_change_date_format_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Change_Date_Format : public CSG_Module { public: CTable_Change_Date_Format(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Change_Time_Format : public CSG_Module { public: CTable_Change_Time_Format(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_change_date_format_H saga-2.2.3/src/modules/table/table_tools/table_selection.cpp0000664000175000017500000003666612565125412025310 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_selection.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_selection.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_selection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelection_Copy::CSelection_Copy(void) { Set_Name (_TL("Copy Selection")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Copies selected records to a new table." )); Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "OUT_TABLE" , _TL("Copied Selection"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "OUT_SHAPES" , _TL("Copied Selection"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- int CSelection_Copy::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TABLE") ) { CSG_Data_Object *pObject = pParameter->asDataObject(); pParameters->Get_Parameter("OUT_TABLE" )->Set_Enabled(pObject && pObject->Get_ObjectType() == DATAOBJECT_TYPE_Table ); pParameters->Get_Parameter("OUT_SHAPES")->Set_Enabled(pObject && pObject->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ); } return( 1 ); } //--------------------------------------------------------- bool CSelection_Copy::On_Execute(void) { //----------------------------------------------------- CSG_Table *pInput = Parameters("TABLE")->asTable(); if( pInput->Get_Selection_Count() <= 0 ) { Error_Set(_TL("no records in selection")); return( false ); } //----------------------------------------------------- if( pInput->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ) { CSG_Shapes *pOutput = Parameters("OUT_SHAPES")->asShapes(); if( !pOutput || pOutput->Get_Type() == SHAPE_TYPE_Undefined ) { return( false ); } pOutput->Create(((CSG_Shapes *)pInput)->Get_Type(), SG_T(""), pInput); pOutput->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), _TL("Selection"))); for(int i=0; iGet_Selection_Count() && Set_Progress(i, pInput->Get_Selection_Count()); i++) { pOutput->Add_Shape(pInput->Get_Selection(i)); } } //----------------------------------------------------- else // if( pInput->Get_ObjectType() == DATAOBJECT_TYPE_Table ) { CSG_Table *pOutput = Parameters("OUT_TABLE" )->asTable(); if( !pOutput ) { return( false ); } pOutput->Create(pInput); pOutput->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), _TL("Selection"))); for(int i=0; iGet_Selection_Count() && Set_Progress(i, pInput->Get_Selection_Count()); i++) { pOutput->Add_Record(pInput->Get_Selection(i)); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelection_Delete::CSelection_Delete(void) { Set_Name (_TL("Delete Selection")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Deletes selected records from table." )); Parameters.Add_Table( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); } //--------------------------------------------------------- bool CSelection_Delete::On_Execute(void) { CSG_Table *pInput = Parameters("INPUT")->asTable(); if( pInput->Get_Selection_Count() <= 0 ) { Error_Set(_TL("no records in selection")); return( false ); } pInput->Del_Selection(); DataObject_Update(pInput); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelection_Invert::CSelection_Invert(void) { Set_Name (_TL("Invert Selection")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Deselects selected and selects unselected records of given table." )); Parameters.Add_Table( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); } //--------------------------------------------------------- bool CSelection_Invert::On_Execute(void) { CSG_Table *pInput = Parameters("INPUT")->asTable(); pInput->Inv_Selection(); DataObject_Update(pInput); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelect_Numeric::CSelect_Numeric(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Select by Numerical Expression")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Selects records for which the expression is true." )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("attribute to be searched; if not set all attributes will be searched"), true ); Parameters.Add_String( NULL , "EXPRESSION" , _TL("Expression"), _TL(""), SG_T("a > 0") ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("new selection"), _TL("add to current selection"), _TL("select from current selection"), _TL("remove from current selection") ), 0 ); } //--------------------------------------------------------- bool CSelect_Numeric::On_Execute(void) { int Method, Field; CSG_String Expression; CSG_Table *pTable; CSG_Formula Formula; //----------------------------------------------------- pTable = Parameters("TABLE" )->asTable(); Field = Parameters("FIELD" )->asInt(); Expression = Parameters("EXPRESSION")->asString(); Method = Parameters("METHOD" )->asInt(); //----------------------------------------------------- if( !Formula.Set_Formula(Expression) ) { CSG_String Message; if( Formula.Get_Error(Message) ) { Error_Set(Message); } return( false ); } //----------------------------------------------------- double *Values = new double[pTable->Get_Field_Count()]; for(int i=0; iGet_Count() && Set_Progress(i, pTable->Get_Count()); i++) { CSG_Table_Record *pRecord = pTable->Get_Record(i); if( Field >= pTable->Get_Field_Count() ) { for(int j=0; jGet_Field_Count(); j++) { Values[j] = pRecord->asDouble(j); } } else { Values[0] = pRecord->asDouble(Field); } switch( Method ) { case 0: // New selection if( ( pRecord->is_Selected() && !Formula.Get_Value(Values, pTable->Get_Field_Count())) || (!pRecord->is_Selected() && Formula.Get_Value(Values, pTable->Get_Field_Count())) ) { pTable->Select(i, true); } break; case 1: // Add to current selection if( !pRecord->is_Selected() && Formula.Get_Value(Values, pTable->Get_Field_Count()) ) { pTable->Select(i, true); } break; case 2: // Select from current selection if( pRecord->is_Selected() && !Formula.Get_Value(Values, pTable->Get_Field_Count()) ) { pTable->Select(i, true); } break; case 3: // Remove from current selection if( pRecord->is_Selected() && Formula.Get_Value(Values, pTable->Get_Field_Count()) ) { pTable->Select(i, true); } break; } } delete[](Values); //----------------------------------------------------- Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("selected records"), pTable->Get_Selection_Count())); DataObject_Update(pTable); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelect_String::CSelect_String(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Select by String Expression")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Searches for an character string expression in the attributes table and selects records where the expression is found." )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("attribute to be searched; if not set all attributes will be searched"), true ); Parameters.Add_String( NULL , "EXPRESSION" , _TL("Expression"), _TL(""), SG_T("") ); Parameters.Add_Value( NULL , "CASE" , _TL("Case Sensitive"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( NULL , "COMPARE" , _TL("Select if..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("attribute is identical with search expression"), _TL("attribute contains search expression"), _TL("attribute is contained in search expression") ), 1 ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("new selection"), _TL("add to current selection"), _TL("select from current selection"), _TL("remove from current selection") ), 0 ); } //--------------------------------------------------------- bool CSelect_String::On_Execute(void) { int Method; CSG_Table *pTable; //----------------------------------------------------- pTable = Parameters("TABLE" )->asTable(); m_Field = Parameters("FIELD" )->asInt(); m_Expression = Parameters("EXPRESSION")->asString(); m_Case = Parameters("CASE" )->asBool(); m_Compare = Parameters("COMPARE" )->asInt(); Method = Parameters("METHOD" )->asInt(); //----------------------------------------------------- if( m_Case == false ) { m_Expression.Make_Upper(); } //----------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pTable->Get_Count()); i++) { CSG_Table_Record *pRecord = pTable->Get_Record(i); switch( Method ) { case 0: // New selection if( ( pRecord->is_Selected() && !Do_Select(pRecord)) || (!pRecord->is_Selected() && Do_Select(pRecord)) ) { pTable->Select(i, true); } break; case 1: // Add to current selection if( !pRecord->is_Selected() && Do_Select(pRecord) ) { pTable->Select(i, true); } break; case 2: // Select from current selection if( pRecord->is_Selected() && !Do_Select(pRecord) ) { pTable->Select(i, true); } break; case 3: // Remove from current selection if( pRecord->is_Selected() && Do_Select(pRecord) ) { pTable->Select(i, true); } break; } } //----------------------------------------------------- Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("selected records"), pTable->Get_Selection_Count())); DataObject_Update(pTable); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CSelect_String::Do_Compare(const SG_Char *Value) { CSG_String s(Value); if( m_Case == false ) { s.Make_Upper(); } switch( m_Compare ) { case 0: // identical return( m_Expression.Cmp(s) == 0 ); case 1: // contains return( s.Find(m_Expression) >= 0 ); case 2: // contained return( m_Expression.Find(s) >= 0 ); } return( false ); } //--------------------------------------------------------- inline bool CSelect_String::Do_Select(CSG_Table_Record *pRecord) { if( m_Field >= 0 && m_Field < pRecord->Get_Table()->Get_Field_Count() ) { return( Do_Compare(pRecord->asString(m_Field)) ); } for(int i=0; iGet_Table()->Get_Field_Count(); i++) { if( Do_Compare(pRecord->asString(i)) ) { return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/Table_Rotate.cpp0000664000175000017500000001376312565125412024512 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Table_Rotate.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // Table_Rotate.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: SAGA User Group Associaton // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Table_Rotate.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Rotate::CTable_Rotate(void) { Set_Name (_TL("Transpose Table")); Set_Description (_TW( "Transposes a table, i.e. to swap rows and columns." )); Parameters.Add_Table( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CTable_Rotate::~CTable_Rotate(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Rotate::On_Execute(void) { bool bCopy; int x, y; TSG_Data_Type FieldType; CSG_Table *pInput, *pOutput; CSG_Table_Record *pRec_In, *pRec_Out; //----------------------------------------------------- pInput = Parameters("INPUT") ->asTable(); pOutput = Parameters("OUTPUT") ->asTable(); //----------------------------------------------------- if( pInput->Get_Field_Count() > 0 && pInput->Get_Record_Count() > 0 ) { if( pInput != pOutput ) { bCopy = true; } else { bCopy = false; pOutput = SG_Create_Table(); } pOutput->Destroy(); pOutput->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), _TL("rotated"))); FieldType = SG_DATATYPE_String; //------------------------------------------------- pOutput->Add_Field(pInput->Get_Field_Name(0), SG_DATATYPE_String); for(y=0; yGet_Record_Count(); y++) { pOutput->Add_Field(pInput->Get_Record(y)->asString(0), FieldType); } for(y=1; yGet_Field_Count(); y++) { pRec_Out = pOutput->Add_Record(); pRec_Out->Set_Value(0, pInput->Get_Field_Name(y)); for(x=0; xGet_Record_Count(); x++) { pRec_In = pInput->Get_Record(x); if( FieldType == SG_DATATYPE_String ) { pRec_Out->Set_Value(x + 1, pRec_In->asString(y)); } else { pRec_Out->Set_Value(x + 1, pRec_In->asDouble(y)); } } } //------------------------------------------------- if( !bCopy ) { pInput->Assign(pOutput); delete(pOutput); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/Table_Create_Empty.h0000664000175000017500000001137112565125412025273 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Table_Create_Empty.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // Table_Create_Empty.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: SAGA User Group Associaton // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Table_Create_Empty_H #define HEADER_INCLUDED__Table_Create_Empty_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Create_Empty : public CSG_Module { public: CTable_Create_Empty(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Table|Construction") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: void _Set_Field_Count (CSG_Parameters *pAttributes, int nAttributes); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Table_Create_Empty_H saga-2.2.3/src/modules/table/table_tools/table_change_color_format.cpp0000664000175000017500000002044712565125412027304 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_change_color_format.cpp 2322 2014-11-03 21:29:57Z johanvdw $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_change_color_format.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_change_color_format.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Change_Color_Format::CTable_Change_Color_Format(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Change Color Format")); Set_Author (SG_T("Copyrights (c) 2013 by Volker Wichmann")); Set_Description (_TW( "This module allows one to convert table fields from SAGA RGB to R, G, B values and " "vice versa.\n\n" )); //----------------------------------------------------- // 2. Parameters... pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL("The input table"), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD_SAGA_RGB" , _TL("SAGA RGB"), _TL("The field with SAGA RGB values"), true ); Parameters.Add_Table_Field( pNode , "FIELD_RED" , _TL("Red"), _TL("The field with R values (0-255)"), true ); Parameters.Add_Table_Field( pNode , "FIELD_GREEN" , _TL("Green"), _TL("The field with G values (0-255)"), true ); Parameters.Add_Table_Field( pNode , "FIELD_BLUE" , _TL("Blue"), _TL("The field with B values (0-255)"), true ); Parameters.Add_Table( NULL , "OUTPUT" , _TL("Output"), _TL("The output table"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "MODE" , _TL("Mode of Operation"), _TL("Choose the mode of operation"), CSG_String::Format(SG_T("%s|%s|"), _TL("SAGA RGB to R,G,B"), _TL("R,G,B to SAGA RGB") ), 0 ); } //--------------------------------------------------------- CTable_Change_Color_Format::~CTable_Change_Color_Format(void) {} /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Change_Color_Format::On_Execute(void) { //----------------------------------------------------- CSG_Table *pTable = Parameters("OUTPUT") ->asTable(); int iFieldRGB = Parameters("FIELD_SAGA_RGB") ->asInt(); int iFieldR = Parameters("FIELD_RED") ->asInt(); int iFieldG = Parameters("FIELD_GREEN") ->asInt(); int iFieldB = Parameters("FIELD_BLUE") ->asInt(); int iMode = Parameters("MODE") ->asInt(); //----------------------------------------------------- if( pTable && pTable != Parameters("TABLE")->asTable() ) { pTable->Assign (Parameters("TABLE")->asTable()); pTable->Set_Name(Parameters("TABLE")->asTable()->Get_Name()); } else { pTable = Parameters("TABLE")->asTable(); } switch( iMode ) { default: case 0: if( iFieldRGB < 0 ) { SG_UI_Msg_Add_Error(_TL("Please provide a valid SAGA RGB field for this kind of operation!")); return( false ); } pTable->Add_Field(_TL("R"), SG_DATATYPE_Int); iFieldR = pTable->Get_Field_Count() - 1; pTable->Add_Field(_TL("G"), SG_DATATYPE_Int); pTable->Add_Field(_TL("B"), SG_DATATYPE_Int); break; case 1: if( iFieldR < 0 || iFieldG < 0 || iFieldB < 0 ) { SG_UI_Msg_Add_Error(_TL("Please provide a valid R,G,B fields for this kind of operation!")); return( false ); } pTable->Add_Field(_TL("RGB"), SG_DATATYPE_Int); iFieldRGB = pTable->Get_Field_Count() - 1; break; } //----------------------------------------------------- for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); switch( iMode ) { default: case 0: pRecord->Set_Value(iFieldR, SG_GET_R(pRecord->asInt(iFieldRGB))); pRecord->Set_Value(iFieldR + 1, SG_GET_G(pRecord->asInt(iFieldRGB))); pRecord->Set_Value(iFieldR + 2, SG_GET_B(pRecord->asInt(iFieldRGB))); break; case 1: pRecord->Set_Value(iFieldRGB, SG_GET_RGB(pRecord->asInt(iFieldR), pRecord->asInt(iFieldG), pRecord->asInt(iFieldB))); break; } } //----------------------------------------------------- if( pTable == Parameters("TABLE")->asTable() ) { DataObject_Update(pTable); } return( true ); } //--------------------------------------------------------- int CTable_Change_Color_Format::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("MODE")) ) { int iMode = pParameters->Get_Parameter("MODE")->asInt(); pParameters->Get_Parameter("FIELD_SAGA_RGB" )->Set_Enabled(iMode == 0); pParameters->Get_Parameter("FIELD_RED" )->Set_Enabled(iMode == 1); pParameters->Get_Parameter("FIELD_GREEN" )->Set_Enabled(iMode == 1); pParameters->Get_Parameter("FIELD_BLUE" )->Set_Enabled(iMode == 1); } //----------------------------------------------------- return (1); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/table_field_deletion.h0000664000175000017500000001157012565125412025721 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_field_deletion.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_field_deletion.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_field_deletion_H #define HEADER_INCLUDED__table_field_deletion_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Field_Deletion : public CSG_Module { public: CTable_Field_Deletion(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_field_deletion_H saga-2.2.3/src/modules/table/table_tools/Table_Rotate.h0000664000175000017500000000741012565125412024147 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Table_Rotate.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // Table_Rotate.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: SAGA User Group Associaton // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Table_Rotate_H #define HEADER_INCLUDED__Table_Rotate_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CTable_Rotate : public CSG_Module { public: CTable_Rotate(void); virtual ~CTable_Rotate(void); protected: virtual bool On_Execute(void); }; #endif // #ifndef HEADER_INCLUDED__Table_Rotate_H saga-2.2.3/src/modules/table/table_tools/table_selection.h0000664000175000017500000001451312565125412024740 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_selection.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_selection.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_selection_H #define HEADER_INCLUDED__table_selection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelection_Copy : public CSG_Module { public: CSelection_Copy(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Table|Selection") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelection_Delete : public CSG_Module { public: CSelection_Delete(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Table|Selection") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelection_Invert : public CSG_Module { public: CSelection_Invert(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Table|Selection") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelect_Numeric : public CSG_Module { public: CSelect_Numeric(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Table|Selection") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelect_String : public CSG_Module { public: CSelect_String(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Table|Selection") ); } protected: virtual bool On_Execute (void); private: bool m_Case; int m_Field, m_Compare; CSG_String m_Expression; bool Do_Compare (const SG_Char *Value); bool Do_Select (CSG_Table_Record *pRecord); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_selection_H saga-2.2.3/src/modules/table/table_tools/Table_Create_Empty.cpp0000664000175000017500000002450412565125412025630 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Table_Create_Empty.cpp 2355 2014-12-19 09:55:41Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // Table_Create_Empty.cpp // // // // Copyright (C) 2005 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: SAGA User Group Associaton // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Table_Create_Empty.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_NODE(i) CSG_String::Format(SG_T("NODE%03d"), i) #define GET_NAME(i) CSG_String::Format(SG_T("NAME%03d"), i) #define GET_TYPE(i) CSG_String::Format(SG_T("TYPE%03d"), i) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Create_Empty::CTable_Create_Empty(void) { //----------------------------------------------------- Set_Name (_TL("Create New Table")); Set_Author (SG_T("O. Conrad (c) 2005")); Set_Description (CSG_String::Format(_TW( "Creates a new empty table.\n\n" "Possible field types are:\n" "- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n"), SG_Data_Type_Get_Name(SG_DATATYPE_String).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Date ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Color ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Byte ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Char ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Word ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Short ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_DWord ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Int ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_ULong ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Long ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Float ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Double).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Binary).c_str() )); //----------------------------------------------------- Parameters.Add_Table_Output( NULL , "TABLE" , _TL("Table"), _TL("") ); Parameters.Add_String( NULL , "NAME" , _TL("Name"), _TL(""), _TL("New Table") ); Parameters.Add_Value( NULL , "NFIELDS" , _TL("Number of Attributes"), _TL(""), PARAMETER_TYPE_Int , 2, 1, true ); Parameters.Add_Parameters( NULL , "FIELDS" , _TL("Attributes"), _TL("") ); //----------------------------------------------------- CSG_Parameters *pAttributes = Parameters("FIELDS")->asParameters(); _Set_Field_Count(pAttributes, Parameters("NFIELDS")->asInt()); pAttributes->Get_Parameter(GET_NAME(0))->Set_Value(_TL("ID")); pAttributes->Get_Parameter(GET_TYPE(0))->Set_Value(3); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTable_Create_Empty::_Set_Field_Count(CSG_Parameters *pAttributes, int nAttributes) { //----------------------------------------------------- CSG_String Types; Types = CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"), SG_Data_Type_Get_Name(SG_DATATYPE_String).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Date ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Color ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Byte ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Char ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Word ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Short ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_DWord ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Int ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_ULong ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Long ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Float ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Double).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Binary).c_str() ); //----------------------------------------------------- if( pAttributes && nAttributes > 0 ) { int nCurrent = pAttributes->Get_Count() / 3; if( nCurrent < nAttributes ) { for(int i=nCurrent; iAdd_Node( NULL , GET_NODE(i), CSG_String::Format(SG_T("%i. %s"), i + 1, _TL("Attribute")), _TL("") ); pAttributes->Add_String( pNode , GET_NAME(i), _TL("Name"), _TL(""), _TL("Name") ); pAttributes->Add_Choice( pNode , GET_TYPE(i), _TL("Type"), _TL(""), Types ); } } else if( nCurrent > nAttributes ) { CSG_Parameters Tmp; Tmp.Assign(pAttributes); pAttributes->Destroy(); pAttributes->Set_Name(Tmp.Get_Name()); for(int i=0; iAdd_Node( NULL , GET_NODE(i), CSG_String::Format(SG_T("%i. %s"), i + 1, _TL("Attribute")), _TL("") ); pAttributes->Add_String( pNode , GET_NAME(i), _TL("Name"), _TL(""), Tmp(GET_NAME(i)) ? Tmp(GET_NAME(i))->asString() : _TL("Name") ); pAttributes->Add_Choice( pNode , GET_TYPE(i), _TL("Type"), _TL(""), Types, Tmp(GET_TYPE(i)) ? Tmp(GET_TYPE(i))->asInt() : 0 ); } } } } //--------------------------------------------------------- int CTable_Create_Empty::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("NFIELDS")) ) { _Set_Field_Count(pParameters->Get_Parameter("FIELDS")->asParameters(), pParameter->asInt()); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Create_Empty::On_Execute(void) { CSG_Table *pTable = SG_Create_Table(); pTable->Set_Name(Parameters("NAME")->asString()); //----------------------------------------------------- int i, n; TSG_Data_Type Type; CSG_Parameters *pAttributes; pAttributes = Parameters("FIELDS")->asParameters(); n = pAttributes->Get_Count() / 3; for(i=0; iGet_Parameter(GET_TYPE(i))->asInt() ) { default: case 0: Type = SG_DATATYPE_String; break; case 1: Type = SG_DATATYPE_Date; break; case 2: Type = SG_DATATYPE_Color; break; case 3: Type = SG_DATATYPE_Byte; break; case 4: Type = SG_DATATYPE_Char; break; case 5: Type = SG_DATATYPE_Word; break; case 6: Type = SG_DATATYPE_Short; break; case 7: Type = SG_DATATYPE_DWord; break; case 8: Type = SG_DATATYPE_Int; break; case 9: Type = SG_DATATYPE_ULong; break; case 10: Type = SG_DATATYPE_Long; break; case 11: Type = SG_DATATYPE_Float; break; case 12: Type = SG_DATATYPE_Double; break; case 13: Type = SG_DATATYPE_Binary; break; } pTable->Add_Field(pAttributes->Get_Parameter(GET_NAME(i))->asString(), Type); } Parameters("TABLE")->Set_Value(pTable); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/table_change_color_format.h0000664000175000017500000001113312565125412026741 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_change_color_format.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_change_color_format.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_change_color_format_H #define HEADER_INCLUDED__table_change_color_format_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Change_Color_Format : public CSG_Module { public: CTable_Change_Color_Format(void); virtual ~CTable_Change_Color_Format(void); protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_change_color_format_H saga-2.2.3/src/modules/table/table_tools/Join_Tables.h0000664000175000017500000001206312565125412023773 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Join_Tables.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Join_Tables.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Join_Tables_H #define HEADER_INCLUDED__Join_Tables_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CJoin_Tables_Base : public CSG_Module { protected: void Initialise (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int Cmp_Keys (CSG_Table_Value *pA, CSG_Table_Value *pB, bool bCmpNumeric); }; //--------------------------------------------------------- class CJoin_Tables : public CJoin_Tables_Base { public: CJoin_Tables(void); }; //--------------------------------------------------------- class CJoin_Tables_Shapes : public CJoin_Tables_Base { public: CJoin_Tables_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Table") ); } }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Append_Cols : public CSG_Module { public: CTable_Append_Cols(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Join_Tables_H saga-2.2.3/src/modules/table/table_tools/table_text_replacer.cpp0000664000175000017500000002064412565125412026151 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_text_replacer.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_text_replacer.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_text_replacer.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define ADD_REPLACEMENT(FROM, TO) { CSG_Table_Record *pR = pTable->Add_Record(); pR->Set_Value(0, FROM); pR->Set_Value(1, TO); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Text_Replacer::CTable_Text_Replacer(void) { //----------------------------------------------------- Set_Name (_TL("Replace Text")); Set_Author (_TL("O.Conrad (c) 2013")); Set_Description (_TW( "Replaces in the selected attribute or, if not specified, in all text attributes " "text strings with replacements as defined in table 'Text Replacements'." )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL(""), true ); Parameters.Add_Table( NULL , "OUT_TABLE" , _TL("Table with Text Replacements"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Shapes( NULL , "OUT_SHAPES" , _TL("Shapes with Text Replacements"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); //----------------------------------------------------- CSG_Table *pTable = Parameters.Add_FixedTable( NULL , "REPLACE" , _TL("Text Replacements"), _TL("") )->asTable(); pTable->Add_Field(_TL("Original" ), SG_DATATYPE_String); pTable->Add_Field(_TL("Replacement"), SG_DATATYPE_String); ADD_REPLACEMENT("ä", "ae"); ADD_REPLACEMENT("ö", "oe"); ADD_REPLACEMENT("ü", "ue"); ADD_REPLACEMENT("Ä", "Ae"); ADD_REPLACEMENT("Ö", "Oe"); ADD_REPLACEMENT("Ü", "Ue"); ADD_REPLACEMENT("ß", "sz"); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTable_Text_Replacer::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TABLE") ) { CSG_Data_Object *pObject = pParameter->asDataObject(); pParameters->Get_Parameter("OUT_TABLE" )->Set_Enabled(pObject && pObject->Get_ObjectType() == DATAOBJECT_TYPE_Table ); pParameters->Get_Parameter("OUT_SHAPES")->Set_Enabled(pObject && pObject->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Text_Replacer::On_Execute(void) { //----------------------------------------------------- CSG_Table *pTable = Parameters("TABLE")->asTable(); if( pTable->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ) { CSG_Shapes *pOutput = Parameters("OUT_SHAPES")->asShapes(); if( pOutput ) { pOutput->Create(*((CSG_Shapes *)pTable)); pTable = pOutput; } } else // if( pTable->Get_ObjectType() == DATAOBJECT_TYPE_Table ) { CSG_Table *pOutput = Parameters("OUT_TABLE" )->asTable(); if( pOutput ) { pOutput->Create(*pTable); pTable = pOutput; } } if( pTable != Parameters("TABLE")->asTable() ) { pTable->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pTable->Get_Name(), _TL("Replacements"))); } //----------------------------------------------------- m_pReplacer = Parameters("REPLACE")->asTable(); int iField = Parameters("FIELD" )->asInt (); size_t nChanges = 0; for(int iRecord=0; iRecordGet_Count(); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); if( iField >= 0 ) { nChanges += Replace(pRecord, iField); } else for(int i=0; iGet_Field_Count(); i++) { if( pTable->Get_Field_Type(i) == SG_DATATYPE_String ) { nChanges += Replace(pRecord, i); } } } //----------------------------------------------------- Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("number of replacements"), nChanges)); if( pTable == Parameters("TABLE")->asTable() ) { DataObject_Update(pTable); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline size_t CTable_Text_Replacer::Replace(CSG_Table_Record *pRecord, int iField) { CSG_String Text(pRecord->asString(iField)); size_t nChanges = 0; for(int i=0; iGet_Count(); i++) { CSG_Table_Record *pReplace = m_pReplacer->Get_Record(i); nChanges += Text.Replace(pReplace->asString(0), pReplace->asString(1)); } if( nChanges > 0 ) { pRecord->Set_Value(iField, Text); } return( nChanges ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/MLB_Interface.cpp0000664000175000017500000001336012565125412024530 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2481 2015-04-30 15:31:49Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@gwdg.de // // // // 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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Tools") ); case MLB_INFO_Category: return( _TL("Table") ); case MLB_INFO_Author: return( _TL("SAGA User Group Associaton (c) 2002-2013") ); case MLB_INFO_Description: return( _TL("Tools for the creation and manipulation of tables.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Table|Tools") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Table_Create_Empty.h" #include "Table_Rotate.h" #include "Table_Enumerate.h" #include "Join_Tables.h" #include "table_change_date_format.h" #include "table_change_field_type.h" #include "table_change_color_format.h" #include "table_text_replacer.h" #include "table_field_deletion.h" #include "table_selection.h" #include "table_categories_to_indicators.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CTable_Create_Empty ); case 1: return( new CTable_Rotate ); case 2: return( new CTable_Enumerate ); case 3: return( new CJoin_Tables ); case 4: return( new CJoin_Tables_Shapes ); case 5: return( new CTable_Change_Date_Format ); case 6: return( new CTable_Change_Time_Format ); case 7: return( new CTable_Change_Field_Type ); case 8: return( new CTable_Append_Cols ); case 9: return( new CTable_Change_Color_Format ); case 10: return( new CTable_Text_Replacer ); case 11: return( new CTable_Field_Deletion ); case 15: return( new CSelection_Copy ); case 16: return( new CSelection_Delete ); case 17: return( new CSelection_Invert ); case 18: return( new CSelect_Numeric ); case 19: return( new CSelect_String ); case 20: return( new CTable_Categories_to_Indicators ); case 25: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/table/table_tools/Table_Enumerate.h0000664000175000017500000000743512565125412024645 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Table_Enumerate.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // Table_Enumerate.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: SAGA User Group Associaton // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Table_Enumerate_H #define HEADER_INCLUDED__Table_Enumerate_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CTable_Enumerate : public CSG_Module { public: CTable_Enumerate(void); virtual ~CTable_Enumerate(void); protected: virtual bool On_Execute(void); }; #endif // #ifndef HEADER_INCLUDED__Table_Enumerate_H saga-2.2.3/src/modules/table/table_tools/table_change_field_type.h0000664000175000017500000001075512565125412026410 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_change_field_type.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_change_field_type.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_change_field_type_H #define HEADER_INCLUDED__table_change_field_type_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Change_Field_Type : public CSG_Module { public: CTable_Change_Field_Type(void); protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_change_field_type_H saga-2.2.3/src/modules/table/table_tools/Makefile.am0000664000175000017500000000213512565125412023464 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 2366 2015-01-09 15:13:32Z oconrad $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libtable_tools.la libtable_tools_la_SOURCES =\ Join_Tables.cpp\ MLB_Interface.cpp\ table_categories_to_indicators.cpp\ table_change_color_format.cpp\ table_change_date_format.cpp\ table_change_field_type.cpp\ Table_Create_Empty.cpp\ Table_Enumerate.cpp\ table_field_deletion.cpp\ Table_Rotate.cpp\ table_selection.cpp\ table_text_replacer.cpp\ Join_Tables.h\ MLB_Interface.h\ table_categories_to_indicators.h\ table_change_color_format.h\ table_change_date_format.h\ table_change_field_type.h\ Table_Create_Empty.h\ Table_Enumerate.h\ table_field_deletion.h\ Table_Rotate.h\ table_selection.h\ table_text_replacer.h libtable_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/table/table_tools/table_change_field_type.cpp0000664000175000017500000002114412565125412026735 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_change_field_type.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_change_field_type.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_change_field_type.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Change_Field_Type::CTable_Change_Field_Type(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Change Field Type")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "" )); //----------------------------------------------------- // 2. Parameters... pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Field"), _TL("") ); Parameters.Add_Table( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Data Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"), SG_Data_Type_Get_Name(SG_DATATYPE_String).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Date ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Color ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Byte ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Char ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Word ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Short ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_DWord ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Int ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_ULong ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Long ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Float ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Double).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Binary).c_str() ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTable_Change_Field_Type::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("TABLE")) || !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FIELD")) ) { CSG_Table *pTable = pParameters->Get_Parameter("TABLE")->asTable(); if( pTable ) { int Type; switch( pTable->Get_Field_Type(pParameters->Get_Parameter("FIELD")->asInt()) ) { default: case SG_DATATYPE_String: Type = 0; break; case SG_DATATYPE_Date: Type = 1; break; case SG_DATATYPE_Color: Type = 2; break; case SG_DATATYPE_Byte: Type = 3; break; case SG_DATATYPE_Char: Type = 4; break; case SG_DATATYPE_Word: Type = 5; break; case SG_DATATYPE_Short: Type = 6; break; case SG_DATATYPE_DWord: Type = 7; break; case SG_DATATYPE_Int: Type = 8; break; case SG_DATATYPE_ULong: Type = 9; break; case SG_DATATYPE_Long: Type = 10; break; case SG_DATATYPE_Float: Type = 11; break; case SG_DATATYPE_Double: Type = 12; break; case SG_DATATYPE_Binary: Type = 13; break; } pParameters->Get_Parameter("TYPE")->Set_Value(Type); } } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Change_Field_Type::On_Execute(void) { //----------------------------------------------------- TSG_Data_Type Type; switch( Parameters("TYPE")->asInt() ) { default: case 0: Type = SG_DATATYPE_String; break; case 1: Type = SG_DATATYPE_Date; break; case 2: Type = SG_DATATYPE_Color; break; case 3: Type = SG_DATATYPE_Byte; break; case 4: Type = SG_DATATYPE_Char; break; case 5: Type = SG_DATATYPE_Word; break; case 6: Type = SG_DATATYPE_Short; break; case 7: Type = SG_DATATYPE_DWord; break; case 8: Type = SG_DATATYPE_Int; break; case 9: Type = SG_DATATYPE_ULong; break; case 10: Type = SG_DATATYPE_Long; break; case 11: Type = SG_DATATYPE_Float; break; case 12: Type = SG_DATATYPE_Double; break; case 13: Type = SG_DATATYPE_Binary; break; } //----------------------------------------------------- CSG_Table *pTable = Parameters("OUTPUT")->asTable(); if( pTable && pTable != Parameters("TABLE")->asTable() ) { pTable->Assign (Parameters("TABLE")->asTable()); pTable->Set_Name(Parameters("TABLE")->asTable()->Get_Name()); } else { pTable = Parameters("TABLE")->asTable(); } //----------------------------------------------------- int Field = Parameters("FIELD" )->asInt(); if( Type == pTable->Get_Field_Type(Field) ) { Error_Set(_TL("nothing to do: original and desired field types are identical")); return( false ); } //----------------------------------------------------- pTable->Set_Field_Type(Field, Type); //----------------------------------------------------- if( pTable == Parameters("TABLE")->asTable() ) { DataObject_Update(pTable); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/table_tools/MLB_Interface.h0000664000175000017500000000771512565125412024204 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@gwdg.de // // // // contact: SAGA User Group Associaton // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_tools_H #define HEADER_INCLUDED__table_tools_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef table_tools_EXPORTS #define table_tools_EXPORT _SAGA_DLL_EXPORT #else #define table_tools_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_tools_H saga-2.2.3/src/modules/table/table_tools/table_categories_to_indicators.h0000664000175000017500000001166412565125412030025 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_categories_to_indicators.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_categories_to_indicators.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_categories_to_indicators_H #define HEADER_INCLUDED__table_categories_to_indicators_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Categories_to_Indicators : public CSG_Module { public: CTable_Categories_to_Indicators(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_categories_to_indicators_H saga-2.2.3/src/modules/table/table_tools/table_text_replacer.h0000664000175000017500000001173212565125412025614 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_text_replacer.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_tools // // // //-------------------------------------------------------// // // // table_text_replacer.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_text_replacer_H #define HEADER_INCLUDED__table_text_replacer_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Text_Replacer : public CSG_Module { public: CTable_Text_Replacer(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Table *m_pReplacer; size_t Replace (CSG_Table_Record *pRecord, int iField); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_text_replacer_H saga-2.2.3/src/modules/table/table_tools/Table_Enumerate.cpp0000664000175000017500000001502212565125412025167 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Table_Enumerate.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // Table_Enumerate.cpp // // // // Copyright (C) 2005 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: SAGA User Group Associaton // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Table_Enumerate.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Enumerate::CTable_Enumerate(void) { CSG_Parameter *pNode; Set_Name(_TL("Enumerate Table Field")); Set_Description(_TW( "Enumerate attribute of a table, i.e. assign to identical values of chosen attribute field unique identifiers." )); pNode = Parameters.Add_Table( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL(""), true ); Parameters.Add_Table( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } //--------------------------------------------------------- CTable_Enumerate::~CTable_Enumerate(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Enumerate::On_Execute(void) { int iField, iField_ID; CSG_Table *pTable, *pOutput; //----------------------------------------------------- pTable = Parameters("INPUT") ->asTable(); pOutput = Parameters("OUTPUT") ->asTable(); iField = Parameters("FIELD") ->asInt(); //----------------------------------------------------- if( pTable->Get_Record_Count() <= 0 ) { Error_Set(_TL("no records in data set")); return( false ); } //----------------------------------------------------- if( pOutput != NULL && pOutput != pTable ) { pOutput->Create (*pTable); pOutput->Set_Name ( pTable->Get_Name()); pTable = pOutput; } pTable->Add_Field(_TL("ENUM_ID"), SG_DATATYPE_Int); iField_ID = pTable->Get_Field_Count() - 1; //----------------------------------------------------- if( iField >= 0 && iField < pTable->Get_Field_Count() ) { TSG_Table_Index_Order old_Order = pTable->Get_Index_Order(0); int old_Field = pTable->Get_Index_Field(0); pTable->Set_Index(iField, TABLE_INDEX_Descending); CSG_String Value = pTable->Get_Record_byIndex(0)->asString(iField); for(int iRecord=0, iID=1; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record_byIndex(iRecord); if( Value.Cmp(pRecord->asString(iField)) ) { Value = pRecord->asString(iField); iID++; } pRecord->Set_Value(iField_ID, iID); } pTable->Set_Index(old_Field, old_Order); } else { for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); pRecord->Set_Value(iField_ID, iRecord + 1); } } //----------------------------------------------------- if( pTable == Parameters("INPUT")->asTable() ) { DataObject_Update(pTable); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/table/Makefile.in0000664000175000017500000004553212622651175021202 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/table DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 = table_tools table_calculus 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) --foreign src/modules/table/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/table/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/table/Makefile.am0000664000175000017500000000004612565125412021154 0ustar00oconradoconrad00000000000000SUBDIRS = table_tools table_calculus saga-2.2.3/src/modules/Makefile.in0000664000175000017500000004565212622651156020115 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 = climate contrib db docs garden grid imagery io pointcloud projection shapes simulation statistics table terrain_analysis tin 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) --foreign src/modules/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/pointcloud/0000775000175000017500000000000012634325744020220 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/pointcloud/Makefile.in0000664000175000017500000004570312622651167022274 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/pointcloud DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = pointcloud_tools pointcloud_viewer 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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@ @WITH_GUI_FALSE@SUBDIRS = pointcloud_tools @WITH_GUI_TRUE@SUBDIRS = pointcloud_viewer pointcloud_tools 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) --foreign src/modules/pointcloud/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/pointcloud/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/0000775000175000017500000000000012634325744023761 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/points_view_control.h0000664000175000017500000001515512565125407030244 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_view_control.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // SAGA_GUI_API // // // //-------------------------------------------------------// // // // points_view_control.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_view_control_H #define HEADER_INCLUDED__points_view_control_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { COLOR_MODE_RGB, COLOR_MODE_RED, COLOR_MODE_BLUE }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_View_Control : public wxPanel { public: CPoints_View_Control(wxWindow *pParent, CSG_PointCloud *pPoints, CSG_Parameters &Settings); virtual ~CPoints_View_Control(void); bool m_bCentral, m_bStereo, m_bScale; int m_zField, m_cField; double m_xRotate, m_yRotate, m_zRotate, m_xShift, m_yShift, m_zShift, m_dCentral, m_Detail; void Update_View (void); void Update_Extent (CSG_Rect Extent); 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); void On_Mouse_RUp (wxMouseEvent &event); void On_Mouse_MDown (wxMouseEvent &event); void On_Mouse_MUp (wxMouseEvent &event); void On_Mouse_Motion (wxMouseEvent &event); void On_Mouse_Wheel (wxMouseEvent &event); private: bool m_bColorAsRGB, m_bDim; int m_nSelection, *m_pSelection, m_Color_Mode, m_Size_Def, m_BGColor; double m_xDown, m_yDown, m_cMin, m_cScale, m_Size_Scale, m_Dim_A, m_Dim_B, m_zMin, m_zMax; double r_sin_x, r_sin_y, r_sin_z, r_cos_x, r_cos_y, r_cos_z, r_xc, r_yc, r_zc, r_Scale, r_Scale_z; CSG_Rect m_Extent; CSG_Matrix m_Image_zMax; CSG_Simple_Statistics m_zStats, m_cStats; CSG_Parameters *m_pSettings; CSG_Colors *m_pColors; CSG_PointCloud *m_pPoints; wxPoint m_Mouse_Down; wxImage m_Image; void _Set_Size (void); bool _Draw_Image (void); void _Draw_Background (void); void _Draw_Point (int iPoint); 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_Z _Get_Projection (TSG_Point_Z p); DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_view_control_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/points_view_module.cpp0000664000175000017500000001250012565125407030373 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_view_module.cpp 2289 2014-10-16 13:45:05Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // points_view_module // // // //-------------------------------------------------------// // // // points_view_module.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "points_view_module.h" #include "points_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_View_Module::CPoints_View_Module(void) { //----------------------------------------------------- Set_Name (_TL("[deprecated] Point Cloud Viewer")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "This module is a 3D viewer for SAGA Point Clouds. Amongst others, " "the viewer supports attribute based coloring, a map view to control " "the area-of-interest, point size scaling based on distance, level " "of detail control and an anaglyph modus (to use with red/blue or " "red/green glasses).\n\n" "Module development was supported by " "http://Laserdata GmbH, Austria\n" "and " "http://alpS GmbH, Austria\n" )); //----------------------------------------------------- Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_View_Module::On_Execute(void) { if( !SG_UI_Get_Window_Main() ) { Message_Add(_TL("point cloud viewer can only be run from graphical user interface")); return( false ); } CSG_PointCloud *pPoints = Parameters("POINTS")->asPointCloud(); if( pPoints->Get_Count() <= 0 ) { Message_Add(_TL("point cloud viewer will not be started, because point cloud has no points")); return( false ); } CPoints_View_Dialog dlg(pPoints); dlg.ShowModal(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.h0000664000175000017500000001237712565125407030026 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_view_dialog.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // image_io // // // //-------------------------------------------------------// // // // points_view_dialog.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_view_dialog_H #define HEADER_INCLUDED__points_view_dialog_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_View_Dialog : public CSGDI_Dialog { public: CPoints_View_Dialog(CSG_PointCloud *pPoints); void Update_Rotation (void); void Update_Extent (void); private: wxButton *m_pBtn_Prop; wxCheckBox *m_pCheck_Central, *m_pCheck_Stereo, *m_pCheck_Scale; wxChoice *m_pField_Color, *m_pField_Z; wxTextCtrl *m_pFormula, *m_pParameters; CSGDI_Slider *m_pSlide_xRotate, *m_pSlide_yRotate, *m_pSlide_zRotate, *m_pSlide_Central, *m_pSlide_Detail; class CPoints_View_Control *m_pView; class CPoints_View_Extent *m_pExtent; CSG_Parameters m_Settings; void On_Update_Control (wxCommandEvent &event); void On_Update_Choices (wxCommandEvent &event); void On_Button (wxCommandEvent &event); void On_Mouse_Wheel (wxMouseEvent &event); DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_view_dialog_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/points_view_extent.cpp0000664000175000017500000003212612565125407030423 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_view_extent.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // SAGA_GUI_API // // // //-------------------------------------------------------// // // // points_view_extent.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #ifdef __BORLANDC__ #pragma hdrstop #endif #include #include #include #include //--------------------------------------------------------- #include "points_view_extent.h" #include "points_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define m_Settings (*m_pSettings) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(CPoints_View_Extent, wxPanel) EVT_SIZE (CPoints_View_Extent::On_Size) EVT_ERASE_BACKGROUND (CPoints_View_Extent::On_EraseBackGround) EVT_PAINT (CPoints_View_Extent::On_Paint) EVT_LEFT_DOWN (CPoints_View_Extent::On_Mouse_LDown) EVT_LEFT_UP (CPoints_View_Extent::On_Mouse_LUp) EVT_RIGHT_DOWN (CPoints_View_Extent::On_Mouse_RDown) EVT_RIGHT_UP (CPoints_View_Extent::On_Mouse_RUp) EVT_MOTION (CPoints_View_Extent::On_Mouse_Motion) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_View_Extent::CPoints_View_Extent(wxWindow *pParent, CSG_PointCloud *pPoints, CSG_Parameters &Settings, wxSize Size) : wxPanel(pParent, wxID_ANY, wxDefaultPosition, Size, wxTAB_TRAVERSAL|wxSUNKEN_BORDER|wxNO_FULL_REPAINT_ON_RESIZE) { m_pPoints = pPoints; m_pSettings = &Settings; m_cField = 2; m_Select = wxRect(0, 0, GetClientSize().x - 1, GetClientSize().y - 1); //----------------------------------------------------- CSG_Parameter *pNode = m_pSettings->Add_Node(NULL, "NODE_EXTENT", _TL("Zoom View"), _TL("")); m_pSettings->Add_Range( pNode , "EXT_C_RANGE" , _TL("Colors Value Range"), _TL("") ); //----------------------------------------------------- _Draw_Image(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_View_Extent::On_Size(wxSizeEvent &event) { _Draw_Image(); event.Skip(); } //--------------------------------------------------------- void CPoints_View_Extent::On_EraseBackGround(wxEraseEvent &event) { // event.Skip(); } //--------------------------------------------------------- void CPoints_View_Extent::On_Paint(wxPaintEvent &WXUNUSED(event)) { if( m_Image.IsOk() && m_Image.GetWidth() > 0 && m_Image.GetHeight() > 0 ) { wxPaintDC dc(this); dc.DrawBitmap(wxBitmap(m_Image), 0, 0, false); dc.SetPen(wxPen(*wxRED)); int ax = m_Select.GetX(); int ay = m_Select.GetY(); int bx = m_Select.GetX() + m_Select.GetWidth(); int by = m_Select.GetY() + m_Select.GetHeight(); dc.DrawLine(ax, ay, bx, ay); dc.DrawLine(bx, ay, bx, by); dc.DrawLine(bx, by, ax, by); dc.DrawLine(ax, by, ax, ay); } } //--------------------------------------------------------- void CPoints_View_Extent::Update_View(void) { if( _Draw_Image() ) { Refresh(false); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_View_Extent::On_Mouse_LDown(wxMouseEvent &event) { m_Mouse_Down = m_Mouse_Move = event.GetPosition(); CaptureMouse(); } //--------------------------------------------------------- void CPoints_View_Extent::On_Mouse_LUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } _Draw_Inverse(m_Mouse_Down, m_Mouse_Move); wxPoint p; p.x = event.GetX() < 0 ? 0 : event.GetX() >= GetClientSize().x ? GetClientSize().x - 1 : event.GetX(); p.y = event.GetY() < 0 ? 0 : event.GetY() >= GetClientSize().y ? GetClientSize().y - 1 : event.GetY(); if( m_Mouse_Down.x != p.x || m_Mouse_Down.y != p.y ) { m_Select = wxRect(wxPoint(m_Mouse_Down.x, m_Mouse_Down.y), p); } else { m_Select.SetX(p.x - m_Select.GetWidth () / 2); m_Select.SetY(p.y - m_Select.GetHeight() / 2); } Refresh(false); ((CPoints_View_Dialog *)GetParent())->Update_Extent(); } //--------------------------------------------------------- void CPoints_View_Extent::On_Mouse_RDown(wxMouseEvent &event) { m_Mouse_Down = m_Mouse_Move = event.GetPosition(); CaptureMouse(); } //--------------------------------------------------------- void CPoints_View_Extent::On_Mouse_RUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } m_Select = wxRect(0, 0, GetClientSize().x - 1, GetClientSize().y - 1); Refresh(false); ((CPoints_View_Dialog *)GetParent())->Update_Extent(); } //--------------------------------------------------------- void CPoints_View_Extent::On_Mouse_Motion(wxMouseEvent &event) { if( HasCapture() && event.Dragging() ) { if( event.LeftIsDown() ) { _Draw_Inverse(m_Mouse_Down, m_Mouse_Move); _Draw_Inverse(m_Mouse_Down, event.GetPosition()); } } m_Mouse_Move = event.GetPosition(); } //--------------------------------------------------------- TSG_Rect CPoints_View_Extent::Get_Extent(void) { TSG_Rect r; double d = m_Extent.Get_XRange() / m_Image.GetWidth(); r.xMin = m_Extent.Get_XMin() + d * m_Select.GetX(); r.xMax = m_Extent.Get_XMin() + d * (m_Select.GetX() + m_Select.GetWidth()); r.yMax = m_Extent.Get_YMax() - d * m_Select.GetY(); r.yMin = m_Extent.Get_YMax() - d * (m_Select.GetY() + m_Select.GetHeight()); return( r ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_View_Extent::_Draw_Image(void) { if( m_pPoints->Get_Count() <= 0 || m_pPoints->Get_Extent().Get_XRange() <= 0.0 || m_pPoints->Get_Extent().Get_YRange() <= 0.0 || m_cField < 0 || m_cField >= m_pPoints->Get_Field_Count() ) { return( false ); } //------------------------------------------------- wxSize Size; double dx, dy; Size = GetClientSize(); if (Size.x <= 0 || Size.y <= 0) // temporary hack for wxGTK to suppress 'assert "isOK()" failed in Get_Height(): invalid image' return( false ); // when dlg.ShowModal() is called; during construction everything is fine, but the first call of // the On_Size() event returns a client size of 0 m_Image .Create(Size.x, Size.y); m_Image_Value .Create(Size.x, Size.y); m_Image_Count .Create(Size.x, Size.y); //------------------------------------------------- m_Extent = m_pPoints->Get_Extent(); if( (dx = Size.y / (double)Size.x) < (m_Extent.Get_YRange() / m_Extent.Get_XRange()) ) { dx = 0.5 * (m_Extent.Get_XRange() - m_Extent.Get_YRange() / dx); m_Extent.m_rect.xMin += dx; m_Extent.m_rect.xMax -= dx; } else { dy = 0.5 * (m_Extent.Get_YRange() - m_Extent.Get_XRange() * dx); m_Extent.m_rect.yMin += dy; m_Extent.m_rect.yMax -= dy; } dx = Size.x / m_Extent.Get_XRange(); dy = Size.y / m_Extent.Get_YRange(); //------------------------------------------------- bool bColorAsRGB = m_Settings("C_AS_RGB")->asBool(); for(int i=0; iGet_Count(); i++) { 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() ) { if( !bColorAsRGB ) { m_Image_Value[iy][ix] += p.z; } else { m_Image_Value[iy][ix] = p.z; } m_Image_Count[iy][ix]++; } } //------------------------------------------------- double zMin = m_pPoints->Get_Mean(m_cField) - 1.5 * m_pPoints->Get_StdDev(m_cField); double zRange = m_pPoints->Get_Mean(m_cField) + 1.5 * m_pPoints->Get_StdDev(m_cField) - zMin; CSG_Colors *pColors = m_Settings("COLORS")->asColors(); for(int iy=0; iy 0 ) { 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 { _Draw_Pixel(ix, iy, 0); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CPoints_View_Extent::_Draw_Pixel(int x, int y, int color) { if( x >= 0 && x < m_Image.GetWidth() && y >= 0 && y < m_Image.GetHeight() ) { BYTE *pRGB = m_Image.GetData() + 3 * ((m_Image.GetHeight() - y - 1) * m_Image.GetWidth() + x); *pRGB = SG_GET_R(color); pRGB++; *pRGB = SG_GET_G(color); pRGB++; *pRGB = SG_GET_B(color); } } //--------------------------------------------------------- void CPoints_View_Extent::_Draw_Inverse(wxPoint pa, wxPoint pb) { wxClientDC dc(this); dc.SetLogicalFunction(wxINVERT); dc.DrawRectangle(pa.x, pa.y, pb.x - pa.x, pb.y - pa.y); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/Makefile.in0000664000175000017500000005620112622651170026022 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/pointcloud/pointcloud_viewer DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libpointcloud_viewer_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la \ $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la am_libpointcloud_viewer_la_OBJECTS = MLB_Interface.lo \ points_view_control.lo points_view_dialog.lo \ points_view_extent.lo points_view_module.lo libpointcloud_viewer_la_OBJECTS = \ $(am_libpointcloud_viewer_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libpointcloud_viewer_la_SOURCES) DIST_SOURCES = $(libpointcloud_viewer_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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@ @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @SAGA_UNICODE_FALSE@DEP_DEFS = -fPIC `wx-config --unicode=no --static=no --cxxflags` $(DBGFLAGS) @SAGA_UNICODE_TRUE@DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` -D_SAGA_UNICODE $(DBGFLAGS) @SAGA_UNICODE_FALSE@DEP_LFLG = -fPIC -shared `wx-config --unicode=no --static=no --libs` @SAGA_UNICODE_TRUE@DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` 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) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libpointcloud_viewer.la libpointcloud_viewer_la_SOURCES = \ MLB_Interface.cpp\ points_view_control.cpp\ points_view_dialog.cpp\ points_view_extent.cpp\ points_view_module.cpp\ MLB_Interface.h\ points_view_control.h\ points_view_dialog.h\ points_view_extent.h\ points_view_module.h libpointcloud_viewer_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.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) --foreign src/modules/pointcloud/pointcloud_viewer/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/pointcloud/pointcloud_viewer/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libpointcloud_viewer.la: $(libpointcloud_viewer_la_OBJECTS) $(libpointcloud_viewer_la_DEPENDENCIES) $(EXTRA_libpointcloud_viewer_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libpointcloud_viewer_la_OBJECTS) $(libpointcloud_viewer_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_view_control.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_view_dialog.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_view_extent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_view_module.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/points_view_control.cpp0000664000175000017500000005630512565125407030601 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_view_control.cpp 2052 2014-03-12 14:47:06Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // SAGA_GUI_API // // // //-------------------------------------------------------// // // // points_view_control.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #ifdef __BORLANDC__ #pragma hdrstop #endif #include #include #include #include //--------------------------------------------------------- #include "points_view_control.h" #include "points_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define m_Settings (*m_pSettings) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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) EVT_RIGHT_UP (CPoints_View_Control::On_Mouse_RUp) EVT_MIDDLE_DOWN (CPoints_View_Control::On_Mouse_MDown) EVT_MIDDLE_UP (CPoints_View_Control::On_Mouse_MUp) EVT_MOTION (CPoints_View_Control::On_Mouse_Motion) EVT_MOUSEWHEEL (CPoints_View_Control::On_Mouse_Wheel) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_View_Control::CPoints_View_Control(wxWindow *pParent, CSG_PointCloud *pPoints, CSG_Parameters &Settings) : wxPanel(pParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxSUNKEN_BORDER|wxNO_FULL_REPAINT_ON_RESIZE) { m_pPoints = pPoints; m_pSettings = &Settings; m_zField = 2; m_cField = 2; m_xRotate = 0.0; m_yRotate = 0.0; m_zRotate = 0.0; m_xShift = 0.0; m_yShift = 0.0; m_zShift = 1000.0; m_bCentral = true; m_bStereo = false; m_bScale = false; m_dCentral = 500.0; m_Detail = 1.0; //----------------------------------------------------- CSG_Parameter *pNode = m_pSettings->Add_Node(NULL, "NODE_CONTROL", _TL("3D View"), _TL("")); m_pSettings->Add_Colors( pNode , "COLORS" , _TL("Colors"), _TL("") ); m_pSettings->Add_Value( pNode , "BGCOLOR" , _TL("Background Color"), _TL(""), PARAMETER_TYPE_Color, 0 ); m_pSettings->Add_Range( pNode , "C_RANGE" , _TL("Colors Value Range"), _TL("") ); m_pSettings->Add_Value( pNode , "C_AS_RGB" , _TL("Value as RGB Code"), _TL(""), PARAMETER_TYPE_Bool, false ); m_pSettings->Add_Value( pNode , "SIZE_DEF" , _TL("Point Size: Default"), _TL(""), PARAMETER_TYPE_Int, 0, 0, true ); m_pSettings->Add_Value( pNode , "SIZE_SCALE" , _TL("Point Size: Scaling"), _TL(""), PARAMETER_TYPE_Double, 250.0, 1.0, true ); m_pSettings->Add_Value( pNode , "EXAGGERATION" , _TL("Exaggeration"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); m_pSettings->Add_Value( pNode , "STEREO_DIST" , _TL("Stereo Eye Distance [Degree]"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); pNode = m_pSettings->Add_Value( pNode , "DIM" , _TL("Dim Colours"), _TL(""), PARAMETER_TYPE_Bool, false ); pNode = m_pSettings->Add_Range( pNode , "DIM_RANGE" , _TL("Dim Range"), _TL(""), 0.0, 1.0, 0.0, true ); //----------------------------------------------------- m_pSelection = (int *)SG_Malloc(m_pPoints->Get_Count() * sizeof(int)); Update_Extent(m_pPoints->Get_Extent()); } //--------------------------------------------------------- CPoints_View_Control::~CPoints_View_Control(void) { if( m_pSelection ) { SG_Free(m_pSelection); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_View_Control::On_Size(wxSizeEvent &event) { _Set_Size(); event.Skip(); } //--------------------------------------------------------- void CPoints_View_Control::On_Paint(wxPaintEvent &WXUNUSED(event)) { if( m_Image.IsOk() && m_Image.GetWidth() > 0 && m_Image.GetHeight() > 0 ) { wxPaintDC dc(this); dc.DrawBitmap(wxBitmap(m_Image), 0, 0, false); } } //--------------------------------------------------------- void CPoints_View_Control::Update_View(void) { if( _Draw_Image() ) { wxClientDC dc(this); dc.DrawBitmap(wxBitmap(m_Image), 0, 0, false); } } //--------------------------------------------------------- void CPoints_View_Control::Update_Extent(CSG_Rect Extent) { m_Extent.Assign(Extent); m_zStats.Invalidate(); m_cStats.Invalidate(); m_nSelection = 0; for(int i=0; iGet_Count(); i++) { m_pPoints->Set_Cursor(i); TSG_Point_Z p = m_pPoints->Get_Point(); if( m_Extent.Contains(p.x, p.y) ) { m_pSelection[m_nSelection++] = i; m_zStats.Add_Value(m_pPoints->Get_Value(m_zField)); m_cStats.Add_Value(m_pPoints->Get_Value(m_cField)); } } m_Settings("C_RANGE")->asRange()->Set_Range( m_cStats.Get_Mean() - 1.5 * m_cStats.Get_StdDev(), m_cStats.Get_Mean() + 1.5 * m_cStats.Get_StdDev() ); Update_View(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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_PAGEUP: m_zShift -= 10.0; break; case WXK_PAGEDOWN: 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; if( !HasCapture() ) { CaptureMouse(); } } void CPoints_View_Control::On_Mouse_LUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } if( m_Mouse_Down.x != event.GetX() || m_Mouse_Down.y != event.GetY() ) { m_zRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_xRotate = m_yDown + GET_MOUSE_Y_RELDIFF * M_PI_180; Update_View(); ((CPoints_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CPoints_View_Control::On_Mouse_RDown(wxMouseEvent &event) { SetFocus(); m_Mouse_Down = event.GetPosition(); m_xDown = m_xShift; m_yDown = m_yShift; if( !HasCapture() ) { CaptureMouse(); } } void CPoints_View_Control::On_Mouse_RUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } if( m_Mouse_Down.x != event.GetX() || m_Mouse_Down.y != event.GetY() ) { m_xShift = m_xDown - GET_MOUSE_X_RELDIFF * 1000.0; m_yShift = m_yDown - GET_MOUSE_Y_RELDIFF * 1000.0; Update_View(); ((CPoints_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CPoints_View_Control::On_Mouse_MDown(wxMouseEvent &event) { SetFocus(); m_Mouse_Down = event.GetPosition(); m_xDown = m_yRotate; m_yDown = m_zShift; if( !HasCapture() ) { CaptureMouse(); } } void CPoints_View_Control::On_Mouse_MUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } if( m_Mouse_Down.x != event.GetX() || m_Mouse_Down.y != event.GetY() ) { m_yRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_zShift = m_yDown + GET_MOUSE_Y_RELDIFF * 1000.0; Update_View(); ((CPoints_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CPoints_View_Control::On_Mouse_Motion(wxMouseEvent &event) { if( HasCapture() && event.Dragging() ) { if( event.LeftIsDown() ) { m_zRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_xRotate = m_yDown + GET_MOUSE_Y_RELDIFF * M_PI_180; } else if( event.RightIsDown() ) { m_xShift = m_xDown - GET_MOUSE_X_RELDIFF * 1000.0; m_yShift = m_yDown - GET_MOUSE_Y_RELDIFF * 1000.0; } else if( event.MiddleIsDown() ) { m_yRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_zShift = m_yDown + GET_MOUSE_Y_RELDIFF * 1000.0; } else { return; } Update_View(); ((CPoints_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CPoints_View_Control::On_Mouse_Wheel(wxMouseEvent &event) { if( event.GetWheelRotation() ) { m_zShift += 0.5 * event.GetWheelRotation(); Update_View(); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_View_Control::_Set_Size(void) { Update_View(); } //--------------------------------------------------------- bool CPoints_View_Control::_Draw_Image(void) { wxSize dcSize = GetClientSize(); if( m_pPoints->Get_Count() <= 0 || dcSize.x <= 0 || dcSize.y <= 0 || m_Extent.Get_XRange() <= 0.0 || m_Extent.Get_YRange() <= 0.0 || m_zField < 0 || m_zField >= m_pPoints->Get_Field_Count() || m_cField < 0 || m_cField >= m_pPoints->Get_Field_Count() || m_zStats.Get_Range() <= 0.0 ) { return( false ); } //------------------------------------------------- if( !m_Image.IsOk() || dcSize.x != m_Image.GetWidth() || dcSize.y != m_Image.GetHeight() ) { m_Image .Create(dcSize.x, dcSize.y); m_Image_zMax.Create(dcSize.x, dcSize.y); } //------------------------------------------------- if( m_Settings("C_RANGE")->asRange()->Get_LoVal() >= m_Settings("C_RANGE")->asRange()->Get_HiVal() ) { m_Settings("C_RANGE")->asRange()->Set_Range( m_cStats.Get_Mean() - 1.5 * m_pPoints->Get_StdDev(m_cField), m_cStats.Get_Mean() + 1.5 * m_pPoints->Get_StdDev(m_cField) ); } m_pColors = m_Settings("COLORS")->asColors(); m_cMin = m_Settings("C_RANGE")->asRange()->Get_LoVal(); m_cScale = m_pColors->Get_Count() / (m_Settings("C_RANGE")->asRange()->Get_HiVal() - m_cMin); m_BGColor = m_Settings("BGCOLOR")->asColor(); //------------------------------------------------- if( (dcSize.x / (double)dcSize.y) > (m_Extent.Get_XRange() / m_Extent.Get_YRange()) ) { r_Scale = m_Image.GetWidth() / m_Extent.Get_XRange(); } else { r_Scale = m_Image.GetHeight() / m_Extent.Get_YRange(); } r_sin_x = sin(m_xRotate - M_PI_180); r_cos_x = cos(m_xRotate - M_PI_180); r_sin_y = sin(m_yRotate); r_cos_y = cos(m_yRotate); r_sin_z = sin(m_zRotate); r_cos_z = cos(m_zRotate); r_xc = m_Extent.Get_XCenter(); r_yc = m_Extent.Get_YCenter(); r_zc = m_zStats.Get_Minimum() + 0.5 * m_zStats.Get_Range(); r_Scale_z = r_Scale * m_Settings("EXAGGERATION")->asDouble(); //------------------------------------------------- // guess zmin, zmax TSG_Point_Z p; p.x = m_Extent.Get_XMin(); p.y = m_Extent.Get_YMin(); p.z = m_pPoints->Get_Value(m_zStats.Get_Minimum()); p = _Get_Projection(p); m_zMin = m_zMax = p.z; p.x = m_Extent.Get_XMin(); p.y = m_Extent.Get_YMin(); p.z = m_pPoints->Get_Value(m_zStats.Get_Maximum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMax(); p.y = m_Extent.Get_YMin(); p.z = m_pPoints->Get_Value(m_zStats.Get_Minimum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMax(); p.y = m_Extent.Get_YMin(); p.z = m_pPoints->Get_Value(m_zStats.Get_Maximum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMin(); p.y = m_Extent.Get_YMax(); p.z = m_pPoints->Get_Value(m_zStats.Get_Minimum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMin(); p.y = m_Extent.Get_YMax(); p.z = m_pPoints->Get_Value(m_zStats.Get_Maximum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMax(); p.y = m_Extent.Get_YMax(); p.z = m_pPoints->Get_Value(m_zStats.Get_Minimum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMax(); p.y = m_Extent.Get_YMax(); p.z = m_pPoints->Get_Value(m_zStats.Get_Maximum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; //------------------------------------------------- m_Size_Def = m_Settings("SIZE_DEF")->asInt(); m_Size_Scale = 1.0 / m_Settings("SIZE_SCALE")->asDouble(); m_bColorAsRGB = m_Settings("C_AS_RGB")->asBool(); m_bDim = m_Settings("DIM")->asBool(); m_Dim_A = m_zMin + m_Settings("DIM_RANGE")->asRange()->Get_LoVal() * (m_zMax - m_zMin); m_Dim_B = m_zMin + m_Settings("DIM_RANGE")->asRange()->Get_HiVal() * (m_zMax - m_zMin); int iSelection; int nSkip = 1 + (int)(0.001 * m_pPoints->Get_Count() * SG_Get_Square(1.0 - m_Detail)); _Draw_Background(); //------------------------------------------------- if( m_bStereo == false ) { m_Image_zMax.Assign(999999.0); m_Color_Mode = COLOR_MODE_RGB; for(iSelection=0; iSelectionasDouble() / 2.0; m_Image_zMax.Assign(999999.0); r_sin_y = sin(m_yRotate - d * M_DEG_TO_RAD); r_cos_y = cos(m_yRotate - d * M_DEG_TO_RAD); m_Color_Mode = COLOR_MODE_RED; for(iSelection=0; iSelectionSet_Cursor(iPoint); p = m_pPoints->Get_Point(); p.z = m_pPoints->Get_Value(m_zField); p = _Get_Projection(p); p.x = (int)(p.x + 0.5 * m_Image.GetWidth()); p.y = (int)(p.y + 0.5 * m_Image.GetHeight()); if( !m_bColorAsRGB ) { iColor = (int)(m_cScale * (m_pPoints->Get_Value(m_cField) - m_cMin)); iColor = m_pColors->Get_Color(iColor < 0 ? 0 : (iColor >= m_pColors->Get_Count() ? m_pColors->Get_Count() - 1 : iColor)); } else { iColor = (int)m_pPoints->Get_Value(m_cField); } if( m_bDim ) { double dim = 1.0 - (p.z - m_Dim_A) / (m_Dim_B - m_Dim_A); if( dim < 1.0 ) { if( dim <= 0.1 ) { dim = 0.1; } iColor = SG_GET_RGB( SG_GET_R(m_BGColor) + (int)((SG_GET_R(iColor) - SG_GET_R(m_BGColor)) * dim), SG_GET_G(m_BGColor) + (int)((SG_GET_G(iColor) - SG_GET_G(m_BGColor)) * dim), SG_GET_B(m_BGColor) + (int)((SG_GET_B(iColor) - SG_GET_B(m_BGColor)) * dim) ); } } _Draw_Point(p.x, p.y, p.z, iColor, m_Size_Def + (!m_bScale ? 0 : (int)(20.0 * exp(-m_Size_Scale * p.z)))); } //--------------------------------------------------------- inline void CPoints_View_Control::_Draw_Point(int x, int y, double z, int color, int Size) { if( z > 0.0 ) { _Draw_Pixel(x, y, z, color); if( Size > 0 && Size < 50 ) { for(int iy=1; iy<=Size; iy++) { for(int ix=0; ix<=Size; ix++) { if( ix*ix + iy*iy <= Size*Size ) { _Draw_Pixel(x + ix, y + iy, z, color); _Draw_Pixel(x + iy, y - ix, z, color); _Draw_Pixel(x - ix, y - iy, z, color); _Draw_Pixel(x - iy, y + ix, z, color); } } } } } } //--------------------------------------------------------- inline void CPoints_View_Control::_Draw_Pixel(int x, int y, double z, int color) { if( x >= 0 && x < m_Image.GetWidth() && y >= 0 && y < m_Image.GetHeight() && z < m_Image_zMax[y][x] ) { BYTE *pRGB = m_Image.GetData() + 3 * (y * m_Image.GetWidth() + x); switch( m_Color_Mode ) { case COLOR_MODE_RGB: *pRGB = SG_GET_R(color); pRGB++; *pRGB = SG_GET_G(color); pRGB++; *pRGB = SG_GET_B(color); break; case COLOR_MODE_RED: *pRGB = ((SG_GET_R(color) + SG_GET_G(color) + SG_GET_B(color)) / 3); break; case COLOR_MODE_BLUE: *(pRGB + 1) = ((SG_GET_R(color) + SG_GET_G(color) + SG_GET_B(color)) / 3); *(pRGB + 2) = ((SG_GET_R(color) + SG_GET_G(color) + SG_GET_B(color)) / 3); break; } m_Image_zMax[y][x] = z; } } //--------------------------------------------------------- inline TSG_Point_Z CPoints_View_Control::_Get_Projection(TSG_Point_Z p) { TSG_Point_Z q; p.x = (p.x - r_xc) * r_Scale; p.y = (p.y - r_yc) * r_Scale; p.z = (p.z - r_zc) * r_Scale_z; double a = (r_cos_y * p.z + r_sin_y * (r_sin_z * p.y + r_cos_z * p.x)); double b = (r_cos_z * p.y - r_sin_z * p.x); q.x = r_cos_y * (r_sin_z * p.y + r_cos_z * p.x) - r_sin_y * p.z; q.y = r_sin_x * a + r_cos_x * b; q.z = r_cos_x * a - r_sin_x * b; q.x += m_xShift; q.y += m_yShift; q.z += m_zShift; if( m_bCentral ) { q.x *= m_dCentral / q.z; q.y *= m_dCentral / q.z; } else { double z = m_dCentral / m_zShift; q.x *= z; q.y *= z; // q.z = -q.z; } return( q ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/points_view_module.h0000664000175000017500000001017312565125407030044 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_view_module.h 2158 2014-06-12 12:30:42Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // points_view_module // // // //-------------------------------------------------------// // // // points_view_module.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_view_module_H #define HEADER_INCLUDED__points_view_module_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_View_Module : public CSG_Module { public: CPoints_View_Module(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_view_module_H saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.cpp0000664000175000017500000002252112565125407030351 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_view_dialog.cpp 1928 2014-01-10 12:10:05Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // point_cloud_viewer // // // //-------------------------------------------------------// // // // points_view_dialog.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "points_view_control.h" #include "points_view_extent.h" #include "points_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(CPoints_View_Dialog, CSGDI_Dialog) EVT_MOUSEWHEEL (CPoints_View_Dialog::On_Mouse_Wheel) 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) EVT_SLIDER (wxID_ANY , CPoints_View_Dialog::On_Update_Control) EVT_CHOICE (wxID_ANY , CPoints_View_Dialog::On_Update_Choices) END_EVENT_TABLE() //--------------------------------------------------------- CPoints_View_Dialog::CPoints_View_Dialog(CSG_PointCloud *pPoints) : CSGDI_Dialog(_TL("Point Cloud Viewer"), SGDI_DLG_STYLE_START_MAXIMISED) { SetWindowStyle(wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE); //----------------------------------------------------- m_Settings.Create(NULL, _TL("Point Cloud Viewer Settings"), _TL("")); m_pView = new CPoints_View_Control (this, pPoints, m_Settings); m_pExtent = new CPoints_View_Extent (this, pPoints, m_Settings, wxSize(200, 200)); //----------------------------------------------------- wxArrayString Attributes; for(int i=0; iGet_Field_Count(); i++) { Attributes.Add(pPoints->Get_Field_Name(i)); } //----------------------------------------------------- Add_Button(_TL("Close"), wxID_OK); m_pBtn_Prop = Add_Button (_TL("Advanced Settings") , wxID_ANY); Add_Spacer(); m_pField_Z = Add_Choice (_TL("Z Attribute") , Attributes, m_pView->m_zField); m_pField_Color = Add_Choice (_TL("Color Attribute") , Attributes, m_pView->m_cField); Add_Spacer(); m_pCheck_Central = Add_CheckBox (_TL("Central Projection") , m_pView->m_bCentral); m_pCheck_Stereo = Add_CheckBox (_TL("Anaglyph") , m_pView->m_bStereo); m_pCheck_Scale = Add_CheckBox (_TL("Scale Point Size") , m_pView->m_bScale); Add_Spacer(); m_pSlide_xRotate = Add_Slider (_TL("X-Rotation") , m_pView->m_xRotate * M_RAD_TO_DEG, -180.0, 180.0); m_pSlide_yRotate = Add_Slider (_TL("Y-Rotation") , m_pView->m_yRotate * M_RAD_TO_DEG, -180.0, 180.0); m_pSlide_zRotate = Add_Slider (_TL("Z-Rotation") , m_pView->m_zRotate * M_RAD_TO_DEG, -180.0, 180.0); m_pSlide_Central = Add_Slider (_TL("Eye Distance") , m_pView->m_dCentral, 1.0, 2000.0); m_pSlide_Detail = Add_Slider (_TL("Level of Detail") , m_pView->m_Detail, 0.0, 1.0); // Add_Spacer(); // m_pParameters = Add_TextCtrl (_TL("Function Parameters"), wxTE_MULTILINE|wxTE_READONLY); Add_Spacer(); Add_CustomCtrl(_TL("Extent"), m_pExtent); Add_Output(m_pView); } //--------------------------------------------------------- void CPoints_View_Dialog::On_Mouse_Wheel(wxMouseEvent &event) { m_pView->On_Mouse_Wheel(event); } //--------------------------------------------------------- void CPoints_View_Dialog::On_Update_Control(wxCommandEvent &event) { if( event.GetEventObject() == m_pCheck_Central ) { m_pView->m_bCentral = m_pCheck_Central ->GetValue() == 1 ? 1 : 0; } else if( event.GetEventObject() == m_pCheck_Stereo ) { m_pView->m_bStereo = m_pCheck_Stereo ->GetValue() == 1 ? 1 : 0; } else if( event.GetEventObject() == m_pCheck_Scale ) { m_pView->m_bScale = m_pCheck_Scale ->GetValue() == 1 ? 1 : 0; } else if( event.GetEventObject() == m_pSlide_xRotate ) { m_pView->m_xRotate = m_pSlide_xRotate ->Get_Value() * M_DEG_TO_RAD; } else if( event.GetEventObject() == m_pSlide_yRotate ) { m_pView->m_yRotate = m_pSlide_yRotate ->Get_Value() * M_DEG_TO_RAD; } else if( event.GetEventObject() == m_pSlide_zRotate ) { m_pView->m_zRotate = m_pSlide_zRotate ->Get_Value() * M_DEG_TO_RAD; } else if( event.GetEventObject() == m_pSlide_Central ) { m_pView->m_dCentral = m_pSlide_Central ->Get_Value(); } else if( event.GetEventObject() == m_pSlide_Detail ) { m_pView->m_Detail = m_pSlide_Detail ->Get_Value(); } else { return; } m_pView->Update_View(); } //--------------------------------------------------------- void CPoints_View_Dialog::On_Update_Choices(wxCommandEvent &event) { if( event.GetEventObject() == m_pField_Z ) { m_pView ->m_zField = m_pField_Z ->GetSelection(); m_pView ->Update_View(); } else if( event.GetEventObject() == m_pField_Color ) { m_Settings("C_RANGE")->asRange()->Set_Range(0.0, 0.0); m_pExtent ->m_cField = m_pField_Color->GetSelection(); m_pView ->m_cField = m_pField_Color->GetSelection(); m_pExtent ->Update_View(); m_pView ->Update_Extent(m_pExtent->Get_Extent()); } else { return; } } //--------------------------------------------------------- void CPoints_View_Dialog::On_Button(wxCommandEvent &event) { if( event.GetEventObject() == m_pBtn_Prop ) { if( SG_UI_Dlg_Parameters(&m_Settings, m_Settings.Get_Name()) ) { m_pExtent ->Update_View(); m_pView ->Update_View(); } } else { event.Skip(); } } //--------------------------------------------------------- void CPoints_View_Dialog::Update_Extent(void) { m_pView->Update_Extent(m_pExtent->Get_Extent()); } //--------------------------------------------------------- void CPoints_View_Dialog::Update_Rotation(void) { double d; d = fmod(M_RAD_TO_DEG * m_pView->m_xRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0; m_pSlide_xRotate->Set_Value(d); d = fmod(M_RAD_TO_DEG * m_pView->m_yRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0; m_pSlide_yRotate->Set_Value(d); 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); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/points_view_extent.h0000664000175000017500000001272712565125407030075 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_view_extent.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // SAGA_GUI_API // // // //-------------------------------------------------------// // // // points_view_extent.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_view_extent_H #define HEADER_INCLUDED__points_view_extent_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_View_Extent : public wxPanel { public: CPoints_View_Extent(wxWindow *pParent, CSG_PointCloud *pPoints, CSG_Parameters &Settings, wxSize Size); int m_cField; void Update_View (void); void On_Size (wxSizeEvent &event); void On_EraseBackGround (wxEraseEvent &event); void On_Paint (wxPaintEvent &event); void On_Mouse_LDown (wxMouseEvent &event); void On_Mouse_LUp (wxMouseEvent &event); void On_Mouse_RDown (wxMouseEvent &event); void On_Mouse_RUp (wxMouseEvent &event); void On_Mouse_Motion (wxMouseEvent &event); TSG_Rect Get_Extent (void); private: CSG_Rect m_Extent; CSG_Matrix m_Image_Value, m_Image_Count; CSG_PointCloud *m_pPoints; CSG_Parameters *m_pSettings; wxPoint m_Mouse_Down, m_Mouse_Move; wxRect m_Select; wxImage m_Image; bool _Draw_Image (void); void _Draw_Pixel (int x, int y, int color); void _Draw_Inverse (wxPoint pa, wxPoint pb); DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_view_extent_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/MLB_Interface.cpp0000664000175000017500000001077112565125407027062 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2289 2014-10-16 13:45:05Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_viewer // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for 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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Point Clouds Viewer") ); case MLB_INFO_Category: return( _TL("Visualization") ); case MLB_INFO_Author: return( SG_T("O.Conrad (c) 2009") ); case MLB_INFO_Description: return( _TL("Point clouds viewer." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Visualization|3D Viewer" )); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "points_view_module.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CPoints_View_Module ); default: return( NULL ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/Makefile.am0000664000175000017500000000206112565125407026011 0ustar00oconradoconrad00000000000000if 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` 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 = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libpointcloud_viewer.la libpointcloud_viewer_la_SOURCES =\ MLB_Interface.cpp\ points_view_control.cpp\ points_view_dialog.cpp\ points_view_extent.cpp\ points_view_module.cpp\ MLB_Interface.h\ points_view_control.h\ points_view_dialog.h\ points_view_extent.h\ points_view_module.h libpointcloud_viewer_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la $(ADD_MLBS) saga-2.2.3/src/modules/pointcloud/pointcloud_viewer/MLB_Interface.h0000664000175000017500000000760512565125407026531 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_viewer // // // //-------------------------------------------------------// // // // MLB_Interface.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pointcloud_viewer_mlb_H #define HEADER_INCLUDED__pointcloud_viewer_mlb_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef pointcloud_viewer_EXPORTS #define pointcloud_viewer_EXPORT _SAGA_DLL_EXPORT #else #define pointcloud_viewer_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pointcloud_viewer_mlb_H saga-2.2.3/src/modules/pointcloud/Makefile.am0000664000175000017500000000014412565125407022250 0ustar00oconradoconrad00000000000000if WITH_GUI SUBDIRS = pointcloud_viewer pointcloud_tools else SUBDIRS = pointcloud_tools endif saga-2.2.3/src/modules/pointcloud/pointcloud_tools/0000775000175000017500000000000012634325744023620 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_from_table.h0000664000175000017500000000770512577724054026601 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_from_table.h 2570 2015-09-03 10:16:20Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_table.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_From_Table_H #define HEADER_INCLUDED__PC_From_Table_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_From_Table : public CSG_Module { public: CPC_From_Table(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Conversion") ); } protected: virtual bool On_Execute (void); private: }; #endif // #ifndef HEADER_INCLUDED__PC_From_Table_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_reclass_extract.h0000664000175000017500000001153512570021307027631 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_reclass_extract.h 2561 2015-08-27 08:10:41Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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 CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: int m_Single; bool m_bExtract, m_bCreateAttrib; int m_AttrField; int m_iOrig; CSG_PointCloud *m_pInput, *m_pResult; void Reclass_Single (void); void Reclass_Range (void); bool Reclass_Table (bool bUser); void Set_Value (int i, double value); void Set_Display_Attributes (CSG_PointCloud *pPC, int iField, CSG_Parameters &sParms); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Reclass_Extract_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_from_table.cpp0000664000175000017500000001576412577724054027140 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_from_table.cpp 2570 2015-09-03 10:16:20Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_table.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_from_table.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_From_Table::CPC_From_Table(void) { Set_Name (_TL("Point Cloud from Table")); Set_Author (SG_T("V. Wichmann (c) 2015")); Set_Description (_TW( "This tool allows one to create a point cloud from a table.\n\n" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Table( NULL , "TAB_IN" ,_TL("Table"), _TL("The input table."), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD_X" , _TL("X"), _TL("The attribute field with the x-coordinate.") ); Parameters.Add_Table_Field( pNode , "FIELD_Y" , _TL("Y"), _TL("The attribute field with the y-coordinate.") ); Parameters.Add_Table_Field( pNode , "FIELD_Z" , _TL("Z"), _TL("The attribute field with the z-coordinate.") ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("The attribute fields to convert, optional.") ); Parameters.Add_PointCloud( NULL , "PC_OUT" ,_TL("Point Cloud"), _TL("The output point cloud."), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_From_Table::On_Execute(void) { CSG_Table *pTable; int iFieldX, iFieldY, iFieldZ; int *Features, nFeatures; CSG_PointCloud *pPoints; //----------------------------------------------------- pTable = Parameters("TAB_IN")->asTable(); iFieldX = Parameters("FIELD_X")->asInt(); iFieldY = Parameters("FIELD_Y")->asInt(); iFieldZ = Parameters("FIELD_Z")->asInt(); Features = (int *)Parameters("FIELDS")->asPointer(); nFeatures = Parameters("FIELDS")->asInt (); pPoints = Parameters("PC_OUT")->asPointCloud(); //----------------------------------------------------- pPoints->Create(); pPoints->Set_Name(CSG_String::Format(SG_T("%s_pc"), pTable->Get_Name())); for( int j=0; jGet_Field_Type(Features[j]) ) { case SG_DATATYPE_Undefined: case SG_DATATYPE_Binary: SG_UI_Msg_Add_Error(_TL("Undefined or binary attribute field types are not supported!")); return( false ); case SG_DATATYPE_Date: case SG_DATATYPE_String: Data_Type = SG_DATATYPE_String; break; default: Data_Type = pTable->Get_Field_Type(Features[j]); break; } pPoints->Add_Field(pTable->Get_Field_Name(Features[j]), Data_Type); } //----------------------------------------------------- Process_Set_Text(_TL("Converting ...")); for( int iRecord=0; iRecordGet_Record_Count() && Set_Progress(iRecord, pTable->Get_Record_Count()); iRecord++ ) { pPoints->Add_Point(pTable->Get_Record(iRecord)->asDouble(iFieldX), pTable->Get_Record(iRecord)->asDouble(iFieldY), pTable->Get_Record(iRecord)->asDouble(iFieldZ)); for( int j=0; jGet_Attribute_Type(j) ) { case SG_DATATYPE_String: pPoints->Set_Value(iRecord, j + 3, pTable->Get_Record(iRecord)->asString(Features[j])); break; default: pPoints->Set_Value(iRecord, j + 3, pTable->Get_Record(iRecord)->asDouble(Features[j])); break; } } } //------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_drop_attribute.h0000664000175000017500000001073412603215353027475 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_drop_attribute.h 2626 2015-10-01 09:06:32Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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 CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Before_Execution (void); virtual bool On_Execute (void); private: void Set_Display_Attributes(CSG_PointCloud *pPC, CSG_Parameters &sParms); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Drop_Attribute_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_from_shapes.cpp0000664000175000017500000001472012577724054027323 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_from_shapes.cpp 2570 2015-09-03 10:16:20Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_from_shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_From_Shapes::CPC_From_Shapes(void) { //----------------------------------------------------- Set_Name (_TL("Point Cloud from Shapes")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ZFIELD" , _TL("Z Value"), _TL(""), true ); Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("only z"), _TL("all attributes") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_From_Shapes::On_Execute(void) { int zField, nFields, *Fields; CSG_PointCloud *pPoints; CSG_Shapes *pShapes; pShapes = Parameters("SHAPES")->asShapes(); pPoints = Parameters("POINTS")->asPointCloud(); zField = Parameters("ZFIELD")->asInt(); if( !pShapes->is_Valid() ) { Error_Set(_TL("invalid input")); return( false ); } //----------------------------------------------------- pPoints->Create(); pPoints->Set_Name(pShapes->Get_Name()); nFields = 0; Fields = new int[pShapes->Get_Field_Count()]; if( Parameters("OUTPUT")->asInt() == 1 ) // all attributes { for(int iField=0; iFieldGet_Field_Count(); iField++) { if( iField != zField && pPoints->Add_Field(pShapes->Get_Field_Name(iField), pShapes->Get_Field_Type(iField)) ) { Fields[nFields++] = iField; } } } //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); pPoints->Add_Point(p.x, p.y, zField < 0 ? pShape->Get_Z(iPoint, iPart) : pShape->asDouble(zField)); for(int iField=0, jField=3; iFieldGet_Field_Type(jField) ) { case SG_DATATYPE_Date: case SG_DATATYPE_String: pPoints->Set_Value(jField, pShape->asString(Fields[iField])); break; default: pPoints->Set_Value(jField, pShape->asDouble(Fields[iField])); break; } } } } } //----------------------------------------------------- delete[](Fields); return( pPoints->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_from_shapes.h0000664000175000017500000001011612577724054026763 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_from_shapes.h 2570 2015-09-03 10:16:20Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_From_Shapes_H #define HEADER_INCLUDED__PC_From_Shapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_From_Shapes : public CSG_Module { public: CPC_From_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Conversion") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_From_Shapes_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_cut.cpp0000664000175000017500000004354712565125407025613 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_cut.cpp 2427 2015-02-26 16:24:53Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_cut.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Cut::CPC_Cut(void) { CSG_Parameters *pParameters; //----------------------------------------------------- Set_Name (_TL("Point Cloud Cutter")); Set_Author (SG_T("O. Conrad, V. Wichmann (c) 2009-15")); Set_Description (_TW( "This modules allows one to extract subsets from one or several " "point cloud datasets. 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_List( NULL , "POINTS" , _TL("Points"), _TL("One or several input point cloud datasets to cut."), PARAMETER_INPUT ); Parameters.Add_PointCloud_List( NULL , "CUT" , _TL("Cut"), _TL("The cutted output point cloud dataset(s)."), 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 ); //----------------------------------------------------- // 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); //----------------------------------------------------- // Grid System Extent pParameters = Add_Parameters ( "GRID" , _TL("Grid System Extent") , _TL("")); pParameters ->Add_Grid_System (NULL, "GRID" , _TL("Grid System") , _TL("")); //----------------------------------------------------- // Shapes Extent pParameters = Add_Parameters ( "EXTENT" , _TL("Shapes Extent") , _TL("")); pParameters ->Add_Shapes (NULL, "EXTENT" , _TL("Shapes Extent") , _TL(""), PARAMETER_INPUT_OPTIONAL); //----------------------------------------------------- // Polygons pParameters = Add_Parameters ( "POLYGONS" , _TL("Polygons") , _TL("")); pParameters ->Add_Shapes (NULL, "POLYGONS" , _TL("Polygons") , _TL(""), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Polygon); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Cut::On_Execute(void) { CSG_Parameter_PointCloud_List *pPointsList = Parameters("POINTS") ->asPointCloudList(); CSG_Parameter_PointCloud_List *pCutList = Parameters("CUT") ->asPointCloudList(); 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(pPointsList, pCutList, r, Parameters("INVERSE")->asBool()) ); } break; //----------------------------------------------------- case 1: // Grid System Extent if( Dlg_Parameters("GRID") ) { return( Get_Cut(pPointsList, pCutList, Get_Parameters("GRID")->Get_Parameter("GRID")->asGrid_System()->Get_Extent(), Parameters("INVERSE")->asBool()) ); } break; //----------------------------------------------------- case 2: // Shapes Extent if( Dlg_Parameters("EXTENT") ) { if( Get_Parameters("EXTENT")->Get_Parameter("EXTENT")->asShapes() == NULL ) { SG_UI_Msg_Add_Error(_TL("Please provide a shapefile with the 'Shapes Extent' parameter!")); return( false ); } return( Get_Cut(pPointsList, pCutList, Get_Parameters("EXTENT")->Get_Parameter("EXTENT")->asShapes()->Get_Extent(), Parameters("INVERSE")->asBool()) ); } break; //----------------------------------------------------- case 3: // Polygons if( Dlg_Parameters("POLYGONS") ) { if( Get_Parameters("POLYGONS")->Get_Parameter("POLYGONS")->asShapes() == NULL ) { SG_UI_Msg_Add_Error(_TL("Please provide a shapefile with the 'Polygons' parameter!")); return( false ); } 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(pPointsList, pCutList, Get_Parameters("POLYGONS")->Get_Parameter("POLYGONS")->asShapes(), Parameters("INVERSE")->asBool()) ); } break; } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Cut::Get_Cut(CSG_Parameter_PointCloud_List *pPointsList, CSG_Parameter_PointCloud_List *pCutList, const CSG_Rect &Extent, bool bInverse) { for(int iItem=0; iItemGet_Count(); iItem++) { SG_UI_Process_Set_Text(CSG_String::Format(_TL("Processing dataset %d"), iItem+1)); CSG_PointCloud *pPoints = pPointsList->asPointCloud(iItem); if( pPoints && pPoints->is_Valid() ) { CSG_PointCloud *pCut = new CSG_PointCloud(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; iGet_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; jGet_Field_Count() - 3; j++) { pCut->Set_Attribute(j, pPoints->Get_Attribute(j)); } } } } if( pCut->Get_Count() <= 0 ) { delete pCut; SG_UI_Msg_Add(CSG_String::Format(_TL("Cutting %s resulted in an empty point cloud, skipping output!"), pPoints->Get_Name()), true); } else { pCutList->Add_Item(pCut); SG_UI_Msg_Add(CSG_String::Format(_TL("%d points from %s written to output %s."), pCut->Get_Point_Count(), pPoints->Get_Name(), pCut->Get_Name()), true); } } } return( true ); } //--------------------------------------------------------- bool CPC_Cut::Get_Cut(CSG_Parameter_PointCloud_List *pPointsList, CSG_Parameter_PointCloud_List *pCutList, CSG_Shapes *pPolygons, bool bInverse) { for(int iItem=0; iItemGet_Count(); iItem++) { SG_UI_Process_Set_Text(CSG_String::Format(_TL("Processing dataset %d"), iItem+1)); CSG_PointCloud *pPoints = pPointsList->asPointCloud(iItem); if( pPoints && pPoints->is_Valid() ) { CSG_PointCloud *pCut = new CSG_PointCloud(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; iGet_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; jGet_Field_Count() - 3; j++) { pCut->Set_Attribute(j, pPoints->Get_Attribute(j)); } } } } if( pCut->Get_Count() <= 0 ) { delete pCut; SG_UI_Msg_Add(CSG_String::Format(_TL("Cutting %s resulted in an empty point cloud, skipping output!"), pPoints->Get_Name()), true); } else { pCutList->Add_Item(pCut); SG_UI_Msg_Add(CSG_String::Format(_TL("%d points from %s written to output %s."), pCut->Get_Point_Count(), pPoints->Get_Name(), pCut->Get_Name()), true); } } } return( true ); } //--------------------------------------------------------- bool CPC_Cut::Contains(CSG_Shapes *pPolygons, double x, double y) { if( pPolygons->Get_Extent().Contains(x, y) ) { for(int iPolygon=0; iPolygonGet_Count(); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); if( pPolygon->Contains(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-15")); Set_Description (_TW( "This modules allows one to extract subsets from one or several " "point cloud datasets. 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_List( NULL , "POINTS" , _TL("Points"), _TL("One or several input point cloud datasets to cut."), PARAMETER_INPUT ); Parameters.Add_PointCloud_List( NULL , "CUT" , _TL("Cut"), _TL("The cutted output point cloud dataset(s)."), 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_pPointsList = Parameters("POINTS") ->asPointCloudList(); m_pCutList = Parameters("CUT") ->asPointCloudList(); 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, SG_T("AOI_Cutter")); 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("OUTLINE_COLOR")) { sParms("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() ); CPC_Cut::Get_Cut(m_pPointsList, m_pCutList, r, m_bInverse); } return( true ); } return( false ); //----------------------------------------------------- case MODULE_INTERACTIVE_RDOWN: if( !m_bAOIBox ) { m_bAdd = false; CPC_Cut::Get_Cut(m_pPointsList, m_pCutList, m_pAOI, m_bInverse); return( true ); } return( false ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_thinning_simple.cpp0000664000175000017500000001272512565125407030201 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_thinning_simple.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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(SG_T("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; iGet_Point_Count() && Set_Progress(i, pInput->Get_Point_Count()); i+=step) { pResult->Del_Point(i); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_from_grid.cpp0000664000175000017500000001302012565125407026747 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_from_grid.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_grid.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_from_grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_From_Grid::CPC_From_Grid(void) { //----------------------------------------------------- Set_Name (_TL("Point Cloud from Grid Points")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Z Value"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Additional Values"), _TL(""), PARAMETER_INPUT_OPTIONAL, false ); Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_From_Grid::On_Execute(void) { int x, y, i; TSG_Point p; CSG_Grid *pGrid; CSG_Parameter_Grid_List *pGrids; CSG_PointCloud *pPoints; //----------------------------------------------------- pGrid = Parameters("GRID") ->asGrid(); pGrids = Parameters("GRIDS") ->asGridList(); pPoints = Parameters("POINTS") ->asPointCloud(); pPoints->Create(); pPoints->Set_Name(pGrid->Get_Name()); for(i=0; iGet_Count(); i++) { pPoints->Add_Field(pGrids->asGrid(i)->Get_Name(), SG_DATATYPE_Float); } //----------------------------------------------------- for(y=0, p.y=Get_YMin(); yis_NoData(x, y) ) { pPoints->Add_Point(p.x, p.y, pGrid->asDouble(x, y)); for(i=0; iGet_Count(); i++) { pPoints->Set_Value(3 + i, pGrids->asGrid(i)->Get_Value(p)); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_to_grid.h0000664000175000017500000001033312565125407026077 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_to_grid.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_to_grid.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_To_Grid_H #define HEADER_INCLUDED__PC_To_Grid_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_To_Grid : public CSG_Module { public: CPC_To_Grid(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Conversion") ); } protected: virtual bool On_Execute (void); private: int m_Aggregation; CSG_Grid *m_pGrid, *m_pCount; void Set_Value (int x, int y, double z, int Count, double value, CSG_Grid *pGrid); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_To_Grid_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_to_shapes.cpp0000664000175000017500000001264412565125407026777 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_to_shapes.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_to_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_to_shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_To_Shapes::CPC_To_Shapes(void) { //----------------------------------------------------- Set_Name (_TL("Point Cloud to Shapes")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_To_Shapes::On_Execute(void) { int iField; CSG_PointCloud *pPoints; CSG_Shapes *pShapes; pPoints = Parameters("POINTS") ->asPointCloud(); pShapes = Parameters("SHAPES") ->asShapes(); //----------------------------------------------------- pShapes->Create(SHAPE_TYPE_Point, pPoints->Get_Name(), NULL, SG_VERTEX_TYPE_XYZ); for(iField=2; iFieldGet_Field_Count(); iField++) { pShapes->Add_Field(pPoints->Get_Field_Name(iField), pPoints->Get_Field_Type(iField)); } //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { pPoints->Set_Cursor(iPoint); CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Add_Point(pPoints->Get_X(), pPoints->Get_Y()); pShape->Set_Z(pPoints->Get_Z(), 0); for(iField=2; iFieldGet_Field_Count(); iField++) { pShape->Set_Value(iField - 2, pPoints->Get_Value(iField)); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_drop_attribute.cpp0000664000175000017500000002030612603215353030024 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_drop_attribute.cpp 2626 2015-10-01 09:06:32Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_drop_attribute.h" #include #include /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Drop_Attribute::CPC_Drop_Attribute(void) { Set_Name(_TL("Drop Point Cloud Attributes")); Set_Author(_TL("Volker Wichmann (c) 2010, LASERDATA GmbH")); Set_Description (_TW( "The module can be used to drop attributes from a point cloud. " "In case the output dataset is not set, the attribute(s) will be dropped " "from the input dataset, i.e. the input dataset will be overwritten.\n\n" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_PointCloud( NULL , "INPUT" ,_TL("Input"), _TL("Point cloud to drop attribute(s) from."), PARAMETER_INPUT ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("The attribute field(s) to drop.") ); Parameters.Add_PointCloud( NULL , "OUTPUT" , _TL("Output"), _TL("Point cloud with attribute(s) dropped."), PARAMETER_OUTPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Drop_Attribute::On_Before_Execution(void) { if( Parameters("OUTPUT")->asPointCloud() == Parameters("INPUT")->asPointCloud() ) Parameters("OUTPUT")->Set_Value(DATAOBJECT_NOTSET); return (true); } //--------------------------------------------------------- bool CPC_Drop_Attribute::On_Execute(void) { CSG_PointCloud *pInput, *pOutput; CSG_Parameters sParms; int *Features, nFeatures; std::set setCols; std::set::iterator it; pInput = Parameters("INPUT")->asPointCloud(); pOutput = Parameters("OUTPUT")->asPointCloud(); //------------------------------------------------- Features = (int *)Parameters("FIELDS")->asPointer(); nFeatures = Parameters("FIELDS")->asInt (); if( !Features || nFeatures <= 0 ) { Error_Set(_TL("You must specify at least one attribute to drop!")); return( false ); } //----------------------------------------------------- CSG_String sName; CSG_MetaData History; if( !pOutput || pOutput == pInput ) { sName = pInput->Get_Name(); pOutput = SG_Create_PointCloud(pInput); History = pInput->Get_History(); } else { sName = CSG_String::Format(SG_T("%s_droppedAttr"), pInput->Get_Name()); pOutput->Create(pInput); } //----------------------------------------------------- setCols.clear(); for( int i=0; iDel_Field(*it - j); j++; } DataObject_Update(pOutput); for(int i=0; iGet_Point_Count() && SG_UI_Process_Set_Progress(i, pInput->Get_Count()); i++) { pOutput->Add_Point(pInput->Get_X(i), pInput->Get_Y(i), pInput->Get_Z(i)); for(int j=0, k=0; jGet_Attribute_Count(); j++, k++) { it = setCols.find(j + 3); if( it != setCols.end() ) { k--; continue; } pOutput->Set_Attribute(k, pInput->Get_Attribute(i, j)); } } //----------------------------------------------------- if (!Parameters("OUTPUT")->asPointCloud() || Parameters("OUTPUT")->asPointCloud() == pInput ) { pInput->Assign(pOutput); pInput->Get_History() = History; pInput->Set_Name(sName); Parameters("OUTPUT")->Set_Value(pInput); delete(pOutput); DataObject_Get_Parameters(pInput, sParms); Set_Display_Attributes(pInput, sParms); } else { pOutput->Set_Name(sName); DataObject_Update(pOutput); DataObject_Get_Parameters(pOutput, sParms); Set_Display_Attributes(pOutput, sParms); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- void CPC_Drop_Attribute::Set_Display_Attributes(CSG_PointCloud *pPC, CSG_Parameters &sParms) { if (sParms("METRIC_ATTRIB") && sParms("COLORS_TYPE") && sParms("METRIC_COLORS") && sParms("METRIC_ZRANGE") && sParms("DISPLAY_VALUE_AGGREGATE")) { sParms("DISPLAY_VALUE_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("METRIC_ATTRIB")->Set_Value(2); // z attrib sParms("METRIC_ZRANGE")->asRange()->Set_Range(pPC->Get_Minimum(2), pPC->Get_Maximum(2)); } DataObject_Set_Parameters(pPC, sParms); DataObject_Update(pPC); return; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_cluster_analysis.h0000664000175000017500000001131112565125407030031 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_cluster_analysis.h 2295 2014-10-17 15:35:10Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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 "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Cluster_Analysis : public CSG_Module { public: CPC_Cluster_Analysis(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Classification") ); } protected: virtual bool On_Execute (void); private: bool m_bUpdateView; int *m_Features, m_nFeatures, clustField, *nMembers; double **Centroids, *Variances; CSG_PointCloud *pInput, *pResult; std::vector< std::vector > 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 saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_reclass_extract.cpp0000664000175000017500000005723712570021307030175 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_reclass_extract.cpp 2561 2015-08-27 08:10:41Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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(SG_T("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("Reclassified 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_Value( NULL , "CREATE_ATTRIB" , _TL("Create new Attribute"), _TL("Check this to create a new attribute with the reclassification result. If unchecked, the existing attribute is updated."), PARAMETER_TYPE_Bool, false ); 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 ); //----------------------------------------------------- Parameters.Add_Value( NULL , "OLD" , _TL("old value"), _TL("Value to reclassify."), PARAMETER_TYPE_Double, 0 ); Parameters.Add_Value( NULL , "NEW" , _TL("new value"), _TL("New value."), PARAMETER_TYPE_Double, 1 ); Parameters.Add_Choice( NULL , "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 ); //----------------------------------------------------- Parameters.Add_Value( NULL , "MIN" , _TL("minimum value"), _TL("Minimum value of the range to be reclassified."), PARAMETER_TYPE_Double, 0 ); Parameters.Add_Value( NULL , "MAX" , _TL("maximum value"), _TL("Maximum value of the range to be reclassified."), PARAMETER_TYPE_Double, 10 ); Parameters.Add_Value( NULL , "RNEW" , _TL("new value"), _TL("new value"), PARAMETER_TYPE_Double, 5 ); Parameters.Add_Choice( NULL , "ROPERATOR" , _TL("operator"), _TL("Select operator: eg. min < value < max."), CSG_String::Format(SG_T("%s|%s|"), _TL("<="), _TL("<") ), 0 ); //----------------------------------------------------- Parameters.Add_FixedTable( NULL , "RETAB" , _TL("Lookup Table"), _TL("Lookup table used in method \"table\"") ); Parameters.Add_Choice( NULL , "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_Table( NULL , "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( Parameters("NODATAOPT") , "NODATA" , _TL("new 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( Parameters("OTHEROPT") , "OTHERS" , _TL("new 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; CSG_Parameters sParms; 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_bCreateAttrib = Parameters("CREATE_ATTRIB")->asBool(); 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))); if( m_bCreateAttrib ) m_pResult->Add_Field(CSG_String::Format(SG_T("%s_reclass"), m_pInput->Get_Field_Name(m_AttrField)), m_pInput->Get_Field_Type(m_AttrField)); } m_iOrig = 0; // counter of unchanged points //----------------------------------------------------- switch( method ) { case 0: Reclass_Single(); break; case 1: Reclass_Range(); break; case 2: if( Reclass_Table(false) ) break; else return( false ); case 3: if( Reclass_Table(true) ) break; else return( false ); default: break; } //----------------------------------------------------- DataObject_Update(m_pResult); DataObject_Get_Parameters(m_pResult, sParms); if (m_bExtract) Set_Display_Attributes(m_pResult, 2, sParms); else { if( m_bCreateAttrib ) Set_Display_Attributes(m_pResult, m_pResult->Get_Field_Count()-1, sParms); else Set_Display_Attributes(m_pResult, m_AttrField, sParms); } if( m_bExtract) SG_UI_Msg_Add(CSG_String::Format(_TL("%d points out of %d extracted."), m_pInput->Get_Point_Count()-m_iOrig, m_pInput->Get_Point_Count()), true); else SG_UI_Msg_Add(CSG_String::Format(_TL("%d points out of %d reclassified."), m_pInput->Get_Point_Count()-m_iOrig, m_pInput->Get_Point_Count()), true); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void 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(); opera = Parameters("ROPERATOR")->asInt(); otherOpt = m_bExtract ? false : Parameters("OTHEROPT")->asBool(); noDataOpt = m_bExtract ? false : Parameters("NODATAOPT")->asBool(); 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; iGet_Point_Count() && Set_Progress(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 m_iOrig++; } } 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 m_iOrig++; } } } return; } //--------------------------------------------------------- void 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(); opera = Parameters("SOPERATOR")->asInt(); otherOpt = m_bExtract ? false : Parameters("OTHEROPT")->asBool(); noDataOpt = m_bExtract ? false : Parameters("NODATAOPT")->asBool(); 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; iGet_Point_Count() && Set_Progress(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 m_iOrig++; } } 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 m_iOrig++; } } 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 m_iOrig++; } } 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 m_iOrig++; } } 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 m_iOrig++; } } } return; } //--------------------------------------------------------- bool CPC_Reclass_Extract::Reclass_Table(bool bUser) { bool set, otherOpt, noDataOpt; int opera, field_Min, field_Max, field_Code; double 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(); opera = Parameters("TOPERATOR")->asInt(); otherOpt = m_bExtract ? false : Parameters("OTHEROPT")->asBool(); noDataOpt = m_bExtract ? false : Parameters("NODATAOPT")->asBool(); 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 ); } if( pReTab->Get_Record_Count() == 0 ) { Error_Set(_TL("You must specify a reclass table with a minimium of one record!\n")); return( false ); } for (int i=0; iGet_Point_Count() && Set_Progress(i, m_pInput->Get_Point_Count()); i++) { value = m_pInput->Get_Value(i, m_AttrField); set = false; for(int iRecord=0; iRecordGet_Record_Count(); iRecord++) // reclass { pRecord = pReTab->Get_Record(iRecord); if( opera == 0 ) // min <= value < max { if( value >= pRecord->asDouble(field_Min) && value < pRecord->asDouble(field_Max) ) { Set_Value(i, pRecord->asDouble(field_Code)); set = true; break; } } else if( opera == 1 ) // min <= value <= max { if( value >= pRecord->asDouble(field_Min) && value <= pRecord->asDouble(field_Max) ) { Set_Value(i, pRecord->asDouble(field_Code)); set = true; break; } } else if( opera == 2 ) // min < value <= max { if( value > pRecord->asDouble(field_Min) && value <= pRecord->asDouble(field_Max) ) { Set_Value(i, pRecord->asDouble(field_Code)); set = true; break; } } else if( opera == 3 ) // min < value < max { if( value > pRecord->asDouble(field_Min) && value < pRecord->asDouble(field_Max) ) { Set_Value(i, pRecord->asDouble(field_Code)); set = true; 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 m_iOrig++; } } } 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; jGet_Attribute_Count(); j++) m_pResult->Set_Attribute(j, m_pInput->Get_Attribute(i, j)); if (!m_bExtract) { if (m_bCreateAttrib) m_pResult->Set_Value(m_pResult->Get_Field_Count()-1, value); else m_pResult->Set_Value(m_AttrField, value); } return; } //--------------------------------------------------------- void CPC_Reclass_Extract::Set_Display_Attributes(CSG_PointCloud *pPC, int iField, CSG_Parameters &sParms) { if (sParms("METRIC_ATTRIB") && sParms("COLORS_TYPE") && sParms("METRIC_COLORS") && sParms("METRIC_ZRANGE") && sParms("DISPLAY_VALUE_AGGREGATE")) { sParms("DISPLAY_VALUE_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("METRIC_ATTRIB")->Set_Value(iField); // attrib sParms("METRIC_ZRANGE")->asRange()->Set_Range(pPC->Get_Minimum(iField), pPC->Get_Maximum(iField)); } DataObject_Set_Parameters(pPC, sParms); DataObject_Update(pPC); return; } //--------------------------------------------------------- int CPC_Reclass_Extract::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("METHOD")) || !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("MODE")) ) { int iMode = pParameters->Get_Parameter("MODE")->asInt(); // 0 == reclassify, 1 == extract int Value = pParameters->Get_Parameter("METHOD")->asInt(); pParameters->Get_Parameter("CREATE_ATTRIB")->Set_Enabled(iMode == 0); // single pParameters->Get_Parameter("OLD" )->Set_Enabled(Value == 0); pParameters->Get_Parameter("NEW" )->Set_Enabled(Value == 0 && iMode == 0); pParameters->Get_Parameter("SOPERATOR" )->Set_Enabled(Value == 0); // range pParameters->Get_Parameter("MIN" )->Set_Enabled(Value == 1); pParameters->Get_Parameter("MAX" )->Set_Enabled(Value == 1); pParameters->Get_Parameter("RNEW" )->Set_Enabled(Value == 1 && iMode == 0); pParameters->Get_Parameter("ROPERATOR" )->Set_Enabled(Value == 1); // simple table pParameters->Get_Parameter("RETAB" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("TOPERATOR" )->Set_Enabled(Value == 2); // user supplied table pParameters->Get_Parameter("RETAB_2" )->Set_Enabled(Value == 3); //pParameters->Get_Parameter("F_MIN" )->Set_Enabled(Value == 3); //pParameters->Get_Parameter("F_MAX" )->Set_Enabled(Value == 3); //pParameters->Get_Parameter("F_CODE" )->Set_Enabled(Value == 3); // other options pParameters->Get_Parameter("NODATAOPT" )->Set_Enabled(iMode == 0); pParameters->Get_Parameter("OTHEROPT" )->Set_Enabled(iMode == 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("NODATAOPT")) ) { pParameters->Get_Parameter("NODATA" )->Set_Enabled(pParameter->asInt() > 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("OTHEROPT")) ) { pParameters->Get_Parameter("OTHERS" )->Set_Enabled(pParameter->asInt() > 0); } //----------------------------------------------------- return (1); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_tools/Makefile.in0000664000175000017500000006030412622651167025666 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/pointcloud/pointcloud_tools DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } 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_attribute_calculator.lo pc_cluster_analysis.lo pc_cut.lo \ pc_drop_attribute.lo pc_from_grid.lo pc_from_shapes.lo \ pc_from_table.lo pc_merge.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) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libpointcloud_tools_la_SOURCES) DIST_SOURCES = $(libpointcloud_tools_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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@ @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @SAGA_UNICODE_FALSE@DEP_DEFS = -fPIC `wx-config --unicode=no --static=no --cxxflags` $(DBGFLAGS) @SAGA_UNICODE_TRUE@DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` -D_SAGA_UNICODE $(DBGFLAGS) @SAGA_UNICODE_FALSE@DEP_LFLG = -fPIC -shared `wx-config --unicode=no --static=no --libs` @SAGA_UNICODE_TRUE@DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` @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) $(DEP_DEFS) $(UC_DEFS) $(DBGFLAGS) $(GOMPFLAGS) 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_from_table.cpp\ pc_merge.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_from_table.h\ pc_merge.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 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) --foreign src/modules/pointcloud/pointcloud_tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/pointcloud/pointcloud_tools/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libpointcloud_tools.la: $(libpointcloud_tools_la_OBJECTS) $(libpointcloud_tools_la_DEPENDENCIES) $(EXTRA_libpointcloud_tools_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libpointcloud_tools_la_OBJECTS) $(libpointcloud_tools_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_attribute_calculator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_cluster_analysis.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_cut.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_drop_attribute.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_from_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_from_shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_from_table.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_merge.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_reclass_extract.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_thinning_simple.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_to_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_to_shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_transform.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_thinning_simple.h0000664000175000017500000001060612565125407027642 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_thinning_simple.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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 CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Thinning_Simple_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_attribute_calculator.h0000664000175000017500000001123012603215353030652 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_attribute_calculator.h 2627 2015-10-01 09:29:25Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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 CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Before_Execution (void); virtual bool On_Execute (void); virtual int On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: CSG_String Get_Formula(CSG_String sFormula, CSG_Table *pTable, int *Fields, int &nFields); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Attribute_Calculator_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_attribute_calculator.cpp0000664000175000017500000002436312603215353031220 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_attribute_calculator.cpp 2627 2015-10-01 09:29:25Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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-213, LASERDATA GmbH")); CSG_String s(_TW( "The Point Cloud Attribute Calculator calculates a new attribute " "based on existing attributes and a mathematical formula. " "Attribute fields are addressed by the character 'f' (for 'field') " "followed by the field number (i.e.: f1, f2, ..., fn) " "or by the field name in square brackets (e.g.: [Field Name]).\n" "Examples:\n" "sin(f1) * f2 + f3\n" "[intensity] / 1000\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_OPTIONAL ); Parameters.Add_String( NULL , "FORMULA" , _TL("Formula"), _TL(""), SG_T("f1+f2") ); Parameters.Add_String( NULL , "NAME" , _TL("Output Field Name"), _TL(""), SG_T("Calculation") ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Field data type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("1 bit"), _TL("1 byte unsigned integer"), _TL("1 byte signed integer"), _TL("2 byte unsigned integer"), _TL("2 byte signed integer"), _TL("4 byte unsigned integer"), _TL("4 byte signed integer"), _TL("4 byte floating point"), _TL("8 byte floating point") ), 7 ); Parameters.Add_Value( NULL , "USE_NODATA" , _TL("Use NoData"), _TL("Check this in order to include NoData points in the calculation."), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------- CPC_Attribute_Calculator::~CPC_Attribute_Calculator(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Attribute_Calculator::On_Before_Execution(void) { if( Parameters("PC_OUT")->asPointCloud() == Parameters("PC_IN")->asPointCloud() ) Parameters("PC_OUT")->Set_Value(DATAOBJECT_NOTSET); return (true); } //--------------------------------------------------------- bool CPC_Attribute_Calculator::On_Execute(void) { CSG_PointCloud *pInput, *pResult; TSG_Data_Type Type; bool bUseNoData; //--------------------------------------------------------- pInput = Parameters("PC_IN")->asPointCloud(); pResult = Parameters("PC_OUT")->asPointCloud(); bUseNoData = Parameters("USE_NODATA")->asBool(); switch( Parameters("TYPE")->asInt() ) { 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: default: Type = SG_DATATYPE_Float; break; case 8: Type = SG_DATATYPE_Double; break; } //----------------------------------------------------- if( !pInput->is_Valid() || pInput->Get_Field_Count() <= 0 || pInput->Get_Record_Count() <= 0 ) { Error_Set(_TL("invalid point cloud")); return( false ); } //----------------------------------------------------- CSG_Formula Formula; int nFields = pInput->Get_Field_Count(); int *pFields = new int[nFields]; if( !Formula.Set_Formula(Get_Formula(Parameters("FORMULA")->asString(), pInput, pFields, nFields)) ) { CSG_String Message; Formula.Get_Error(Message); Error_Set(Message); delete[](pFields); return( false ); } if( nFields == 0 ) { SG_UI_Msg_Add_Error(_TL("No attribute fields specified!")); delete[](pFields); return( false ); } //----------------------------------------------------- CSG_String sName; CSG_MetaData History; if (!pResult || pResult == pInput) { sName = pInput->Get_Name(); pResult = SG_Create_PointCloud(pInput); History = pInput->Get_History(); } else { 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(), Type); //--------------------------------------------------------- CSG_Vector Values(nFields); for( int i=0; iGet_Point_Count() && Set_Progress(i, pInput->Get_Point_Count()); i++ ) { bool bOkay = true; pResult->Add_Point(pInput->Get_X(i), pInput->Get_Y(i), pInput->Get_Z(i)); for( int iField=2; iFieldGet_Field_Count(); iField++ ) pResult->Set_Value(i, iField, pInput->Get_Value(i, iField)); for( int iField=0; iFieldis_NoData(i, pFields[iField]) || bUseNoData ) { Values[iField] = pInput->Get_Value(i, pFields[iField]); } else { bOkay = false; } } if( bOkay ) { pResult->Set_Value(i, pInput->Get_Field_Count(), Formula.Get_Value(Values.Get_Data(), nFields)); } else { pResult->Set_NoData(i, pInput->Get_Field_Count()); } } delete[](pFields); //----------------------------------------------------- if (!Parameters("PC_OUT")->asPointCloud() || Parameters("PC_OUT")->asPointCloud() == pInput) { pInput->Assign(pResult); pInput->Get_History() = History; pInput->Set_Name(sName); Parameters("PC_OUT")->Set_Value(pInput); delete(pResult); } else { DataObject_Update(pResult); } return (true); } //--------------------------------------------------------- CSG_String CPC_Attribute_Calculator::Get_Formula(CSG_String sFormula, CSG_Table *pTable, int *Fields, int &nFields) { const SG_Char vars[27] = SG_T("abcdefghijklmnopqrstuvwxyz"); int iField; for(iField=pTable->Get_Field_Count()-1, nFields=0; iField>=0 && nFields<26; iField--) { bool bUse = false; CSG_String sField; sField.Printf(SG_T("f%d"), iField + 1); if( sFormula.Find(sField) >= 0 ) { sFormula.Replace(sField, CSG_String(vars[nFields])); bUse = true; } sField.Printf(SG_T("[%s]"), pTable->Get_Field_Name(iField)); if( sFormula.Find(sField) >= 0 ) { sFormula.Replace(sField, CSG_String(vars[nFields])); bUse = true; } if( bUse ) { Fields[nFields++] = iField; } } return( sFormula ); } //--------------------------------------------------------- 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); } saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_merge.h0000664000175000017500000001030112602774414025542 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_merge.h 2608 2015-09-27 12:54:38Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_merge.h // // // // Copyright (C) 2012 by // // Magnus Bremer // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: magnus.bremer@uibk.ac.at // // // // contact: Magnus Bremer // // Innrain 52 // // 6020 Innsbruck // // Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_Merge_H #define HEADER_INCLUDED__PC_Merge_H //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Merge : public CSG_Module { public: CPC_Merge(void); virtual ~CPC_Merge(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Merge_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_to_grid.cpp0000664000175000017500000002064412565125407026440 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_to_grid.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_to_grid.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_to_grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_To_Grid::CPC_To_Grid(void) { //----------------------------------------------------- Set_Name (_TL("Point Cloud to Grid")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Z Value"), _TL("") ); Parameters.Add_Grid_Output( NULL , "COUNT" , _TL("Number of Points in Cell"), _TL("") ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Attributes"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("only z"), _TL("all attributes") ), 0 ); Parameters.Add_Choice( NULL , "AGGREGATION" , _TL("Aggregation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("first value"), _TL("last value"), _TL("mean value"), _TL("lowest z"), _TL("highest z") ), 0 ); Parameters.Add_Value( NULL , "CELLSIZE" , _TL("Cellsize"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_To_Grid::On_Execute(void) { int x, y, iField, iGrid; CSG_Grid_System System; CSG_Parameter_Grid_List *pGrids; CSG_PointCloud *pPoints; pPoints = Parameters("POINTS") ->asPointCloud(); pGrids = Parameters("GRIDS") ->asGridList(); m_Aggregation = Parameters("AGGREGATION") ->asInt(); //----------------------------------------------------- System.Assign(Parameters("CELLSIZE")->asDouble(), pPoints->Get_Extent()); //----------------------------------------------------- pGrids->Del_Items(); if( Parameters("OUTPUT")->asInt() != 0 ) { for(iField=3; iFieldGet_Field_Count(); iField++) { pGrids->Add_Item(SG_Create_Grid(System, SG_DATATYPE_Float)); pGrids->asGrid(iField - 3)->Set_Name(CSG_String::Format(SG_T("%s - %s"), pPoints->Get_Name(), pPoints->Get_Field_Name(iField))); } } Parameters("GRID") ->Set_Value(m_pGrid = SG_Create_Grid(System, SG_DATATYPE_Float)); Parameters("COUNT") ->Set_Value(m_pCount = SG_Create_Grid(System, SG_DATATYPE_Int)); m_pGrid ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), pPoints->Get_Field_Name(2))); m_pCount ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Points per Cell"))); m_pCount ->Set_NoData_Value(0.0); //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { pPoints->Set_Cursor(iPoint); if( System.Get_World_to_Grid(x, y, pPoints->Get_X(), pPoints->Get_Y()) ) { int n = m_pCount->asInt(x, y); double z = pPoints->Get_Z(); for(iGrid=0; iGridGet_Count(); iGrid++) { Set_Value(x, y, z, n, pPoints->Get_Value(iGrid + 3), pGrids->asGrid(iGrid)); } Set_Value(x, y, z, n, z, m_pGrid); m_pCount->Add_Value(x, y, 1); } } //----------------------------------------------------- for(y=0; yasInt(x, y); switch( n ) { case 0: m_pGrid->Set_NoData(x, y); for(iGrid=0; iGridGet_Count(); iGrid++) { pGrids->asGrid(iGrid)->Set_NoData(x, y); } break; case 1: break; default: if( m_Aggregation == 2 ) // mean value { m_pGrid->Mul_Value(x, y, 1.0 / n); for(iGrid=0; iGridGet_Count(); iGrid++) { pGrids->asGrid(iGrid)->Mul_Value(x, y, 1.0 / n); } } break; } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CPC_To_Grid::Set_Value(int x, int y, double z, int Count, double value, CSG_Grid *pGrid) { switch( m_Aggregation ) { case 0: // first value if( Count == 0 ) { pGrid->Set_Value(x, y, value); } break; case 1: // last value pGrid->Set_Value(x, y, value); break; case 2: // mean value pGrid->Add_Value(x, y, value); break; case 3: // lowest z if( Count == 0 || z < m_pGrid->asDouble(x, y) ) { pGrid->Set_Value(x, y, value); } break; case 4: // highest z if( Count == 0 || z > m_pGrid->asDouble(x, y) ) { pGrid->Set_Value(x, y, value); } break; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_from_grid.h0000664000175000017500000001010412565125407026414 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_from_grid.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_grid.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_From_Grid_H #define HEADER_INCLUDED__PC_From_Grid //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_From_Grid : public CSG_Module_Grid { public: CPC_From_Grid(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Conversion") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_From_Grid_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_merge.cpp0000664000175000017500000002233112602774414026103 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_merge.cpp 2608 2015-09-27 12:54:38Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_merge.cpp // // // // Copyright (C) 2012 by // // Magnus Bremer // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: magnus.bremer@student.uibk.ac.at // // // // contact: Magnus Bremer // // Innrain 52 // // 6020 Innsbruck // // Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_merge.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Merge::CPC_Merge(void) { Set_Name (_TL("Merge Point Clouds")); Set_Author (SG_T("Magnus Bremer (c) 2012")); Set_Description (_TW("The module can be used to merge Point Clouds.\n" "The attribute fields of the merged point cloud resemble those " "of the main point cloud. In order to merge the attributes of the " "additional point cloud layers, these must be consistent " "(field name and type) with the main point cloud. Missing " "attribute values are set to NoData.\n\n" )); Parameters.Add_PointCloud( NULL , "PC_IN" , _TL("Main Point Cloud"), _TL("Main layer. The output layer will have the same fields in the attribute table as this layer."), PARAMETER_INPUT ); Parameters.Add_PointCloud_List( NULL , "PC_LAYERS" , _TL("Additional Point Clouds"), _TL("Additional point clouds to merge with main point cloud."), PARAMETER_INPUT ); Parameters.Add_PointCloud( NULL , "PC_OUT" , _TL("Merged Point Cloud"), _TL("The merged point cloud."), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "ADD_IDENTIFIER" , _TL("Add Identifier"), _TL("Add unique identifier attribute field to output, ID resembles processing order."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( Parameters("ADD_IDENTIFIER") , "START_VALUE" , _TL("Start Value"), _TL("The start value to use for the identifier."), PARAMETER_TYPE_Int, 0 ); } //--------------------------------------------------------- CPC_Merge::~CPC_Merge(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Merge::On_Execute(void) { CSG_PointCloud *pMain, *pAdd, *pResult; bool bID; int iStartValue; int iAccept = 0; CSG_Parameter_PointCloud_List *pPointCloudList; std::vector FieldNames; std::vector FieldTypes; pMain = Parameters("PC_IN")->asPointCloud(); pPointCloudList = Parameters("PC_LAYERS")->asPointCloudList(); pResult = Parameters("PC_OUT")->asPointCloud(); bID = Parameters("ADD_IDENTIFIER")->asBool(); iStartValue = Parameters("START_VALUE")->asInt(); pResult->Create(pMain); pResult->Set_Name(CSG_String::Format(_TL("%s_merged"), pMain->Get_Name())); if( bID ) pResult->Add_Field(SG_T("ID"), SG_DATATYPE_Int); DataObject_Update(pResult); //copy main layer into destination for(int iField=0; iFieldGet_Attribute_Count(); iField++) { FieldNames.push_back(pMain->Get_Attribute_Name(iField)); FieldTypes.push_back(pMain->Get_Attribute_Type(iField)); } for(int i=0; iGet_Count() && Set_Progress(i, pMain->Get_Count()); i++) { pResult->Add_Point(pMain->Get_X(i), pMain->Get_Y(i), pMain->Get_Z(i)); for(int iField=0; iFieldGet_Attribute_Count(); iField++) { pResult->Set_Attribute(iAccept, iField, pMain->Get_Attribute(i, iField)); } if( bID ) pResult->Set_Attribute(iAccept, pMain->Get_Attribute_Count(), iStartValue); iAccept++; } //copy additional layer into destination if( (pPointCloudList = Parameters("PC_LAYERS")->asPointCloudList()) != NULL && pPointCloudList->Get_Count() > 0 ) { for(int iLayer=0; iLayerGet_Count(); iLayer++) { if( (pAdd = pPointCloudList->asPointCloud(iLayer)) != NULL ) { if( pAdd->Get_Type() == pMain->Get_Type() ) { pAdd = pPointCloudList->asPointCloud(iLayer); std::vector FieldMapping(FieldNames.size(), -1); // pMain to pAdd for(int iField=0; iFieldGet_Attribute_Count(); iField++) { CSG_String ThisField = pAdd->Get_Attribute_Name(iField); for(int j=0; jGet_Attribute_Type(iField) == FieldTypes[j] ) { FieldMapping[j] = iField; break; } } } } for(int i=0; iGet_Count() && Set_Progress(i, pAdd->Get_Count()); i++) { pResult->Add_Point(pAdd->Get_X(i), pAdd->Get_Y(i), pAdd->Get_Z(i)); for(int iField=0; iFieldGet_Attribute_Count(); iField++) { if( FieldMapping[iField] > -1 ) pResult->Set_Attribute(iAccept, iField, pAdd->Get_Attribute(i, FieldMapping[iField])); else pResult->Set_Attribute(iAccept, iField, pMain->Get_NoData_Value()); } if( bID ) { pResult->Set_Attribute(iAccept, pMain->Get_Attribute_Count(), iLayer + iStartValue + 1); } iAccept++; } } } } } CSG_Parameters sParms; DataObject_Get_Parameters(pResult, sParms); if( sParms("METRIC_ATTRIB") && sParms("COLORS_TYPE") && sParms("METRIC_COLORS") && sParms("METRIC_ZRANGE") && sParms("DISPLAY_VALUE_AGGREGATE") ) { sParms("DISPLAY_VALUE_AGGREGATE") ->Set_Value(3); sParms("COLORS_TYPE") ->Set_Value(2); sParms("METRIC_COLORS")->asColors() ->Set_Count(255); sParms("METRIC_ATTRIB") ->Set_Value(2); sParms("METRIC_ZRANGE")->asRange() ->Set_Range(pResult->Get_Minimum(2), pResult->Get_Maximum(2)); } DataObject_Set_Parameters(pResult, sParms); DataObject_Update(pResult); return( true ); } //--------------------------------------------------------- int CPC_Merge::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("ADD_IDENTIFIER")) ) { pParameters->Get_Parameter("START_VALUE")->Set_Enabled(pParameter->asBool()); } //----------------------------------------------------- return (1); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //---------------------------------------------------------saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_cut.h0000664000175000017500000001220712565125407025245 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_cut.h 2427 2015-02-26 16:24:53Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } static bool Get_Cut (CSG_Parameter_PointCloud_List *pPointsList, CSG_Parameter_PointCloud_List *pCutList, const CSG_Rect &Extent, bool bInverse); static bool Get_Cut (CSG_Parameter_PointCloud_List *pPointsList, CSG_Parameter_PointCloud_List *pCutList, 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 CSG_String 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_Parameter_PointCloud_List *m_pPointsList, *m_pCutList; CSG_Shapes *m_pAOI; bool m_bAOIBox, m_bAdd, m_bInverse; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Cut_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_transform.h0000664000175000017500000001053512565125407026467 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_transform.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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 CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Transform_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_to_shapes.h0000664000175000017500000001010112565125407026426 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_to_shapes.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_to_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_To_Shapes_H #define HEADER_INCLUDED__PC_To_Shapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_To_Shapes : public CSG_Module { public: CPC_To_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Conversion") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_To_Shapes_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/MLB_Interface.cpp0000664000175000017500000001217212571530407026713 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2562 2015-08-30 10:50:30Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Point Clouds") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( SG_T("O.Conrad, V.Wichmann, M.Bremer (c) 2009-15") ); 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_from_table.h" #include "pc_merge.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 ); case 12: return( new CPC_Merge ); case 13: return( new CPC_From_Table ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/pointcloud/pointcloud_tools/Makefile.am0000664000175000017500000000253412571530407025652 0ustar00oconradoconrad00000000000000if 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) $(GOMPFLAGS) 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_from_table.cpp\ pc_merge.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_from_table.h\ pc_merge.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 saga-2.2.3/src/modules/pointcloud/pointcloud_tools/MLB_Interface.h0000664000175000017500000000756312565125407026373 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // MLB_Interface.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pointcloud_tools_H #define HEADER_INCLUDED__pointcloud_tools_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef pointcloud_tools_EXPORTS #define pointcloud_tools_EXPORT _SAGA_DLL_EXPORT #else #define pointcloud_tools_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pointcloud_tools_H saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_cluster_analysis.cpp0000664000175000017500000005376212565125407030404 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_cluster_analysis.cpp 2295 2014-10-17 15:35:10Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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" "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... CSG_Parameter *pNode = Parameters.Add_PointCloud( NULL , "PC_IN" ,_TL("Point Cloud"), _TL("Input"), PARAMETER_INPUT ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("The attribute fields to cluster") ); 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_Value( NULL , "UPDATEVIEW" , _TL("Update View"), _TL("Update cluster view while clustering."), PARAMETER_TYPE_Bool, true ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Cluster_Analysis::On_Execute(void) { int nCluster; long nElements; double SP; CSG_Parameters Parms; m_bUpdateView = false; //----------------------------------------------------- nCluster = Parameters("NCLUSTER")->asInt(); pInput = Parameters("PC_IN") ->asPointCloud(); pResult = Parameters("PC_OUT") ->asPointCloud(); if( SG_UI_Get_Window_Main() ) m_bUpdateView = Parameters("UPDATEVIEW")->asBool(); //------------------------------------------------- m_Features = (int *)Parameters("FIELDS")->asPointer(); m_nFeatures = Parameters("FIELDS")->asInt (); if( !m_Features || m_nFeatures <= 0 ) { Error_Set(_TL("no features in selection")); return( false ); } //----------------------------------------------------- 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; //----------------------------------------------------- Process_Set_Text(_TL("Initializing ...")); for( int i=0; i() ); for( int i=0; iGet_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)); for( int j=0; jGet_Attribute_Count(); j++ ) pResult->Set_Attribute(i, j, pInput->Get_Attribute(i, j)); pResult->Set_NoData(i, clustField); bool bNoData = false; for( int j=0; jis_NoData(i, m_Features[j]) ) { bNoData = true; break; } } if( !bNoData ) { for( int j=0; jasBool() ) vValues.at(j).push_back( (pInput->Get_Value(i, m_Features[j]) - pInput->Get_Mean(m_Features[j])) / pInput->Get_StdDev(m_Features[j]) ); else vValues.at(j).push_back(pInput->Get_Value(i, m_Features[j])); } } else { for( int j=0; jGet_NoData_Value()); } } } if( m_bUpdateView ) { if( DataObject_Get_Parameters(pResult, Parms) && Parms("COLORS_TYPE") && Parms("METRIC_ATTRIB") && Parms("METRIC_COLORS") && Parms("METRIC_ZRANGE") ) { Parms("COLORS_TYPE") ->Set_Value(2); // graduated color Parms("METRIC_COLORS")->asColors() ->Set_Count(nCluster); Parms("METRIC_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( int i=0; iGet_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( int i=0; iGet_Variance(m_Features[i])) * Centroids[j][iv] + pInput->Get_Mean(m_Features[i]); } iv++; } } Write_Result(Parameters("STATISTICS")->asTable(), nElements, nCluster, SP); //------------------------------------------------- if( DataObject_Get_Parameters(pResult, Parms) && Parms("COLORS_TYPE") && Parms("LUT") && Parms("LUT_ATTRIB") ) { CSG_Table_Record *pClass; CSG_Table *pLUT = Parms("LUT")->asTable(); for( int i=0; iGet_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("LUT_ATTRIB") ->Set_Value(clustField); DataObject_Set_Parameters(pResult, Parms); } //------------------------------------------------- for( int i=0; iDestroy(); 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") , m_nFeatures, _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"))); for( int j=0; jGet_Field_Name(m_Features[j]))); pTable->Add_Field(pInput->Get_Field_Name(m_Features[j]), SG_DATATYPE_Double); } Message_Add(s); for( int i=0; iAdd_Record(); pRecord->Set_Value(0, i); pRecord->Set_Value(1, nMembers[i]); pRecord->Set_Value(2, Variances[i]); for( int j=0; jSet_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; iElementis_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( m_bUpdateView ) { DataObject_Update(pResult); } //----------------------------------------------------- // Hauptschleife der Iteration for( nPasses=1, bContinue=true; bContinue && Process_Get_Okay(false); nPasses++ ) { //------------------------------------------------- for( iCluster=0; iClusterGet_Value(iElement, clustField) >= 0 ) { iCluster = (int)pResult->Get_Value(iElement, clustField); nMembers[iCluster]++; for( iField=0; iField 0 ? 1.0 / (double)nMembers[iCluster] : 0; for( iField=0; iFieldGet_Value(iElement, clustField) >= 0 ) { minVariance = -1; for( iCluster=0; iClusterGet_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( m_bUpdateView ) { 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; iClusteris_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; iFieldSet_Value(iElement, clustField, -1); } } //----------------------------------------------------- SP = 0.0; for( iCluster=0; iClusterGet_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= 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; iFieldSet_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( m_bUpdateView ) { DataObject_Update(pResult); } } nElements = nClusterElements; return( SP ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/pointcloud/pointcloud_tools/pc_transform.cpp0000664000175000017500000002265412565125407027027 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_transform.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@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_1 = Parameters.Add_Value( pNode_0, "DZ" , _TL("dZ"), _TL("dZ (Map Units)"), PARAMETER_TYPE_Double, 0.0 ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "ROTATE" , _TL("Rotate"), _TL("")); pNode_1 = Parameters.Add_Value( pNode_0 , "ANGLEX" , _TL("Angle X"), _TL("Angle in degrees, clockwise around x axis"), PARAMETER_TYPE_Double, 0.0 ); pNode_1 = Parameters.Add_Value( pNode_0 , "ANGLEY" , _TL("Angle Y"), _TL("Angle in degrees, clockwise around y axis"), PARAMETER_TYPE_Double, 0.0 ); pNode_1 = Parameters.Add_Value( pNode_0 , "ANGLEZ" , _TL("Angle Z"), _TL("Angle in degrees, clockwise around z axis"), 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_1 = Parameters.Add_Value( pNode_0 , "SCALEZ" , _TL("Scale Factor Z"), _TL("Scale Factor Z"), 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 ); pNode_1 = Parameters.Add_Value( pNode_0 , "ANCHORZ" , _TL("Z"), _TL("Z"), PARAMETER_TYPE_Double, 0.0 ); } //--------------------------------------------------------- CPC_Transform::~CPC_Transform(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Transform::On_Execute(void) { bool bCopy; double angleX, angleY, angleZ; TSG_Point_Z P, Q, Move, Scale, Anchor; CSG_PointCloud *pIn, *pOut; double a11, a12, a13, a21, a22, a23, a31, a32, a33; //----------------------------------------------------- pIn = Parameters("IN") ->asPointCloud(); pOut = Parameters("OUT") ->asPointCloud(); Scale.x = Parameters("SCALEX") ->asDouble(); Scale.y = Parameters("SCALEY") ->asDouble(); Scale.z = Parameters("SCALEZ") ->asDouble(); Move.x = Parameters("DX") ->asDouble(); Move.y = Parameters("DY") ->asDouble(); Move.z = Parameters("DZ") ->asDouble(); Anchor.x = Parameters("ANCHORX") ->asDouble(); Anchor.y = Parameters("ANCHORY") ->asDouble(); Anchor.z = Parameters("ANCHORZ") ->asDouble(); angleX = Parameters("ANGLEX") ->asDouble() * -M_DEG_TO_RAD; angleY = Parameters("ANGLEY") ->asDouble() * -M_DEG_TO_RAD; angleZ = Parameters("ANGLEZ") ->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; iPointGet_Point_Count(); iPoint++) { P = pIn->Get_Point(iPoint); //anchor shift P.x -= Anchor.x; P.y -= Anchor.y; P.z -= Anchor.z; // create rotation matrix a11 = cos(angleY) * cos(angleZ); a12 = -cos(angleX) * sin(angleZ) + sin(angleX) * sin(angleY) * cos(angleZ); a13 = sin(angleX) * sin(angleZ) + cos(angleX) * sin(angleY) * cos(angleZ); a21 = cos(angleY) * sin(angleZ); a22 = cos(angleX) * cos(angleZ) + sin(angleX) * sin(angleY) * sin(angleZ); a23 = -sin(angleX) * cos(angleZ) + cos(angleX) * sin(angleY) * sin(angleZ); a31 = -sin(angleY); a32 = sin(angleX) * cos(angleY); a33 = cos(angleX) * cos(angleY); //transform Q.x = (P.x * a11 + P.y * a12 + P.z * a13) * Scale.x; Q.y = (P.x * a21 + P.y * a22 + P.z * a23) * Scale.y; Q.z = (P.x * a31 + P.y * a32 + P.z * a33) * Scale.z; //undo anchor shift and apply move Q.x += Anchor.x + Move.x; Q.y += Anchor.y + Move.y; Q.z += Anchor.z + Move.z; pOut->Add_Point(Q.x, Q.y, Q.z); for (int iField=0; iFieldGet_Attribute_Count(); iField++) pOut->Set_Attribute(iPoint, iField, pIn->Get_Attribute(iPoint, iField)); } //----------------------------------------------------- if( bCopy ) { pIn->Assign(pOut); delete(pOut); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/0000775000175000017500000000000012634325750020227 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/statistics/statistics_kriging/0000775000175000017500000000000012634325751024134 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/statistics/statistics_kriging/variogram_dialog.cpp0000664000175000017500000004364012565125413030151 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: variogram_dialog.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // geostatistics_kriging_variogram // // // //-------------------------------------------------------// // // // Variogram_Dialog.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "variogram_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Variogram::CSG_Variogram(void) {} //--------------------------------------------------------- bool CSG_Variogram::Calculate(CSG_Shapes *pPoints, int Attribute, bool bLog, CSG_Table *pVariogram, int nClasses, double maxDistance, int nSkip) { int i, j, k, n; double z, lagDistance; TSG_Point p; CSG_Vector Count, Variance; CSG_Table_Record *pRecord; CSG_Shape *pPoint; //----------------------------------------------------- if( nSkip < 1 ) { nSkip = 1; } if( maxDistance <= 0.0 || maxDistance > SG_Get_Length(pPoints->Get_Extent().Get_XRange(), pPoints->Get_Extent().Get_YRange()) ) { maxDistance = SG_Get_Length(pPoints->Get_Extent().Get_XRange(), pPoints->Get_Extent().Get_YRange()); // bounding box' diagonal } lagDistance = maxDistance / nClasses; Count .Create(nClasses); Variance .Create(nClasses); //----------------------------------------------------- for(i=0, n=0; iGet_Count()-nSkip && SG_UI_Process_Set_Progress(n, SG_Get_Square(pPoints->Get_Count()/nSkip)/2); i+=nSkip) { pPoint = pPoints->Get_Shape(i); if( !pPoint->is_NoData(Attribute) ) { p = pPoint->Get_Point(0); z = bLog ? log(pPoint->asDouble(Attribute)) : pPoint->asDouble(Attribute); for(j=i+nSkip; jGet_Count(); j+=nSkip, n++) { pPoint = pPoints->Get_Shape(j); if( !pPoint->is_NoData(Attribute) ) { k = (int)(SG_Get_Distance(p, pPoint->Get_Point(0)) / lagDistance); if( k < nClasses ) { Count [k] ++; Variance[k] += SG_Get_Square((bLog ? log(pPoint->asDouble(Attribute)) : pPoint->asDouble(Attribute)) - z); } } } } } //----------------------------------------------------- pVariogram->Destroy(); pVariogram->Set_Name(CSG_String::Format(SG_T("%s [%s]"), _TL("Variogram"), pPoints->Get_Name())); pVariogram->Add_Field(_TL("Class") , SG_DATATYPE_Int); // FIELD_CLASS pVariogram->Add_Field(_TL("Distance") , SG_DATATYPE_Double); // FIELD_DISTANCE pVariogram->Add_Field(_TL("Count") , SG_DATATYPE_Int); // FIELD_COUNT pVariogram->Add_Field(_TL("Variance") , SG_DATATYPE_Double); // FIELD_VAR_EXP pVariogram->Add_Field(_TL("Var.cum.") , SG_DATATYPE_Double); // FIELD_VAR_CUM pVariogram->Add_Field(_TL("Model") , SG_DATATYPE_Double); // FIELD_VAR_MODEL for(i=0, z=0.0, n=0; i 0 ) { n += (int)Count[i]; z += Variance[i]; pRecord = pVariogram->Add_Record(); pRecord->Set_Value(FIELD_CLASS , (i + 1)); pRecord->Set_Value(FIELD_DISTANCE , (i + 1) * lagDistance); pRecord->Set_Value(FIELD_COUNT , Count[i]); pRecord->Set_Value(FIELD_VAR_EXP , 0.5 * Variance[i] / Count[i]); pRecord->Set_Value(FIELD_VAR_CUM , 0.5 * z / n); } } //----------------------------------------------------- return( SG_UI_Process_Get_Okay() ); } //--------------------------------------------------------- double CSG_Variogram::Get_Lag_Distance(CSG_Shapes *pPoints, int Method, int nSkip) { if( Method == 0 ) { CSG_PRQuadTree QT(pPoints, 0); CSG_Simple_Statistics s; double x, y, z; if( nSkip < 1 ) { nSkip = 1; } for(int iPoint=0; iPointGet_Count() && ::SG_UI_Process_Set_Progress(iPoint, pPoints->Get_Count()); iPoint+=nSkip) { 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 && s.Get_Mean() > 0.0 ) { return( s.Get_Mean() ); } } return( 0.25 * sqrt((pPoints->Get_Extent().Get_XRange() * pPoints->Get_Extent().Get_YRange()) / pPoints->Get_Count()) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CVariogram_Diagram : public CSGDI_Diagram { public: CVariogram_Diagram(wxWindow *pParent); bool m_bPairs; void Initialize (CSG_Trend *pModel, CSG_Table *pVariogram); void Set_Variogram (void); private: CSG_Table *m_pVariogram; CSG_Trend *m_pModel; virtual void On_Draw (wxDC &dc, wxRect rDraw); }; //--------------------------------------------------------- CVariogram_Diagram::CVariogram_Diagram(wxWindow *pParent) : CSGDI_Diagram(pParent) { m_xName = _TL("Distance"); m_yName = _TL("Variance"); m_pModel = NULL; m_pVariogram = NULL; m_bPairs = false; } //--------------------------------------------------------- void CVariogram_Diagram::Initialize(CSG_Trend *pModel, CSG_Table *pVariogram) { m_pModel = pModel; m_pVariogram = pVariogram; } //--------------------------------------------------------- void CVariogram_Diagram::Set_Variogram(void) { m_xMin = m_yMin = 0.0; m_xMax = (1.0 + 0.00) * m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_DISTANCE); m_yMax = (1.0 + 0.02) * m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_VAR_EXP ); } //--------------------------------------------------------- void CVariogram_Diagram::On_Draw(wxDC &dc, wxRect rDraw) { if( m_pVariogram->Get_Count() > 0 ) { int i, ix, iy, jx, jy; double x, dx; //------------------------------------------------- if( m_pModel->Get_Data_Count() > 0 ) { ix = Get_xToScreen(m_pModel->Get_Data_XMax()); dc.SetPen (wxPen(wxColour( 0, 127, 0), 2)); dc.DrawLine(ix, Get_yToScreen(m_yMin), ix, Get_yToScreen(m_yMax)); } //------------------------------------------------- if( m_bPairs && m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_COUNT) > 0 ) { double dScale = m_yMax / m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_COUNT); dc.SetPen (wxColour(191, 191, 191)); dc.SetBrush(wxColour(191, 191, 191)); for(i=0; iGet_Count(); i++) { CSG_Table_Record *pRecord = m_pVariogram->Get_Record(i); ix = Get_xToScreen(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE)); iy = Get_yToScreen(pRecord->asDouble(CSG_Variogram::FIELD_COUNT ) * dScale); dc.DrawCircle(ix, iy, 3); } } //------------------------------------------------- dc.SetPen (wxColour(127, 127, 127)); dc.SetBrush(wxColour( 0, 0, 0)); for(i=0; iGet_Count(); i++) { CSG_Table_Record *pRecord = m_pVariogram->Get_Record(i); ix = Get_xToScreen(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE)); iy = Get_yToScreen(pRecord->asDouble(CSG_Variogram::FIELD_VAR_EXP )); dc.DrawCircle(ix, iy, 3); } //------------------------------------------------- if( m_pModel->is_Okay() ) { dc.SetPen(wxPen(*wxRED, 2)); dx = (m_xMax - m_xMin) / (double)rDraw.GetWidth(); ix = Get_xToScreen(m_xMin); iy = Get_yToScreen(m_pModel->Get_Value(m_xMin)); for(x=m_xMin+dx; x<=m_xMax; x+=dx) { jx = ix; jy = iy; ix = Get_xToScreen(x); iy = Get_yToScreen(m_pModel->Get_Value(x)); dc.DrawLine(jx, jy, ix, iy); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(CVariogram_Dialog, CSGDI_Dialog) EVT_BUTTON (wxID_ANY , CVariogram_Dialog::On_Button) EVT_CHECKBOX (wxID_ANY , CVariogram_Dialog::On_Update_Control) EVT_TEXT_ENTER (wxID_ANY , CVariogram_Dialog::On_Update_Control) EVT_SLIDER (wxID_ANY , CVariogram_Dialog::On_Update_Control) EVT_CHOICE (wxID_ANY , CVariogram_Dialog::On_Update_Choices) END_EVENT_TABLE() //--------------------------------------------------------- CVariogram_Dialog::CVariogram_Dialog(void) : CSGDI_Dialog(_TL("Variogram")) { m_pPoints = NULL; m_nPoints = 0; m_Attribute = 0; m_pVariogram = NULL; m_pModel = NULL; m_Distance = -1; //----------------------------------------------------- wxArrayString Formulas; Formulas.Empty(); Formulas.Add(SG_T("a + b * x")); // 1st order polynom (linear) Formulas.Add(SG_T("a + b * x + c * x^2")); // 2nd order polynom (quadric) Formulas.Add(SG_T("a + b * x + c * x^2 + d * x^3")); // 3rd order polynom (cubic) Formulas.Add(SG_T("a + b * x + c * x^2 + d * x^3 + e * x^4")); // 4th order polynom Formulas.Add(SG_T("a + b * sqrt(x)")); // square root Formulas.Add(SG_T("a + b * ln(x)")); // logarithmic Formulas.Add(SG_T("a + b * x^c")); // exponential Formulas.Add(SG_T("a + b * (1 - exp(-(x / b)^2))")); // gaussian Formulas.Add(SG_T("a + b * ifelse(x > c, 1, 1.5 * x / c - 0.5 * x^3 / c^3)")); // spherical //----------------------------------------------------- Add_Button(_TL("Ok") , wxID_OK); Add_Button(_TL("Cancel") , wxID_CANCEL); Add_Spacer(); m_pSettings = Add_Button (_TL("Settings"), wxID_ANY); Add_Spacer(); m_pPairs = Add_CheckBox (_TL("Number of Pairs"), false); Add_Spacer(); m_pFormulas = Add_Choice (_TL("Predefined Functions"), Formulas, 0); Add_Spacer(); m_pDistance = Add_Slider (_TL("Function Fitting Range"), 1, 0, 1); Add_Spacer(); m_pParameters = Add_TextCtrl (_TL("Function Parameters"), wxTE_MULTILINE|wxTE_READONLY); //----------------------------------------------------- Add_Output( m_pDiagram = new CVariogram_Diagram(this), m_pFormula = new wxTextCtrl(this, wxID_ANY, SG_T("a + b * x"), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER), 1, 0 ); //----------------------------------------------------- m_Settings.Set_Name(_TL("Variogram Settings")); m_Settings.Add_Value (NULL, "SKIP" , _TL("Skip" ), _TL(""), PARAMETER_TYPE_Int , 1, 1, true); m_Settings.Add_Value (NULL, "LAGDIST", _TL("Lag Distance" ), _TL(""), PARAMETER_TYPE_Double, 1, 0.0, true); m_Settings.Add_Value (NULL, "MAXDIST", _TL("Maximum Distance"), _TL(""), PARAMETER_TYPE_Double, 1, 0.0, true); m_Settings.Add_String(NULL, "MODEL" , _TL("Model" ), _TL(""), SG_T("a + b * x")); } //--------------------------------------------------------- bool CVariogram_Dialog::Execute(CSG_Shapes *pPoints, int Attribute, bool bLog, CSG_Table *pVariogram, CSG_Trend *pModel) { if( m_pPoints != pPoints || m_nPoints != pPoints->Get_Count() || !m_Extent.is_Equal(pPoints->Get_Extent()) ) { m_pPoints = pPoints; m_nPoints = pPoints->Get_Count(); m_Extent = pPoints->Get_Extent(); m_Distance = -1; int nSkip = 1 + m_pPoints->Get_Count() / 10000; m_Settings("SKIP" )->Set_Value(nSkip); m_Settings("LAGDIST")->Set_Value(CSG_Variogram::Get_Lag_Distance(m_pPoints, 0, nSkip)); m_Settings("MAXDIST")->Set_Value(0.5 * sqrt(SG_Get_Square(m_pPoints->Get_Extent().Get_XRange()) + SG_Get_Square(m_pPoints->Get_Extent().Get_YRange()))); } m_Attribute = Attribute; m_bLog = bLog; m_pVariogram = pVariogram; m_pModel = pModel; m_pDiagram->Initialize(m_pModel, m_pVariogram); //----------------------------------------------------- Set_Variogram(); return( ShowModal() == wxID_OK && m_pModel && m_pModel->is_Okay() ); } //--------------------------------------------------------- void CVariogram_Dialog::On_Update_Control(wxCommandEvent &WXUNUSED(event)) { Set_Model(); } void CVariogram_Dialog::On_Update_Choices(wxCommandEvent &WXUNUSED(event)) { m_pFormula->SetValue(m_pFormulas->GetStringSelection().c_str()); Set_Model(); } //--------------------------------------------------------- void CVariogram_Dialog::On_Button(wxCommandEvent &event) { if( event.GetEventObject() == m_pSettings ) { if( SG_UI_Dlg_Parameters(&m_Settings, m_Settings.Get_Name()) ) { m_pFormula ->SetValue (m_Settings("MODEL") ->asString()); Set_Variogram(); } } else { event.Skip(); } } //--------------------------------------------------------- void CVariogram_Dialog::Set_Variogram(void) { double lagDist = m_Settings("LAGDIST")->asDouble(); double maxDist = m_Settings("MAXDIST")->asDouble(); if( lagDist > 0.0 ) { double Diagonal = SG_Get_Length(m_pPoints->Get_Extent().Get_XRange(), m_pPoints->Get_Extent().Get_YRange()); // bounding box's diagonal if( maxDist <= 0.0 || maxDist > Diagonal ) { m_Settings("MAXDIST")->Set_Value(maxDist = Diagonal); } CSG_Variogram::Calculate(m_pPoints, m_Attribute, m_bLog, m_pVariogram, 1 + (int)(0.5 + maxDist / lagDist), maxDist, m_Settings("SKIP")->asInt() ); m_pDistance->Set_Range(0.0, m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_DISTANCE)); m_pDistance->Set_Value(m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_DISTANCE)); m_pDiagram->Set_Variogram(); Set_Model(); } } //--------------------------------------------------------- void CVariogram_Dialog::Set_Model(void) { //----------------------------------------------------- if( m_Distance < 0 || m_Distance != m_pDistance->Get_Value() ) { m_Distance = m_pDistance->Get_Value(); m_pModel->Clr_Data(); for(int i=0; iGet_Count(); i++) { CSG_Table_Record *pRecord = m_pVariogram->Get_Record(i); if( pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE) <= m_Distance ) { m_pModel->Add_Data(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE), pRecord->asDouble(CSG_Variogram::FIELD_VAR_EXP)); } } m_pModel->Get_Trend(); } //----------------------------------------------------- wxString s; if( !m_pModel->Set_Formula(m_pFormula->GetValue().c_str()) ) { s += m_pModel->Get_Error().w_str(); } else if( !m_pModel->Get_Trend() ) { s += _TL("function fitting failed !"); } else { s += m_pModel->Get_Formula(SG_TREND_STRING_Function).w_str(); s += wxString::Format(wxT("\n%s:\t%.2f%%"), _TL("Determination") , m_pModel->Get_R2() * 100.0); s += wxString::Format(wxT("\n%s:\t%.*f") , _TL("Fitting range") , SG_Get_Significant_Decimals(m_pDistance->Get_Value()), m_pDistance->Get_Value()); s += wxString::Format(wxT("\n%s:\t%d") , _TL("Samples in range") , m_pModel->Get_Data_Count()); s += wxString::Format(wxT("\n%s:\t%d") , _TL("Lag Classes") , m_pVariogram->Get_Count()); s += wxString::Format(wxT("\n%s:\t%.2f") , _TL("Lag Distance") , m_Settings("LAGDIST")->asDouble()); s += wxString::Format(wxT("\n%s:\t%.2f") , _TL("Maximum Distance") , m_Settings("MAXDIST")->asDouble()); m_Settings("MODEL")->Set_Value(m_pModel->Get_Formula(SG_TREND_STRING_Formula)); } m_pParameters->SetValue(s); m_pDiagram->m_bPairs = m_pPairs->GetValue(); m_pDiagram->Refresh(true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_kriging/semivariogram.cpp0000664000175000017500000001573212603000414027473 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: semivariogram.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Geostatistics_Points // // // //-------------------------------------------------------// // // // semivariogram.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "semivariogram.h" #include "variogram_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSemiVariogram::CSemiVariogram(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Variogram (Dialog)")); Set_Author ("O.Conrad (c) 2009"); Set_Description (_TW( "" )); //----------------------------------------------------- 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 , "VARIOGRAM" , _TL("Variogram"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "LOG" , _TL("Logarithmic Transformation"), _TL(""), PARAMETER_TYPE_Bool ); //----------------------------------------------------- Parameters.Add_Value( NULL , "VAR_MAXDIST" , _TL("Maximum Distance"), _TL(""), PARAMETER_TYPE_Double , -1.0 )->Set_UseInGUI(false); Parameters.Add_Value( NULL , "VAR_NCLASSES" , _TL("Lag Distance Classes"), _TL("initial number of lag distance classes"), PARAMETER_TYPE_Int , 100, 1, true )->Set_UseInGUI(false); Parameters.Add_Value( NULL , "VAR_NSKIP" , _TL("Skip"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true )->Set_UseInGUI(false); Parameters.Add_String( NULL , "VAR_MODEL" , _TL("Model"), _TL(""), SG_T("a + b * x") )->Set_UseInGUI(false); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSemiVariogram::On_Execute(void) { bool bLog, bResult = false; int Attribute; CSG_Trend Model; CSG_Shapes *pPoints; CSG_Table *pVariogram; //----------------------------------------------------- pPoints = Parameters("POINTS") ->asShapes(); Attribute = Parameters("ATTRIBUTE") ->asInt(); bLog = Parameters("LOG") ->asBool(); pVariogram = Parameters("VARIOGRAM") ->asTable(); //----------------------------------------------------- if( SG_UI_Get_Window_Main() ) { static CVariogram_Dialog dlg; if( dlg.Execute(pPoints, Attribute, bLog, pVariogram, &Model) ) { bResult = true; } } //----------------------------------------------------- else { int nSkip = Parameters("VAR_NSKIP") ->asInt(); int nClasses = Parameters("VAR_NCLASSES") ->asInt(); double maxDistance = Parameters("VAR_MAXDIST") ->asDouble(); Model.Set_Formula(Parameters("VAR_MODEL")->asString()); if( CSG_Variogram::Calculate(pPoints, Attribute, bLog, pVariogram, nClasses, maxDistance, nSkip) ) { Model.Clr_Data(); for(int i=0; iGet_Count(); i++) { CSG_Table_Record *pRecord = pVariogram->Get_Record(i); Model.Add_Data(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE), pRecord->asDouble(CSG_Variogram::FIELD_VAR_EXP)); } bResult = Model.Get_Trend() || Model.Get_Parameter_Count() == 0; } } //----------------------------------------------------- if( bResult ) { Message_Add(Model.Get_Formula(), false); for(int i=0; iGet_Count(); i++) { CSG_Table_Record *pRecord = pVariogram->Get_Record(i); pRecord->Set_Value(CSG_Variogram::FIELD_VAR_MODEL, Model.Get_Value(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE))); } } return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_kriging/kriging_simple.h0000664000175000017500000001051612565125413027307 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: kriging_simple.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // geostatistics_kriging_variogram // // // //-------------------------------------------------------// // // // kriging_simple.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__kriging_simple_H #define HEADER_INCLUDED__kriging_simple_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "kriging_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CKriging_Simple : public CKriging_Base { public: CKriging_Simple(void); protected: virtual bool Get_Weights (const CSG_Points_Z &Points, CSG_Matrix &W); virtual bool Get_Value (const TSG_Point &p, double &z, double &v); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__kriging_simple_H saga-2.2.3/src/modules/statistics/statistics_kriging/kriging_ordinary.h0000664000175000017500000001072212565125413027644 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: kriging_ordinary.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // geostatistics_kriging_variogram // // // //-------------------------------------------------------// // // // Kriging_Ordinary.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Kriging_Ordinary_H #define HEADER_INCLUDED__Kriging_Ordinary_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "kriging_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CKriging_Ordinary : public CKriging_Base { public: CKriging_Ordinary(void); protected: virtual bool Get_Weights (const CSG_Points_Z &Points, CSG_Matrix &W); virtual bool Get_Value (const TSG_Point &p, double &z, double &v); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Kriging_Ordinary_H saga-2.2.3/src/modules/statistics/statistics_kriging/kriging_base.cpp0000664000175000017500000002766212603000414027257 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: kriging_base.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // geostatistics_kriging_variogram // // // //-------------------------------------------------------// // // // kriging_base.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "variogram_dialog.h" #include "kriging_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CKriging_Base::CKriging_Base(void) { CSG_Parameter *pNode; /////////////////////////////////////////////////////// //----------------------------------------------------- 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_Choice( NULL , "TQUALITY" , _TL("Type of Quality Measure"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("standard deviation"), _TL("variance") ), 0 ); Parameters.Add_Value( NULL , "LOG" , _TL("Logarithmic Transformation"), _TL(""), PARAMETER_TYPE_Bool ); pNode = Parameters.Add_Value( NULL , "BLOCK" , _TL("Block Kriging"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( pNode , "DBLOCK" , _TL("Block Size"), _TL(""), PARAMETER_TYPE_Double, 100.0, 0.0, true ); /////////////////////////////////////////////////////// //----------------------------------------------------- Parameters.Add_Value( NULL , "VAR_MAXDIST" , _TL("Maximum Distance"), _TL(""), PARAMETER_TYPE_Double, -1.0 )->Set_UseInGUI(false); Parameters.Add_Value( NULL , "VAR_NCLASSES" , _TL("Lag Distance Classes"), _TL("initial number of lag distance classes"), PARAMETER_TYPE_Int, 100, 1, true )->Set_UseInGUI(false); Parameters.Add_Value( NULL , "VAR_NSKIP" , _TL("Skip"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true )->Set_UseInGUI(false); Parameters.Add_String( NULL , "VAR_MODEL" , _TL("Model"), _TL(""), SG_T("a + b * x") )->Set_UseInGUI(false); if( !SG_UI_Get_Window_Main() ) { m_pVariogram = NULL; } else { m_pVariogram = new CVariogram_Dialog; } /////////////////////////////////////////////////////// //----------------------------------------------------- m_Grid_Target.Create(&Parameters, false, NULL, "TARGET_"); m_Grid_Target.Add_Grid("PREDICTION", _TL("Prediction" ), false); m_Grid_Target.Add_Grid("VARIANCE" , _TL("Quality Measure"), true); //----------------------------------------------------- m_Search.Create(&Parameters, Parameters.Add_Node(NULL, "NODE_SEARCH", _TL("Search Options"), _TL("")), 16); } /////////////////////////////////////////////////////////// //--------------------------------------------------------- CKriging_Base::~CKriging_Base(void) { if( m_pVariogram && SG_UI_Get_Window_Main() ) // don't destroy dialog, if gui is closing (i.e. main window == NULL) { m_pVariogram->Destroy(); delete(m_pVariogram); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CKriging_Base::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "POINTS") ) { m_Search.On_Parameter_Changed(pParameters, pParameter); m_Grid_Target.Set_User_Defined(pParameters, pParameter->asShapes()); } return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CKriging_Base::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "BLOCK") ) { pParameters->Set_Enabled("DBLOCK", pParameter->asBool()); // block size } m_Search.On_Parameters_Enable(pParameters, pParameter); return( m_Grid_Target.On_Parameters_Enable(pParameters, pParameter) ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKriging_Base::On_Execute(void) { bool bResult = false; //----------------------------------------------------- m_Block = Parameters("BLOCK" )->asBool() ? Parameters("DBLOCK")->asDouble() / 2.0 : 0.0; m_bStdDev = Parameters("TQUALITY")->asInt() == 0; m_bLog = Parameters("LOG" )->asBool(); m_pPoints = Parameters("POINTS" )->asShapes(); m_zField = Parameters("FIELD" )->asInt(); if( m_pPoints->Get_Count() <= 1 ) { SG_UI_Msg_Add(_TL("not enough points for interpolation"), true); return( false ); } //----------------------------------------------------- CSG_Table Variogram; if( m_pVariogram ) { if( m_pVariogram->Execute(m_pPoints, m_zField, m_bLog, &Variogram, &m_Model) ) { bResult = true; } } else { int nSkip = Parameters("VAR_NSKIP" )->asInt(); int nClasses = Parameters("VAR_NCLASSES")->asInt(); double maxDistance = Parameters("VAR_MAXDIST" )->asDouble(); m_Model.Set_Formula(Parameters("VAR_MODEL")->asString()); if( CSG_Variogram::Calculate(m_pPoints, m_zField, m_bLog, &Variogram, nClasses, maxDistance, nSkip) ) { m_Model.Clr_Data(); for(int i=0; iasDouble(CSG_Variogram::FIELD_DISTANCE), pRecord->asDouble(CSG_Variogram::FIELD_VAR_EXP)); } bResult = m_Model.Get_Trend() || m_Model.Get_Parameter_Count() == 0; } } //----------------------------------------------------- if( bResult && (bResult = _Initialise_Grids() && On_Initialize()) ) { Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("variogram model"), m_Model.Get_Formula(SG_TREND_STRING_Formula_Parameters).c_str()), false); for(int y=0; yGet_NY() && Set_Progress(y, m_pGrid->Get_NY()); y++) { #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double z, v; if( Get_Value(m_pGrid->Get_System().Get_Grid_to_World(x, y), z, v) ) { Set_Value(x, y, z, v); } else { Set_NoData(x, y); } } } } //----------------------------------------------------- m_Model .Clr_Data(); m_Search.Finalize(); m_Data .Clear(); m_W .Destroy(); return( bResult ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKriging_Base::_Initialise_Grids(void) { m_Grid_Target.Cmd_Update(m_pPoints); // if called from saga_cmd if( (m_pGrid = m_Grid_Target.Get_Grid("PREDICTION")) != NULL ) { m_pGrid->Set_Name(CSG_String::Format(SG_T("%s.%s [%s]"), Parameters("POINTS")->asShapes()->Get_Name(), Parameters("FIELD")->asString(), Get_Name().c_str())); if( (m_pVariance = m_Grid_Target.Get_Grid("VARIANCE")) != NULL ) { m_pVariance->Set_Name(CSG_String::Format(SG_T("%s.%s [%s %s]"), Parameters("POINTS")->asShapes()->Get_Name(), Parameters("FIELD")->asString(), Get_Name().c_str(), m_bStdDev ? _TL("Standard Deviation") : _TL("Variance"))); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKriging_Base::On_Initialize(void) { //----------------------------------------------------- if( m_Search.Do_Use_All(true) ) // global { m_Data.Clear(); for(int i=0; iGet_Count(); i++) { CSG_Shape *pPoint = m_pPoints->Get_Shape(i); if( !pPoint->is_NoData(m_zField) ) { m_Data.Add(pPoint->Get_Point(0).x, pPoint->Get_Point(0).y, m_bLog ? log(pPoint->asDouble(m_zField)) : pPoint->asDouble(m_zField)); } } return( Get_Weights(m_Data, m_W) ); } //----------------------------------------------------- if( m_bLog ) { CSG_Shapes Points(SHAPE_TYPE_Point); Points.Add_Field("Z", SG_DATATYPE_Double); for(int i=0; iGet_Count() && Set_Progress(i, m_pPoints->Get_Count()); i++) { CSG_Shape *pPoint = m_pPoints->Get_Shape(i); if( !pPoint->is_NoData(m_zField) ) { Points.Add_Shape(pPoint, SHAPE_COPY_GEOM)->Set_Value(0, log(pPoint->asDouble(m_zField))); } } return( m_Search.Initialize(&Points, 0) ); } //----------------------------------------------------- return( m_Search.Initialize(m_pPoints, m_zField) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_kriging/semivariogram.h0000664000175000017500000001021112565125413027141 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: semivariogram.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Geostatistics_Points // // // //-------------------------------------------------------// // // // semivariogram.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__semivariogram_H #define HEADER_INCLUDED__semivariogram_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSemiVariogram : public CSG_Module { public: CSemiVariogram(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Spatial and Geostatistics|Points") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__semivariogram_H saga-2.2.3/src/modules/statistics/statistics_kriging/kriging_regression.h0000664000175000017500000001102412565125413030171 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: kriging_regression.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_kriging // // // //-------------------------------------------------------// // // // kriging_regression.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__kriging_regression_H #define HEADER_INCLUDED__kriging_regression_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "kriging_ordinary.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CKriging_Regression : public CSG_Module_Grid { public: CKriging_Regression(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CKriging_Ordinary m_OK; CSG_Parameters_Search_Points m_Search; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__kriging_regression_H saga-2.2.3/src/modules/statistics/statistics_kriging/kriging_universal.cpp0000664000175000017500000002301612565125413030360 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: kriging_universal.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Geostatistics_Kriging // // // //-------------------------------------------------------// // // // Kriging_Universal.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "kriging_universal.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CKriging_Universal::CKriging_Universal(void) { //----------------------------------------------------- Set_Name (_TL("Universal Kriging")); Set_Author ("O.Conrad (c) 2008"); Set_Description (_TW( "Universal Kriging for grid interpolation from irregular sample points." )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Node( NULL , "NODE_UK" , _TL("Universal Kriging"), _TL("") ); Parameters.Add_Grid_List( pNode , "PREDICTORS" , _TL("Predictors"), _TL(""), PARAMETER_INPUT_OPTIONAL, false ); Parameters.Add_Choice( pNode ,"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_Value( pNode , "COORDS" , _TL("Coordinates"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKriging_Universal::On_Initialize(void) { m_pGrids = Parameters("PREDICTORS")->asGridList(); m_Interpolation = Parameters("INTERPOL" )->asInt(); m_bCoords = Parameters("COORDS" )->asBool(); //----------------------------------------------------- if( m_Search.Do_Use_All(true) ) // global { m_Data.Clear(); for(int i=0; iGet_Count(); i++) { CSG_Shape *pPoint = m_pPoints->Get_Shape(i); if( !pPoint->is_NoData(m_zField) ) { bool bAdd = true; // for better performance, make sure all predictors supply a value now for(int j=0; bAdd && jGet_Count(); j++) { bAdd = m_pGrids->asGrid(j)->is_InGrid_byPos(pPoint->Get_Point(0)); } if( bAdd ) { m_Data.Add(pPoint->Get_Point(0).x, pPoint->Get_Point(0).y, m_bLog ? log(pPoint->asDouble(m_zField)) : pPoint->asDouble(m_zField)); } } } return( Get_Weights(m_Data, m_W) ); } //----------------------------------------------------- if( m_bLog ) { CSG_Shapes Points(SHAPE_TYPE_Point); Points.Add_Field("Z", SG_DATATYPE_Double); for(int iPoint=0; iPointGet_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 better performance, make sure all predictors supply a value now for(int j=0; bAdd && jGet_Count(); j++) { bAdd = m_pGrids->asGrid(j)->is_InGrid_byPos(pPoint->Get_Point(0)); } if( bAdd ) { Points.Add_Shape(pPoint, SHAPE_COPY_GEOM)->Set_Value(0, log(pPoint->asDouble(m_zField))); } } } return( m_Search.Initialize(&Points, 0) ); } //----------------------------------------------------- return( m_Search.Initialize(m_pPoints, m_zField) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKriging_Universal::Get_Weights(const CSG_Points_Z &Points, CSG_Matrix &W) { int n = Points.Get_Count(); if( n > 0 ) { int i, j, k; int nCoords = m_bCoords ? 2 : 0; int nGrids = m_pGrids->Get_Count(); W.Create(n + 1 + nGrids + nCoords, n + 1 + nGrids + nCoords); //------------------------------------------------- for(i=0; iasGrid(k)->Get_Value(Points.Get_X(i), Points.Get_Y(i), m_Interpolation); } for(k=0, j=n+nGrids+1; kGet_Count()) > 0 ) { int nCoords = m_bCoords ? 2 : 0; int nGrids = m_pGrids->Get_Count(); CSG_Vector G(n + 1 + nGrids + nCoords); for(i=0; iGet_Point(i)); } G[n] = 1.0; for(i=0, j=n+1; iasGrid(i)->Get_Value(p, G[j], m_Interpolation) ) { return( false ); } } if( m_bCoords ) { G[n + 1 + nGrids] = p.x; G[n + 2 + nGrids] = p.y; } //------------------------------------------------- for(i=0, z=0.0, v=0.0; iGet_Z(i); v += Lambda * G[i]; } //------------------------------------------------- return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_kriging/Makefile.in0000664000175000017500000005700712622651174026210 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/statistics/statistics_kriging DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libstatistics_kriging_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la \ $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la am_libstatistics_kriging_la_OBJECTS = kriging_base.lo \ kriging_ordinary.lo kriging_regression.lo kriging_simple.lo \ kriging_universal.lo MLB_Interface.lo semivariogram.lo \ variogram_dialog.lo libstatistics_kriging_la_OBJECTS = \ $(am_libstatistics_kriging_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libstatistics_kriging_la_SOURCES) DIST_SOURCES = $(libstatistics_kriging_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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@ @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @SAGA_UNICODE_FALSE@DEP_DEFS = -fPIC `wx-config --unicode=no --static=no --cxxflags` $(DBGFLAGS) @SAGA_UNICODE_TRUE@DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` -D_SAGA_UNICODE $(DBGFLAGS) @SAGA_UNICODE_FALSE@DEP_LFLG = -fPIC -shared `wx-config --unicode=no --static=no --libs` @SAGA_UNICODE_TRUE@DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` 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) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libstatistics_kriging.la libstatistics_kriging_la_SOURCES = \ kriging_base.cpp\ kriging_ordinary.cpp\ kriging_regression.cpp\ kriging_simple.cpp\ kriging_universal.cpp\ MLB_Interface.cpp\ semivariogram.cpp\ variogram_dialog.cpp\ kriging_base.h\ kriging_ordinary.h\ kriging_regression.h\ kriging_simple.h\ kriging_universal.h\ MLB_Interface.h\ semivariogram.h\ variogram_dialog.h libstatistics_kriging_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.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) --foreign src/modules/statistics/statistics_kriging/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/statistics/statistics_kriging/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libstatistics_kriging.la: $(libstatistics_kriging_la_OBJECTS) $(libstatistics_kriging_la_DEPENDENCIES) $(EXTRA_libstatistics_kriging_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libstatistics_kriging_la_OBJECTS) $(libstatistics_kriging_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kriging_base.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kriging_ordinary.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kriging_regression.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kriging_simple.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kriging_universal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/semivariogram.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/variogram_dialog.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/statistics/statistics_kriging/kriging_regression.cpp0000664000175000017500000003350712603000414030520 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: kriging_regression.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Geostatistics_Kriging // // // //-------------------------------------------------------// // // // kriging_regression.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "kriging_regression.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CKriging_Regression::CKriging_Regression(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Regression Kriging")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "Regression Kriging for grid interpolation from irregular sample points." )); /////////////////////////////////////////////////////// //----------------------------------------------------- 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_List( NULL , "PREDICTORS" , _TL("Predictors"), _TL(""), PARAMETER_INPUT, true ); Parameters.Add_Grid( NULL , "REGRESSION" , _TL("Regression"), _TL("regression model applied to predictor grids"), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "PREDICTION" , _TL("Prediction"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "RESIDUALS" , _TL("Residuals"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "VARIANCE" , _TL("Quality Measure"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "TQUALITY" , _TL("Type of Quality Measure"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("standard deviation"), _TL("variance") ), 0 ); /////////////////////////////////////////////////////// //----------------------------------------------------- Parameters.Add_Value( NULL , "LOG" , _TL("Logarithmic Transformation"), _TL(""), PARAMETER_TYPE_Bool ); pNode = Parameters.Add_Value( NULL , "BLOCK" , _TL("Block Kriging"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( pNode , "DBLOCK" , _TL("Block Size"), _TL(""), PARAMETER_TYPE_Double, 100.0, 0.0, true ); /////////////////////////////////////////////////////// //----------------------------------------------------- Parameters.Add_Value( NULL , "VAR_MAXDIST" , _TL("Maximum Distance"), _TL("maximum distance for variogram estimation"), PARAMETER_TYPE_Double, -1.0 )->Set_UseInGUI(false); Parameters.Add_Value( NULL , "VAR_NCLASSES" , _TL("Lag Distance Classes"), _TL("initial number of lag distance classes for variogram estimation"), PARAMETER_TYPE_Int, 100, 1, true )->Set_UseInGUI(false); Parameters.Add_Value( NULL , "VAR_NSKIP" , _TL("Skip"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true )->Set_UseInGUI(false); Parameters.Add_String( NULL , "VAR_MODEL" , _TL("Variogram Model"), _TL(""), "a + b * x" )->Set_UseInGUI(false); /////////////////////////////////////////////////////// //----------------------------------------------------- Parameters.Add_Table(NULL , "INFO_COEFF" , _TL("Regression: Coefficients"), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Table(NULL , "INFO_MODEL" , _TL("Regression: Model" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Table(NULL , "INFO_STEPS" , _TL("Regression: Steps" ), _TL(""), PARAMETER_OUTPUT_OPTIONAL); pNode = Parameters.Add_Node( NULL , "NODE_REG", _TL("Regression"), _TL("") ); Parameters.Add_Value(pNode , "COORD_X" , _TL("Include X Coordinate"), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode , "COORD_Y" , _TL("Include Y Coordinate"), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode , "INTERCEPT" , _TL("Intercept" ), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( pNode ,"METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("include all"), _TL("forward"), _TL("backward"), _TL("stepwise") ), 3 ); Parameters.Add_Value( pNode , "P_VALUE" , _TL("Significance Level"), _TL("Significance level (aka p-value) as threshold for automated predictor selection, given as percentage"), PARAMETER_TYPE_Double, 5.0, 0.0, true, 100.0, true ); Parameters.Add_Choice( pNode ,"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 ); /////////////////////////////////////////////////////// //----------------------------------------------------- m_Search.Create(&Parameters, Parameters.Add_Node(NULL, "NODE_SEARCH", _TL("Search Options"), _TL("")), 16); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CKriging_Regression::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "POINTS") ) { m_Search.On_Parameter_Changed(pParameters, pParameter); } //----------------------------------------------------- return( CSG_Module_Grid::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CKriging_Regression::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Search.On_Parameters_Enable(pParameters, pParameter); //----------------------------------------------------- return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKriging_Regression::On_Execute(void) { //----------------------------------------------------- CSG_Shapes Points(SHAPE_TYPE_Point); CSG_Grid *pPrediction = Parameters("PREDICTION")->asGrid(); CSG_Grid *pRegression = Parameters("REGRESSION")->asGrid(); CSG_Grid *pResiduals = Parameters("RESIDUALS" )->asGrid(); CSG_Grid *pVariance = Parameters("VARIANCE" )->asGrid(); //----------------------------------------------------- if( !pResiduals ) { pResiduals = pPrediction; } //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("statistics_regression", 1, // Multiple Regression Analysis (Points and Predictor Grids) SG_MODULE_PARAMETER_SET("PREDICTORS", Parameters("PREDICTORS")) && SG_MODULE_PARAMETER_SET("POINTS" , Parameters("POINTS" )) && SG_MODULE_PARAMETER_SET("ATTRIBUTE" , Parameters("FIELD" )) && SG_MODULE_PARAMETER_SET("INFO_COEFF", Parameters("INFO_COEFF")) && SG_MODULE_PARAMETER_SET("INFO_MODEL", Parameters("INFO_MODEL")) && SG_MODULE_PARAMETER_SET("INFO_STEPS", Parameters("INFO_STEPS")) && SG_MODULE_PARAMETER_SET("INTERPOL" , Parameters("INTERPOL" )) && SG_MODULE_PARAMETER_SET("COORD_X" , Parameters("COORD_X" )) && SG_MODULE_PARAMETER_SET("COORD_Y" , Parameters("COORD_Y" )) && SG_MODULE_PARAMETER_SET("INTERCEPT" , Parameters("INTERCEPT" )) && SG_MODULE_PARAMETER_SET("METHOD" , Parameters("METHOD" )) && SG_MODULE_PARAMETER_SET("P_VALUE" , Parameters("P_VALUE" )) && SG_MODULE_PARAMETER_SET("REGRESSION", pRegression) && SG_MODULE_PARAMETER_SET("RESIDUALS" , &Points ) ); //----------------------------------------------------- Process_Set_Text(m_OK.Get_Name()); m_OK.Set_Manager(NULL); if( !m_OK.Set_Parameter("POINTS" , &Points) || !m_OK.Set_Parameter("FIELD" , 2) // residual || !m_OK.Set_Parameter("LOG" , Parameters("LOG" )) || !m_OK.Set_Parameter("BLOCK" , Parameters("BLOCK" )) || !m_OK.Set_Parameter("DBLOCK" , Parameters("DBLOCK" )) || !m_OK.Set_Parameter("SEARCH_RANGE" , Parameters("SEARCH_RANGE" )) || !m_OK.Set_Parameter("SEARCH_RADIUS" , Parameters("SEARCH_RADIUS" )) || !m_OK.Set_Parameter("SEARCH_POINTS_ALL", Parameters("SEARCH_POINTS_ALL")) || !m_OK.Set_Parameter("SEARCH_POINTS_MIN", Parameters("SEARCH_POINTS_MIN")) || !m_OK.Set_Parameter("SEARCH_POINTS_MAX", Parameters("SEARCH_POINTS_MAX")) || !m_OK.Set_Parameter("SEARCH_DIRECTION" , Parameters("SEARCH_DIRECTION" )) || !m_OK.Set_Parameter("TARGET_DEFINITION", 1) // grid or grid system || !m_OK.Set_Parameter("PREDICTION" , pResiduals) || !m_OK.Set_Parameter("VARIANCE" , pVariance ) || (!SG_UI_Get_Window_Main() && ( // saga_cmd !m_OK.Set_Parameter("VAR_MAXDIST" , Parameters("VAR_MAXDIST" )) || !m_OK.Set_Parameter("VAR_NCLASSES" , Parameters("VAR_NCLASSES" )) || !m_OK.Set_Parameter("VAR_NSKIP" , Parameters("VAR_NSKIP" )) || !m_OK.Set_Parameter("VAR_MODEL" , Parameters("VAR_MODEL" )))) ) { Error_Set(CSG_String::Format(SG_T("%s [%s].[%s]"), _TL("could not initialize tool"), SG_T("statistics_regression"), m_OK.Get_Name().c_str())); return( false ); } if( !m_OK.Execute() ) { Error_Set(CSG_String::Format(SG_T("%s [%s].[%s]"), _TL("could not execute tool"), SG_T("statistics_regression"), m_OK.Get_Name().c_str()));\ return( false ); } //----------------------------------------------------- #pragma omp parallel for for(int y=0; yis_NoData(x, y) || pResiduals->is_NoData(x, y) ) { pPrediction->Set_NoData(x, y); } else { pPrediction->Add_Value(x, y, pRegression->asDouble(x, y) + pResiduals->asDouble(x, y)); } } } //----------------------------------------------------- pRegression->Set_Name(CSG_String::Format("%s.%s [%s]", Parameters("POINTS")->asGrid()->Get_Name(), Parameters("FIELD")->asString(), _TL("Regression"))); pPrediction->Set_Name(CSG_String::Format("%s.%s [%s]", Parameters("POINTS")->asGrid()->Get_Name(), Parameters("FIELD")->asString(), _TL("Prediction"))); if( Parameters("RESIDUALS")->asGrid() ) { pResiduals->Set_Name(CSG_String::Format("%s.%s [%s]", Parameters("POINTS")->asGrid()->Get_Name(), Parameters("FIELD")->asString(), _TL("Residuals"))); } if( pVariance ) { pVariance ->Set_Name(CSG_String::Format("%s.%s [%s]", Parameters("POINTS")->asGrid()->Get_Name(), Parameters("FIELD")->asString(), _TL("Quality"))); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_kriging/kriging_universal.h0000664000175000017500000001114212565125413030022 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: kriging_universal.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // geostatistics_kriging_variogram // // // //-------------------------------------------------------// // // // Kriging_Universal.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Kriging_Universal_H #define HEADER_INCLUDED__Kriging_Universal_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "kriging_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CKriging_Universal : public CKriging_Base { public: CKriging_Universal(void); protected: virtual bool On_Initialize (void); virtual bool Get_Weights (const CSG_Points_Z &Points, CSG_Matrix &W); virtual bool Get_Value (const TSG_Point &p, double &z, double &v); private: bool m_bCoords; int m_Interpolation; CSG_Parameter_Grid_List *m_pGrids; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Kriging_Universal_H saga-2.2.3/src/modules/statistics/statistics_kriging/kriging_simple.cpp0000664000175000017500000001351012565125413027637 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: kriging_simple.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Geostatistics_Kriging // // // //-------------------------------------------------------// // // // kriging_simple.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "kriging_simple.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CKriging_Simple::CKriging_Simple(void) { //----------------------------------------------------- Set_Name (_TL("Simple Kriging")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "Simple Kriging for grid interpolation from irregular sample points." )); //----------------------------------------------------- } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKriging_Simple::Get_Weights(const CSG_Points_Z &Points, CSG_Matrix &W) { int n = Points.Get_Count(); if( n > 0 ) { int n = Points.Get_Count(); W.Create(n, n); for(int i=0; iGet_Count()) > 0 ) { CSG_Vector G(n); for(i=0; iGet_Point(i)); } //------------------------------------------------- for(i=0, z=0.0, v=0.0; iGet_Z(i); v += Lambda * G[i]; } //------------------------------------------------- return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_kriging/kriging_ordinary.cpp0000664000175000017500000001401212565125413030173 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: kriging_ordinary.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Geostatistics_Kriging // // // //-------------------------------------------------------// // // // Kriging_Ordinary.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "kriging_ordinary.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CKriging_Ordinary::CKriging_Ordinary(void) { //----------------------------------------------------- Set_Name (_TL("Ordinary Kriging")); Set_Author ("O.Conrad (c) 2008"); Set_Description (_TW( "Ordinary Kriging for grid interpolation from irregular sample points." )); //----------------------------------------------------- } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKriging_Ordinary::Get_Weights(const CSG_Points_Z &Points, CSG_Matrix &W) { int n = Points.Get_Count(); if( n > 0 ) { W.Create(n + 1, n + 1); for(int i=0; iGet_Count()) > 0 ) { CSG_Vector G(n + 1); for(i=0; iGet_Point(i)); } G[n] = 1.0; //------------------------------------------------- for(i=0, z=0.0, v=0.0; iGet_Z(i); v += Lambda * G[i]; } //------------------------------------------------- return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_kriging/MLB_Interface.cpp0000664000175000017500000001177612565125413027242 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Geostatistics_Kriging // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Kriging") ); case MLB_INFO_Category: return( _TL("Spatial and Geostatistics") ); case MLB_INFO_Author: 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." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Spatial and Geostatistics|Kriging" )); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "kriging_simple.h" #include "kriging_ordinary.h" #include "kriging_universal.h" #include "kriging_regression.h" #include "semivariogram.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 1: return( new CKriging_Simple ); case 0: return( new CKriging_Ordinary ); case 2: return( new CKriging_Universal ); case 3: return( new CKriging_Regression ); case 4: return( new CSemiVariogram ); case 5: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/statistics/statistics_kriging/Makefile.am0000664000175000017500000000222412565125413026164 0ustar00oconradoconrad00000000000000if 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` 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 = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libstatistics_kriging.la libstatistics_kriging_la_SOURCES =\ kriging_base.cpp\ kriging_ordinary.cpp\ kriging_regression.cpp\ kriging_simple.cpp\ kriging_universal.cpp\ MLB_Interface.cpp\ semivariogram.cpp\ variogram_dialog.cpp\ kriging_base.h\ kriging_ordinary.h\ kriging_regression.h\ kriging_simple.h\ kriging_universal.h\ MLB_Interface.h\ semivariogram.h\ variogram_dialog.h libstatistics_kriging_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la $(ADD_MLBS) saga-2.2.3/src/modules/statistics/statistics_kriging/MLB_Interface.h0000664000175000017500000000745412565125413026705 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Geostatistics_Kriging // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_kriging_H #define HEADER_INCLUDED__geostatistics_kriging_H //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__geostatistics_kriging_H saga-2.2.3/src/modules/statistics/statistics_kriging/variogram_dialog.h0000664000175000017500000001375112565125413027616 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: variogram_dialog.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // image_io // // // //-------------------------------------------------------// // // // Variogram_Dialog.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Variogram_Dialog_H #define HEADER_INCLUDED__Variogram_Dialog_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSG_Variogram { public: enum ESG_Variogram_Field { FIELD_CLASS = 0, FIELD_DISTANCE, FIELD_COUNT, FIELD_VAR_EXP, FIELD_VAR_CUM, FIELD_VAR_MODEL }; CSG_Variogram(void); static bool Calculate (CSG_Shapes *pPoints, int Attribute, bool bLog, CSG_Table *pVariogram, int nClasses = 25, double maxDistance = 0.0, int nSkip = 1); static double Get_Lag_Distance (CSG_Shapes *pPoints, int Method, int nSkip = 1); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CVariogram_Dialog : public CSGDI_Dialog { public: CVariogram_Dialog(void); bool Execute (CSG_Shapes *pPoints, int Attribute, bool bLog, CSG_Table *pVariogram, CSG_Trend *pModel); private: wxButton *m_pSettings; wxCheckBox *m_pPairs; wxChoice *m_pFormulas; wxTextCtrl *m_pFormula, *m_pParameters; CSGDI_Slider *m_pDistance; class CVariogram_Diagram *m_pDiagram; CSG_Parameters m_Settings; CSG_Trend *m_pModel; CSG_Table *m_pVariogram; CSG_Shapes *m_pPoints; CSG_Rect m_Extent; bool m_bLog; int m_Attribute, m_nPoints; double m_Distance; void On_Update_Control (wxCommandEvent &event); void On_Update_Choices (wxCommandEvent &event); void On_Button (wxCommandEvent &event); void Set_Variogram (void); void Set_Model (void); DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Variogram_Dialog_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_kriging/kriging_base.h0000664000175000017500000001455212565125413026734 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: kriging_base.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // geostatistics_kriging_variogram // // // //-------------------------------------------------------// // // // kriging_base.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__kriging_base_H #define HEADER_INCLUDED__kriging_base_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CKriging_Base : public CSG_Module { public: CKriging_Base(void); ~CKriging_Base(void); protected: bool m_bLog; int m_zField; CSG_Points_Z m_Data; CSG_Matrix m_W; CSG_Shapes *m_pPoints; CSG_Parameters_Search_Points m_Search; virtual bool On_Execute (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Initialize (void); virtual bool Get_Weights (const CSG_Points_Z &Points, CSG_Matrix &W) = 0; virtual bool Get_Value (const TSG_Point &p, double &z, double &v) = 0; double Get_Weight (double d) { return( m_Model.Get_Value(d) ); } double Get_Weight (double dx, double dy) { return( Get_Weight(sqrt(dx*dx + dy*dy)) ); } double Get_Weight (const TSG_Point_Z &a, const TSG_Point_Z &b) { return( Get_Weight(a.x - b.x, a.y - b.y) ); } double Get_Weight (const TSG_Point &a, const TSG_Point_Z &b) { return( Get_Weight(a.x - b.x, a.y - b.y) ); } double Get_Weight (double ax, double ay, double bx, double by) { if( m_Block > 0.0 ) { return( ( Get_Weight( ax - bx, ay - by) + Get_Weight((ax + m_Block) - bx, (ay + m_Block) - by) + Get_Weight((ax + m_Block) - bx, (ay - m_Block) - by) + Get_Weight((ax - m_Block) - bx, (ay + m_Block) - by) + Get_Weight((ax - m_Block) - bx, (ay - m_Block) - by) ) / 5.0 ); } return( Get_Weight(ax - bx, ay - by) ); } void Set_Value (int x, int y, double z, double v) { if( m_pGrid ) m_pGrid ->Set_Value(x, y, m_bLog ? exp (z) : z); if( m_pVariance ) m_pVariance->Set_Value(x, y, m_bStdDev ? sqrt(v) : v); } void Set_NoData (int x, int y) { if( m_pGrid ) m_pGrid ->Set_NoData(x, y); if( m_pVariance ) m_pVariance->Set_NoData(x, y); } private: bool m_bStdDev; double m_Block; CSG_Parameters_Grid_Target m_Grid_Target; CSG_Trend m_Model; CSG_Grid *m_pGrid, *m_pVariance; class CVariogram_Dialog *m_pVariogram; bool _Initialise_Grids (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__kriging_base_H saga-2.2.3/src/modules/statistics/statistics_points/0000775000175000017500000000000012634325747024023 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/statistics/statistics_points/GSPoints_Variogram_Surface.h0000664000175000017500000001044512565125413031354 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSPoints_Variogram_Surface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 saga-2.2.3/src/modules/statistics/statistics_points/GSPoints_Semi_Variances.h0000664000175000017500000001061312565125413030642 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSPoints_Semi_Variances.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_points // // // //-------------------------------------------------------// // // // GSPoints_Semi_Variances.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GSPoints_Semi_Variances_H #define HEADER_INCLUDED__GSPoints_Semi_Variances_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGSPoints_Semi_Variances : public CSG_Module { public: CGSPoints_Semi_Variances(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GSPoints_Semi_Variances_H saga-2.2.3/src/modules/statistics/statistics_points/GSPoints_Distances.h0000664000175000017500000001011312565125413027662 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSPoints_Distances.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 saga-2.2.3/src/modules/statistics/statistics_points/GSPoints_Pattern_Analysis.cpp0000664000175000017500000002121312565125413031563 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSPoints_Pattern_Analysis.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_points // // // //-------------------------------------------------------// // // // GSPoints_Pattern_Analysis.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "GSPoints_Pattern_Analysis.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGSPoints_Pattern_Analysis::CGSPoints_Pattern_Analysis(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Spatial Point Pattern Analysis")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description( _TL("Basic measures for spatial point patterns.") ); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "CENTRE" , _TL("Mean Centre"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); pNode = Parameters.Add_Shapes( NULL , "STDDIST" , _TL("Standard Distance"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( pNode , "STEP" , _TL("Vertex Distance [Degree]"), _TL(""), PARAMETER_TYPE_Double, 5.0, 0.1, true, 20.0, true ); Parameters.Add_Shapes( NULL , "BBOX" , _TL("Bounding Box"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGSPoints_Pattern_Analysis::On_Execute(void) { int iPoint; double StdDist; CSG_Shape *pShape; CSG_Shapes *pPoints, *pShapes; CSG_Simple_Statistics X, Y, D; //----------------------------------------------------- pPoints = Parameters("POINTS") ->asShapes(); if( pPoints->Get_Count() <= 1 ) { Error_Set(_TL("not enough points to perform pattern analysis")); return( false ); } //----------------------------------------------------- for(iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { TSG_Point p = pPoints->Get_Shape(iPoint)->Get_Point(0); X.Add_Value(p.x); Y.Add_Value(p.y); } if( X.Get_Range() == 0.0 && Y.Get_Range() == 0.0 ) { Error_Set(_TL("no variation in point pattern")); return( false ); } //----------------------------------------------------- StdDist = 0.0; for(iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { TSG_Point p = pPoints->Get_Shape(iPoint)->Get_Point(0); D.Add_Value(SG_Get_Distance(X.Get_Mean(), Y.Get_Mean(), p.x, p.y)); StdDist += SG_Get_Square(p.x - X.Get_Mean()) + SG_Get_Square(p.y - Y.Get_Mean()); } StdDist = sqrt(StdDist / D.Get_Count()); //----------------------------------------------------- pShapes = Parameters("CENTRE") ->asShapes(); pShapes ->Create(SHAPE_TYPE_Point , CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Centre"))); pShapes ->Add_Field(SG_T("X_CENTRE"), SG_DATATYPE_Double); pShapes ->Add_Field(SG_T("Y_CENTRE"), SG_DATATYPE_Double); pShapes ->Add_Field(SG_T("N_POINTS"), SG_DATATYPE_Double); pShapes ->Add_Field(SG_T("STDDIST" ), SG_DATATYPE_Double); pShapes ->Add_Field(SG_T("MEANDIST"), SG_DATATYPE_Double); pShape = pShapes->Add_Shape(); pShape ->Set_Value(0, X.Get_Mean()); pShape ->Set_Value(1, Y.Get_Mean()); pShape ->Set_Value(2, D.Get_Count()); pShape ->Set_Value(3, StdDist); pShape ->Set_Value(4, D.Get_StdDev()); pShape ->Add_Point(X.Get_Mean(), Y.Get_Mean()); //----------------------------------------------------- pShapes = Parameters("STDDIST") ->asShapes(); pShapes ->Create(SHAPE_TYPE_Polygon , CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Standard Distance"))); pShapes ->Add_Field(SG_T("X_CENTRE"), SG_DATATYPE_Double); pShapes ->Add_Field(SG_T("Y_CENTRE"), SG_DATATYPE_Double); pShapes ->Add_Field(SG_T("N_POINTS"), SG_DATATYPE_Double); pShapes ->Add_Field(SG_T("STDDIST") , SG_DATATYPE_Double); pShape = pShapes->Add_Shape(); pShape ->Set_Value(0, X.Get_Mean()); pShape ->Set_Value(1, Y.Get_Mean()); pShape ->Set_Value(2, X.Get_Count()); pShape ->Set_Value(3, StdDist); double dTheta = Parameters("STEP")->asDouble() * M_DEG_TO_RAD; for(double Theta=0.0; Theta<=M_PI_360; Theta+=dTheta) { pShape ->Add_Point( X.Get_Mean() + StdDist * cos(Theta), Y.Get_Mean() + StdDist * sin(Theta) ); } //----------------------------------------------------- pShapes = Parameters("BBOX") ->asShapes(); pShapes ->Create(SHAPE_TYPE_Polygon , CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Bounding Box"))); pShapes ->Add_Field(SG_T("XMIN") , SG_DATATYPE_Double); pShapes ->Add_Field(SG_T("XMAX") , SG_DATATYPE_Double); pShapes ->Add_Field(SG_T("YMIN") , SG_DATATYPE_Double); pShapes ->Add_Field(SG_T("YMAX") , SG_DATATYPE_Double); pShape = pShapes->Add_Shape(); pShape ->Set_Value(0, X.Get_Minimum()); pShape ->Set_Value(1, X.Get_Maximum()); pShape ->Set_Value(2, Y.Get_Minimum()); pShape ->Set_Value(3, Y.Get_Maximum()); pShape ->Add_Point(X.Get_Minimum(), Y.Get_Minimum()); pShape ->Add_Point(X.Get_Minimum(), Y.Get_Maximum()); pShape ->Add_Point(X.Get_Maximum(), Y.Get_Maximum()); pShape ->Add_Point(X.Get_Maximum(), Y.Get_Minimum()); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_points/GSPoints_Variogram_Surface.cpp0000664000175000017500000002034312565125413031705 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSPoints_Variogram_Surface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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) { sLong i; int 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; iGet_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; jGet_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; iGet_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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_points/GSPoints_Variogram_Cloud.h0000664000175000017500000001043112565125413031025 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSPoints_Variogram_Cloud.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 saga-2.2.3/src/modules/statistics/statistics_points/Makefile.in0000664000175000017500000005576512622651174026103 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/statistics/statistics_points DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libstatistics_points_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libstatistics_points_la_OBJECTS = GSPoints_Distances.lo \ GSPoints_Pattern_Analysis.lo GSPoints_Semi_Variances.lo \ GSPoints_Variogram_Cloud.lo GSPoints_Variogram_Surface.lo \ MLB_Interface.lo libstatistics_points_la_OBJECTS = \ $(am_libstatistics_points_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libstatistics_points_la_SOURCES) DIST_SOURCES = $(libstatistics_points_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libstatistics_points.la libstatistics_points_la_SOURCES = \ GSPoints_Distances.cpp\ GSPoints_Pattern_Analysis.cpp\ GSPoints_Semi_Variances.cpp\ GSPoints_Variogram_Cloud.cpp\ GSPoints_Variogram_Surface.cpp\ MLB_Interface.cpp\ GSPoints_Distances.h\ GSPoints_Pattern_Analysis.h\ GSPoints_Semi_Variances.h\ GSPoints_Variogram_Cloud.h\ GSPoints_Variogram_Surface.h\ MLB_Interface.h libstatistics_points_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) --foreign src/modules/statistics/statistics_points/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/statistics/statistics_points/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libstatistics_points.la: $(libstatistics_points_la_OBJECTS) $(libstatistics_points_la_DEPENDENCIES) $(EXTRA_libstatistics_points_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libstatistics_points_la_OBJECTS) $(libstatistics_points_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSPoints_Distances.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSPoints_Pattern_Analysis.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSPoints_Semi_Variances.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSPoints_Variogram_Cloud.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSPoints_Variogram_Surface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/statistics/statistics_points/GSPoints_Pattern_Analysis.h0000664000175000017500000001016512565125413031234 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSPoints_Pattern_Analysis.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_points // // // //-------------------------------------------------------// // // // GSPoints_Pattern_Analysis.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GSPoints_Pattern_Analysis_H #define HEADER_INCLUDED__GSPoints_Pattern_Analysis_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGSPoints_Pattern_Analysis : public CSG_Module { public: CGSPoints_Pattern_Analysis(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GSPoints_Pattern_Analysis_H saga-2.2.3/src/modules/statistics/statistics_points/GSPoints_Variogram_Cloud.cpp0000664000175000017500000001731112565125413031364 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSPoints_Variogram_Cloud.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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; iGet_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; jGet_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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_points/GSPoints_Semi_Variances.cpp0000664000175000017500000002102512565125413031174 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSPoints_Semi_Variances.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_points // // // //-------------------------------------------------------// // // // GSPoints_Semi_Variances.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "GSPoints_Semi_Variances.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { FIELD_CLASSNR = 0, FIELD_DISTANCE, FIELD_COUNT, FIELD_VARIANCE, FIELD_VARCUMUL, FIELD_COVARIANCE, FIELD_COVARCUMUL }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGSPoints_Semi_Variances::CGSPoints_Semi_Variances(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Variogram")); 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("Sample Variogram"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "DISTCOUNT" , _TL("Initial Number of Distance Classes"), _TL(""), PARAMETER_TYPE_Int , 100, 1, true ); 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_Semi_Variances::On_Execute(void) { 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; //----------------------------------------------------- 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 ) { maxDistance = SG_Get_Length(pPoints->Get_Extent().Get_XRange(), pPoints->Get_Extent().Get_YRange()); } lagDistance = maxDistance / nDistances; zMean = pPoints->Get_Mean(Attribute); Count .Create(nDistances); Variance .Create(nDistances); Covariance .Create(nDistances); //----------------------------------------------------- for(i=0, n=0; iGet_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; jGet_Count(); j+=nSkip, n++) { pPoint = pPoints->Get_Shape(j); if( !pPoint->is_NoData(Attribute) ) { Pt_j = pPoint->Get_Point(0); k = (int)(SG_Get_Distance(Pt_i, Pt_j) / lagDistance); if( k < nDistances ) { zj = pPoint->asDouble(Attribute); v = SG_Get_Square(zi - zj); c = (zi - zMean) * (zj - zMean); Count [k] ++; Variance [k] += v; Covariance[k] += c; } } } } } //----------------------------------------------------- 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 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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_points/MLB_Interface.cpp0000664000175000017500000001174712565125413027122 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_points // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Points") ); case MLB_INFO_Category: return( _TL("Spatial and Geostatistics") ); case MLB_INFO_Author: return( SG_T("O.Conrad (c) 2002-10") ); case MLB_INFO_Description: return( _TL("Spatial and geostatistical analyses of point data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Spatial and Geostatistics|Points") ); } } //--------------------------------------------------------- // 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" #include "GSPoints_Pattern_Analysis.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { 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 ); case 4: return( new CGSPoints_Pattern_Analysis ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/statistics/statistics_points/Makefile.am0000664000175000017500000000156412565125413026054 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libstatistics_points.la libstatistics_points_la_SOURCES =\ GSPoints_Distances.cpp\ GSPoints_Pattern_Analysis.cpp\ GSPoints_Semi_Variances.cpp\ GSPoints_Variogram_Cloud.cpp\ GSPoints_Variogram_Surface.cpp\ MLB_Interface.cpp\ GSPoints_Distances.h\ GSPoints_Pattern_Analysis.h\ GSPoints_Semi_Variances.h\ GSPoints_Variogram_Cloud.h\ GSPoints_Variogram_Surface.h\ MLB_Interface.h libstatistics_points_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/statistics/statistics_points/MLB_Interface.h0000664000175000017500000000744012565125413026562 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_points // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__statistics_points_H #define HEADER_INCLUDED__statistics_points_H //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__statistics_points_H saga-2.2.3/src/modules/statistics/statistics_points/GSPoints_Distances.cpp0000664000175000017500000001410212565125413030217 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSPoints_Distances.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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; iPointGet_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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/Makefile.in0000664000175000017500000004607512622651174022307 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/statistics DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = statistics_points statistics_grid statistics_regression \ statistics_kriging 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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@ @WITH_GUI_FALSE@SUBDIRS = statistics_points statistics_grid statistics_regression @WITH_GUI_TRUE@SUBDIRS = statistics_points statistics_kriging statistics_grid statistics_regression 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) --foreign src/modules/statistics/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/statistics/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/statistics/statistics_regression/0000775000175000017500000000000012634325750024661 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/statistics/statistics_regression/gw_regression.cpp0000664000175000017500000002220312571551577030251 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gw_regression.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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("GWR for Single Predictor (Gridded Model Output)")); Set_Author ("O.Conrad (c) 2010"); Set_Description (_TW( "Reference:\n" ) + GWR_References); //----------------------------------------------------- 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("") ); //----------------------------------------------------- m_Grid_Target.Create(&Parameters, true, NULL, "TARGET_"); m_Grid_Target.Add_Grid("INTERCEPT", _TL("Intercept"), false); m_Grid_Target.Add_Grid("SLOPE" , _TL("Slope" ), false); m_Grid_Target.Add_Grid("QUALITY" , _TL("Quality" ), false); //----------------------------------------------------- m_Weighting.Set_Weighting(SG_DISTWGHT_GAUSS); m_Weighting.Create_Parameters(&Parameters, false); //----------------------------------------------------- m_Search.Create(&Parameters, Parameters.Add_Node(NULL, "NODE_SEARCH", _TL("Search Options"), _TL("")), 16); Parameters("SEARCH_RANGE")->Set_Value(1); Parameters("SEARCH_POINTS_ALL")->Set_Value(1); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGW_Regression::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "POINTS") ) { m_Grid_Target.Set_User_Defined(pParameters, pParameter->asShapes()); m_Search.On_Parameter_Changed(pParameters, pParameter); pParameters->Set_Parameter("DW_BANDWIDTH", GWR_Fit_To_Density(pParameter->asShapes(), 4.0, 1)); } return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CGW_Regression::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Search.On_Parameters_Enable(pParameters, pParameter); m_Weighting.Enable_Parameters(pParameters); return( m_Grid_Target.On_Parameters_Enable(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_Weighting.Set_Parameters(&Parameters); //----------------------------------------------------- if( !m_Search.Initialize(m_pPoints, -1) ) { return( false ); } //----------------------------------------------------- m_Grid_Target.Cmd_Update(m_pPoints); // if called from saga_cmd m_pQuality = m_Grid_Target.Get_Grid("QUALITY" ); m_pSlope = m_Grid_Target.Get_Grid("SLOPE" ); m_pIntercept = m_Grid_Target.Get_Grid("INTERCEPT"); if( !m_pIntercept || !m_pSlope || !m_pQuality ) { m_Search.Finalize(); return( false ); } m_pIntercept->Set_Name(CSG_String::Format(SG_T("%s (%s)"), Parameters("DEPENDENT")->asString(), _TL("GWR Intercept"))); m_pSlope ->Set_Name(CSG_String::Format(SG_T("%s (%s)"), Parameters("DEPENDENT")->asString(), _TL("GWR Slope"))); m_pQuality ->Set_Name(CSG_String::Format(SG_T("%s (%s)"), Parameters("DEPENDENT")->asString(), _TL("GWR Quality"))); //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, m_pIntercept->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { CSG_Regression_Weighted Model; if( Get_Model(x, y, Model) ) { m_pIntercept->Set_Value(x, y, Model[0]); m_pSlope ->Set_Value(x, y, Model[1]); m_pQuality ->Set_Value(x, y, Model.Get_R2()); } else { m_pIntercept->Set_NoData(x, y); m_pSlope ->Set_NoData(x, y); m_pQuality ->Set_NoData(x, y); } } } //----------------------------------------------------- m_Search.Finalize(); DataObject_Update(m_pIntercept); DataObject_Update(m_pSlope); DataObject_Update(m_pQuality); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Regression::Get_Model(int x, int y, CSG_Regression_Weighted &Model) { //----------------------------------------------------- TSG_Point Point = m_pIntercept->Get_System().Get_Grid_to_World(x, y); int nPoints = m_Search.Set_Location(Point); Model.Destroy(); for(int iPoint=0; iPointGet_Shape((int)iz) : m_pPoints->Get_Shape(iPoint); if( !pPoint->is_NoData(m_iDependent) && !pPoint->is_NoData(m_iPredictor) ) { Model.Add_Sample( m_Weighting.Get_Weight(SG_Get_Distance(Point, pPoint->Get_Point(0))), pPoint->asDouble(m_iDependent), CSG_Vector(1, &(iz = pPoint->asDouble(m_iPredictor))) ); } } //----------------------------------------------------- return( Model.Calculate() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/gw_multi_regression_grid.cpp0000664000175000017500000004230212565125413032457 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gw_multi_regression_grid.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gw_multi_regression_grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGW_Multi_Regression_Grid::CGW_Multi_Regression_Grid(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("GWR for Multiple Predictor Grids")); Set_Author ("O.Conrad (c) 2010"); Set_Description (_TW( "References:\n" ) + GWR_References); //----------------------------------------------------- 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 ); //----------------------------------------------------- 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 , "MODEL" , _TL("Regression Parameters"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, false ); Parameters.Add_Value( NULL , "MODEL_OUT" , _TL("Output of Regression Parameters"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- pNode = Parameters.Add_Choice( NULL , "RESOLUTION" , _TL("Model Resolution"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("same as predictors"), _TL("user defined") ), 1 ); Parameters.Add_Value( NULL , "RESOLUTION_VAL" , _TL("Resolution"), _TL("map units"), PARAMETER_TYPE_Double , 1.0, 0.0, true ); //----------------------------------------------------- m_Weighting.Set_Weighting(SG_DISTWGHT_GAUSS); m_Weighting.Create_Parameters(&Parameters, false); //----------------------------------------------------- m_Search.Create(&Parameters, Parameters.Add_Node(NULL, "NODE_SEARCH", _TL("Search Options"), _TL("")), 16); Parameters("SEARCH_RANGE" )->Set_Value(1); Parameters("SEARCH_POINTS_ALL")->Set_Value(1); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGW_Multi_Regression_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "POINTS") && pParameter->asShapes() ) { m_Search.On_Parameter_Changed(pParameters, pParameter); pParameters->Set_Parameter("RESOLUTION_VAL", GWR_Fit_To_Density(pParameter->asShapes(), 4.0, 1)); pParameters->Set_Parameter("DW_BANDWIDTH" , GWR_Fit_To_Density(pParameter->asShapes(), 4.0, 1)); } return( 1 ); } //--------------------------------------------------------- int CGW_Multi_Regression_Grid::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("RESOLUTION")) ) { pParameters->Get_Parameter("RESOLUTION_VAL")->Set_Enabled(pParameter->asInt() == 1); } m_Search.On_Parameters_Enable(pParameters, pParameter); m_Weighting.Enable_Parameters(pParameters); return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression_Grid::On_Execute(void) { int i; //----------------------------------------------------- CSG_Parameter_Grid_List *pPredictors = Parameters("PREDICTORS")->asGridList(); if( !Initialize(Parameters("POINTS")->asShapes(), Parameters("DEPENDENT")->asInt(), pPredictors) ) { Finalize(); return( false ); } //----------------------------------------------------- CSG_Grid Quality; m_dimModel = *Get_System(); if( Parameters("RESOLUTION")->asInt() == 1 && Parameters("RESOLUTION_VAL")->asDouble() > Get_Cellsize() ) { CSG_Rect r(Get_System()->Get_Extent()); r.Inflate(0.5 * Parameters("RESOLUTION_VAL")->asDouble(), false); m_dimModel.Assign(Parameters("RESOLUTION_VAL")->asDouble(), r); Quality.Create(m_dimModel); m_pQuality = &Quality; } else { m_pQuality = Parameters("QUALITY")->asGrid(); } //----------------------------------------------------- Process_Set_Text(_TL("upsetting model domain")); m_pPredictors = (CSG_Grid **)SG_Calloc(m_nPredictors , sizeof(CSG_Grid *)); m_pModel = (CSG_Grid **)SG_Calloc(m_nPredictors + 1, sizeof(CSG_Grid *)); for(i=0; i Get_Cellsize() ) // scaling { m_pPredictors[i] = SG_Create_Grid(m_dimModel); m_pPredictors[i] ->Assign(pPredictors->asGrid(i), GRID_INTERPOLATION_NearestNeighbour); // GRID_INTERPOLATION_Mean_Cells } else { m_pPredictors[i] = pPredictors->asGrid(i); } m_pModel [i] = SG_Create_Grid(m_dimModel); m_pModel [i] ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPredictors->asGrid(i)->Get_Name(), _TL("Factor"))); } m_pModel[m_nPredictors] = SG_Create_Grid(m_dimModel); m_pModel[m_nPredictors] ->Set_Name(_TL("Intercept")); //----------------------------------------------------- Process_Set_Text(_TL("model creation")); bool bResult = Get_Model(); //----------------------------------------------------- if( m_dimModel.Get_Cellsize() > Get_Cellsize() ) // scaling { for(i=0; iasGrid(i); } } //----------------------------------------------------- if( bResult ) { Process_Set_Text(_TL("model application")); bResult = Set_Model(); } //----------------------------------------------------- if( Parameters("MODEL_OUT")->asBool() ) { CSG_Parameter_Grid_List *pModel = Parameters("MODEL")->asGridList(); pModel->Del_Items(); pModel->Add_Item(m_pModel[m_nPredictors]); for(i=0; iAdd_Item(m_pModel[i]); } } else { for(i=0; i<=m_nPredictors; i++) { delete(m_pModel[i]); } } SG_FREE_SAFE(m_pModel); SG_FREE_SAFE(m_pPredictors); Finalize(); return( bResult ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression_Grid::Initialize(CSG_Shapes *pPoints, int iDependent, CSG_Parameter_Grid_List *pPredictors) { //----------------------------------------------------- if( (m_nPredictors = pPredictors->Get_Count()) <= 0 ) { return( false ); } if( !pPoints->Get_Extent().Intersects(Get_System()->Get_Extent()) ) { return( false ); } //----------------------------------------------------- int iPredictor, Interpolation = GRID_INTERPOLATION_BSpline; m_Points.Create (SHAPE_TYPE_Point); m_Points.Set_Name (Parameters("DEPENDENT")->asString()); m_Points.Add_Field(Parameters("DEPENDENT")->asString(), SG_DATATYPE_Double); for(iPredictor=0; iPredictorGet_Count(); iPredictor++) { m_Points.Add_Field(pPredictors->asGrid(iPredictor)->Get_Name(), SG_DATATYPE_Double); } //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); if( !pPoint->is_NoData(iDependent) ) { CSG_Vector z(1 + m_nPredictors); z[0] = pPoint->asDouble(iDependent); TSG_Point Point = pPoint->Get_Point(0); bool bAdd = true; for(iPredictor=0; bAdd && iPredictorasGrid(iPredictor)->Get_Value(Point, z[iPredictor + 1], Interpolation) ) { bAdd = false; } } if( bAdd ) { (pPoint = m_Points.Add_Shape())->Add_Point(Point); for(iPredictor=0; iPredictor<=m_nPredictors; iPredictor++) { pPoint->Set_Value(iPredictor, z[iPredictor]); } } } } //----------------------------------------------------- m_Weighting.Set_Parameters(&Parameters); return( m_Points.Get_Count() > m_nPredictors && m_Search.Initialize(&m_Points, -1) ); } //--------------------------------------------------------- void CGW_Multi_Regression_Grid::Finalize(void) { m_Search.Finalize(); m_Points.Destroy(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression_Grid::Get_Model(void) { //----------------------------------------------------- for(int y=0; ySet_Value(x, y, Model.Get_R2()); m_pModel[m_nPredictors]->Set_Value(x, y, Model[0]); for(int i=0; iSet_Value(x, y, Model[i + 1]); } } else { m_pQuality->Set_NoData(x, y); for(int i=0; i<=m_nPredictors; i++) { m_pModel[i]->Set_NoData(x, y); } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGW_Multi_Regression_Grid::Get_Model(int x, int y, CSG_Regression_Weighted &Model) { //----------------------------------------------------- TSG_Point Point = m_dimModel.Get_Grid_to_World(x, y); int nPoints = m_Search.Set_Location(Point); CSG_Vector Predictors(m_nPredictors); Model.Destroy(); for(int iPoint=0; iPointasDouble(1 + iPredictor); } Model.Add_Sample( m_Weighting.Get_Weight(SG_Get_Distance(Point, pPoint->Get_Point(0))), pPoint->asDouble(0), Predictors ); } //----------------------------------------------------- return( Model.Calculate() ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression_Grid::Set_Model(void) { CSG_Grid *pRegression = Parameters("REGRESSION")->asGrid(); CSG_Grid *pQuality = Parameters("QUALITY" )->asGrid(); pRegression->Set_Name(CSG_String::Format(SG_T("%s [%s]" ), m_Points.Get_Name(), _TL("GWR"))); pQuality ->Set_Name(CSG_String::Format(SG_T("%s [%s, %s]"), m_Points.Get_Name(), _TL("GWR"), _TL("Quality"))); if( m_pQuality == Parameters("QUALITY")->asGrid() ) { pQuality = NULL; } //----------------------------------------------------- for(int y=0; yGet_Value(p_x, p_y)); } else { SG_GRID_PTR_SAFE_SET_NODATA(pRegression, x, y); SG_GRID_PTR_SAFE_SET_NODATA(pQuality , x, y); } } } //----------------------------------------------------- Set_Residuals(); return( true ); } //--------------------------------------------------------- bool CGW_Multi_Regression_Grid::Set_Model(double x, double y, double &Value) { if( !m_pModel[m_nPredictors]->Get_Value(x, y, Value, GRID_INTERPOLATION_BSpline) ) { return( false ); } double Model, Predictor; for(int i=0; iGet_Value(x, y, Model , GRID_INTERPOLATION_BSpline) || !m_pPredictors[i]->Get_Value(x, y, Predictor, GRID_INTERPOLATION_NearestNeighbour) ) { return( false ); } Value += Model * Predictor; } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression_Grid::Set_Residuals(void) { CSG_Shapes *pResiduals = Parameters("RESIDUALS")->asShapes(); if( !pResiduals ) { 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; iShapeasDouble(0); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { double zRegression; TSG_Point Point = pShape->Get_Point(iPoint, iPart); if( Set_Model(Point.x, Point.y, 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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/grids_trend_polynom.cpp0000664000175000017500000002321312565125413031444 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grids_trend_polynom.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // grids_trend_polynom.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grids_trend_polynom.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrids_Trend::CGrids_Trend(void) { //----------------------------------------------------- Set_Name (_TL("Polynomial Trend from Grids")); Set_Author (SG_T("O. Conrad (c) 2011")); Set_Description (_TW( "Fits for each cell a polynomial trend function. " "Outputs are the polynomial coefficients for the " "polynomial trend function of chosen order. " )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "Y_GRIDS" , _TL("Dependent Variables"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "COEFF" , _TL("Polynomial Coefficients"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "R2" , _TL("Coefficient of Determination"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "ORDER" , _TL("Polynomial Order"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Choice( NULL , "XSOURCE" , _TL("Get Independent Variable from ..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("list order"), _TL("table"), _TL("grid list") ), 0 ); Parameters.Add_FixedTable( NULL , "X_TABLE" , _TL("Independent Variable (per Grid)"), _TL("") )->asTable()->Add_Field(_TL("Value"), SG_DATATYPE_Double); Parameters.Add_Grid_List( NULL , "X_GRIDS" , _TL("Independent Variable (per Grid and Cell)"), _TL(""), PARAMETER_INPUT_OPTIONAL ); //----------------------------------------------------- CSG_Table *pTable = Parameters("X_TABLE")->asTable(); pTable->Add_Record()->Set_Value(0, 1000.0); pTable->Add_Record()->Set_Value(0, 925.0); pTable->Add_Record()->Set_Value(0, 850.0); pTable->Add_Record()->Set_Value(0, 700.0); pTable->Add_Record()->Set_Value(0, 600.0); pTable->Add_Record()->Set_Value(0, 500.0); pTable->Add_Record()->Set_Value(0, 400.0); pTable->Add_Record()->Set_Value(0, 300.0); pTable->Add_Record()->Set_Value(0, 250.0); pTable->Add_Record()->Set_Value(0, 200.0); pTable->Add_Record()->Set_Value(0, 150.0); pTable->Add_Record()->Set_Value(0, 100.0); pTable->Add_Record()->Set_Value(0, 70.0); pTable->Add_Record()->Set_Value(0, 50.0); pTable->Add_Record()->Set_Value(0, 30.0); pTable->Add_Record()->Set_Value(0, 20.0); pTable->Add_Record()->Set_Value(0, 10.0); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrids_Trend::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("XSOURCE")) ) { pParameters->Get_Parameter("X_TABLE")->Set_Enabled(pParameter->asInt() == 1); // table pParameters->Get_Parameter("X_GRIDS")->Set_Enabled(pParameter->asInt() == 2); // grid list } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrids_Trend::On_Execute(void) { int Order, xSource, nGrids; CSG_Table *pXTable; CSG_Grid *pR2; CSG_Parameter_Grid_List *pYGrids, *pCoeff, *pXGrids; //----------------------------------------------------- pYGrids = Parameters("Y_GRIDS")->asGridList(); pCoeff = Parameters("COEFF" )->asGridList(); pR2 = Parameters("R2" )->asGrid(); pXGrids = Parameters("X_GRIDS")->asGridList(); pXTable = Parameters("X_TABLE")->asTable(); Order = Parameters("ORDER" )->asInt(); xSource = Parameters("XSOURCE")->asInt(); //----------------------------------------------------- nGrids = pYGrids->Get_Count(); if( nGrids <= Order ) { Error_Set(_TL("fitting a polynom of ith order needs at least i + 1 samples")); return( false ); } //----------------------------------------------------- switch( xSource ) { case 0: nGrids = pYGrids->Get_Count(); break; // list order case 1: nGrids = pXTable->Get_Count(); break; // table case 2: nGrids = pXGrids->Get_Count(); break; // grid list } if( nGrids < pXGrids->Get_Count() ) { Error_Set(_TL("There are less predictor variables then dependent ones.")); return( false ); } if( nGrids > pXGrids->Get_Count() ) { Message_Add(_TL("Warning: there are more predictor variables then dependent ones, surplus will be ignored.")); nGrids = pYGrids->Get_Count(); } //----------------------------------------------------- pCoeff->Del_Items(); for(int i=0; i<=Order; i++) { pCoeff->Add_Item(SG_Create_Grid(*Get_System())); pCoeff->asGrid(i)->Set_Name(CSG_String::Format(SG_T("%s [%d]"), _TL("Polynomial Coefficient"), i + 1)); } if( pR2 ) { pR2->Set_Name(CSG_String::Format(SG_T("%s"), _TL("Determination Coefficients"))); } //----------------------------------------------------- for(int y=0; yasGrid(i)->is_NoData(x, y) ) { switch( xSource ) { case 0: // list order Trend.Add_Data(i, pYGrids->asGrid(i)->asDouble(x, y)); break; case 1: // table Trend.Add_Data(pXTable->Get_Record(i)->asDouble(0), pYGrids->asGrid(i)->asDouble(x, y)); break; case 2: // grid list if( !pXGrids->asGrid(i)->is_NoData(x, y) ) { Trend.Add_Data(pXGrids->asGrid(i)->asDouble(x, y), pYGrids->asGrid(i)->asDouble(x, y)); } break; } } } if( Trend.Get_Trend() ) { for(int iOrder=0; iOrderasGrid(iOrder)->Set_Value(x, y, Trend.Get_Coefficient(iOrder)); } if( pR2 ) pR2->Set_Value(x, y, Trend.Get_R2()); } else { for(int iOrder=0; iOrderasGrid(iOrder)->Set_NoData(x, y); } if( pR2 ) pR2->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/table_trend.cpp0000664000175000017500000002127112565125413027650 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Table_Trend.cpp 1098 2011-06-16 16:06:32Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // table_trend.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_trend.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTable_Trend_Base::Initialise(void) { //----------------------------------------------------- Set_Author (SG_T("O.Conrad (c) 2006")); Set_Description (_TW( "" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters("TABLE"); Parameters.Add_Table_Field( pNode , "FIELD_X" , _TL("X Values"), _TL("") ); Parameters.Add_Table_Field( pNode , "FIELD_Y" , _TL("Y Values"), _TL("") ); Parameters.Add_String( NULL , "FORMULA" , _TL("Formula"), _TL(""), SG_T("m * x + b") ); Parameters.Add_Choice( NULL , "FORMULAS" , _TL("Pre-defined Formulas"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("Linear: a + b * x"), _TL("Quadric: a + b * x + c * x^2"), _TL("Cubic: a + b * x + c * x^2 + d * x^3"), _TL("Logarithmic: a + b * ln(x)"), _TL("Power: a + b * x^c"), _TL("a + b / x"), _TL("a + b * (1 - exp(-x / c))"), _TL("a + b * (1 - exp(-(x / c)^2))") ), 0 ); Parameters.Add_Table( NULL , "TREND" , _TL("Table (with Trend)"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } //--------------------------------------------------------- int CTable_Trend_Base::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FORMULAS")) ) { const SG_Char *Formula; switch( pParameter->asInt() ) { default: return( false ); case 0: Formula = SG_T("a + b * x"); break; case 1: Formula = SG_T("a + b * x + c * x^2"); break; case 2: Formula = SG_T("a + b * x + c * x^2 + d * x^3"); break; case 3: Formula = SG_T("a + b * ln(x)"); break; case 4: Formula = SG_T("a + b * x^c"); break; case 5: Formula = SG_T("a + b / x"); break; case 6: Formula = SG_T("a + b * (1 - exp(-x / c))"); break; case 7: Formula = SG_T("a + b * (1 - exp(-(x / c)^2))"); break; } pParameters->Get_Parameter("FORMULA")->Set_Value(Formula); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FORMULA")) ) { if( !m_Trend.Set_Formula(pParameter->asString()) ) { Message_Dlg(m_Trend.Get_Error(), _TL("Error in Formula")); return( false ); } } return( true ); } //--------------------------------------------------------- bool CTable_Trend_Base::On_Execute(void) { int i, j, xField, yField; CSG_String Name; CSG_Table_Record *pRecord; CSG_Table *pTable; pTable = Parameters("TABLE") ->asTable(); xField = Parameters("FIELD_X") ->asInt(); yField = Parameters("FIELD_Y") ->asInt(); //----------------------------------------------------- if( m_Trend.Set_Formula(Parameters("FORMULA")->asString()) ) { m_Trend.Clr_Data(); for(i=0; iGet_Record_Count(); i++) { pRecord = pTable->Get_Record(i); m_Trend.Add_Data(pRecord->asDouble(xField), pRecord->asDouble(yField)); } //------------------------------------------------- if( m_Trend.Get_Trend() ) { Message_Add(SG_T("\n"), false); Message_Add(m_Trend.Get_Formula(), false); Message_Add(SG_T("\n"), false); Message_Add(CSG_String::Format(SG_T("R2 : %f"), 100.0 * m_Trend.Get_R2()), false); if( Parameters("TREND")->asTable() == NULL ) { pTable->Add_Field("TREND" , SG_DATATYPE_Double); for(i=0, j=pTable->Get_Field_Count()-1; iGet_Record(i); pRecord->Set_Value(j, m_Trend.Get_Value(m_Trend.Get_Data_X(i))); } } else { Name.Printf(SG_T("%s [%s]"), pTable->Get_Name(), _TL("Trend")); pTable = Parameters("TREND")->asTable(); pTable->Destroy(); pTable->Set_Name(Name); pTable->Add_Field("X" , SG_DATATYPE_Double); pTable->Add_Field("Y" , SG_DATATYPE_Double); pTable->Add_Field("Y_TREND" , SG_DATATYPE_Double); for(i=0; iAdd_Record(); pRecord->Set_Value(0, m_Trend.Get_Data_X(i)); pRecord->Set_Value(1, m_Trend.Get_Data_Y(i)); pRecord->Set_Value(2, m_Trend.Get_Value(m_Trend.Get_Data_X(i))); } } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Trend::CTable_Trend(void) : CTable_Trend_Base() { Set_Name (_TL("Trend Analysis")); Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Initialise(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Trend_Shapes::CTable_Trend_Shapes(void) : CTable_Trend_Base() { Set_Name (_TL("Trend Analysis (Shapes)")); Parameters.Add_Shapes( NULL , "TABLE" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Initialise(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/grid_multi_grid_regression.h0000664000175000017500000001116012565125413032432 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_multi_grid_regression.h 1160 2011-09-14 15:11:54Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // grid_multi_grid_regression.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_multi_grid_regression_H #define HEADER_INCLUDED__grid_multi_grid_regression_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Multi_Grid_Regression : public CSG_Module_Grid { public: CGrid_Multi_Grid_Regression(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Regression_Multiple m_Regression; bool Get_Samples (CSG_Parameter_Grid_List *pGrids, CSG_Grid *pDependent, CSG_Matrix &Samples, CSG_Strings &Names); bool Set_Regression (CSG_Parameter_Grid_List *pGrids, CSG_Grid *pDependent, CSG_Grid *pRegression, CSG_Grid *pResiduals, const CSG_String &Name); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_multi_grid_regression_H saga-2.2.3/src/modules/statistics/statistics_regression/table_regression_multiple.h0000664000175000017500000001142312565125413032272 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_regression_multiple.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // table_regression_multiple.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__table_regression_multiple_H #define HEADER_INCLUDED__table_regression_multiple_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Regression_Multiple_Base : public CSG_Module { protected: void Initialise (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; //--------------------------------------------------------- class CTable_Regression_Multiple : public CTable_Regression_Multiple_Base { public: CTable_Regression_Multiple(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Table") ); } }; //--------------------------------------------------------- class CTable_Regression_Multiple_Shapes : public CTable_Regression_Multiple_Base { public: CTable_Regression_Multiple_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Shapes") ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__table_regression_multiple_H saga-2.2.3/src/modules/statistics/statistics_regression/gw_multi_regression_points.h0000664000175000017500000001127412565125413032517 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gw_multi_regression_points.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // gw_multi_regression_points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gw_multi_regression_points_H #define HEADER_INCLUDED__gw_multi_regression_points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGW_Multi_Regression_Points : public CSG_Module { public: CGW_Multi_Regression_Points(void); virtual CSG_String Get_MenuPath (void) { return(_TL("A:Spatial and Geostatistics|Geographically Weighted Regression")); } protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: int m_nPredictors; CSG_Distance_Weighting m_Weighting; CSG_Parameters_Search_Points m_Search; CSG_Shapes *m_pPoints; bool Initialize (void); void Finalize (void); bool Get_Model (const TSG_Point &Point, CSG_Regression_Weighted &Model); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gw_multi_regression_points_H saga-2.2.3/src/modules/statistics/statistics_regression/point_multi_grid_regression.h0000664000175000017500000001136612565125413032646 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: point_multi_grid_regression.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: CSG_Regression_Multiple m_Regression; bool Get_Samples (CSG_Parameter_Grid_List *pGrids, CSG_Shapes *pShapes, int iAttribute, CSG_Matrix &Samples, CSG_Strings &Names); bool Set_Regression (CSG_Parameter_Grid_List *pGrids, CSG_Grid *pRegression, const CSG_String &Name); bool Set_Residuals (CSG_Shapes *pResiduals); bool Set_Residual_Corr (CSG_Grid *pRegression, CSG_Shapes *pResiduals, CSG_Grid *pCorrection); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__point_multi_grid_regression_H saga-2.2.3/src/modules/statistics/statistics_regression/point_zonal_multi_grid_regression.cpp0000664000175000017500000003055712565125413034407 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: point_zonal_multi_grid_regression.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // point_zonal_multi_grid_regression.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "point_zonal_multi_grid_regression.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoint_Zonal_Multi_Grid_Regression::CPoint_Zonal_Multi_Grid_Regression(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Zonal Multiple Regression Analysis (Points and Predictor Grids)")); Set_Author ("O.Conrad, P.Gandelli (c) 2015"); Set_Description (_TW( "Linear regression analysis of point attributes using multiple predictor 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. " "Each polygon in the zones layer is processed as individual zone. " "\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 , "PREDICTORS" , _TL("Predictors"), _TL(""), PARAMETER_INPUT, true ); Parameters.Add_Shapes( NULL , "ZONES" , _TL("Zones"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ATTRIBUTE" , _TL("Dependent Variable"), _TL("") ); Parameters.Add_Shapes( NULL , "RESIDUALS" , _TL("Residuals"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Grid( NULL , "REGRESSION" , _TL("Regression"), _TL(""), PARAMETER_OUTPUT ); 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_Value( NULL , "COORD_X" , _TL("Include X Coordinate"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "COORD_Y" , _TL("Include Y Coordinate"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "INTERCEPT" , _TL("Intercept"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( NULL ,"METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("include all"), _TL("forward"), _TL("backward"), _TL("stepwise") ), 3 ); Parameters.Add_Value( NULL , "P_VALUE" , _TL("Significance Level"), _TL("Significance level (aka p-value) as threshold for automated predictor selection, given as percentage"), PARAMETER_TYPE_Double, 5.0, 0.0, true, 100.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPoint_Zonal_Multi_Grid_Regression::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("P_VALUE", pParameter->asInt() > 0); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoint_Zonal_Multi_Grid_Regression::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS" )->asShapes(); CSG_Shapes *pZones = Parameters("ZONES" )->asShapes(); CSG_Grid *pRegression = Parameters("REGRESSION")->asGrid (); pRegression->Assign_NoData(); CSG_Grid Regression(*Get_System(), SG_DATATYPE_Float); SG_UI_Progress_Lock(true); // suppress dialogs from popping up for(int i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Shape_Polygon *pZone = (CSG_Shape_Polygon *)pZones->Get_Shape(i); //------------------------------------------------- // select all points located in current zone polygon bool bResult; CSG_Shapes Zone(SHAPE_TYPE_Polygon); Zone.Add_Shape(pZone); SG_RUN_MODULE(bResult, "shapes_tools", 5, // select points by location SG_MODULE_PARAMETER_SET("LOCATIONS", &Zone) && SG_MODULE_PARAMETER_SET("SHAPES" , pPoints) ); if( !bResult ) { SG_UI_Process_Set_Okay(); // don't stop overall work flow, if tool execution failed for current zone } else if( pPoints->Get_Selection_Count() > 0 ) { //--------------------------------------------- // copy selected points to a new (temporary) points layer CSG_Shapes Selection; SG_RUN_MODULE(bResult, "shapes_tools", 6, // copy selected points to a new layer SG_MODULE_PARAMETER_SET("INPUT" , pPoints) && SG_MODULE_PARAMETER_SET("OUTPUT", &Selection) ); pPoints->asShapes()->Select(); // unselect everything from original points layer //--------------------------------------------- // perform the regression analysis, regression grid for zone is temporary SG_RUN_MODULE(bResult, "statistics_regression", 1, // multiple linear regression for points and predictor grids SG_MODULE_PARAMETER_SET("PREDICTORS", Parameters("PREDICTORS")) && SG_MODULE_PARAMETER_SET("REGRESSION", &Regression ) && SG_MODULE_PARAMETER_SET("POINTS" , &Selection ) && SG_MODULE_PARAMETER_SET("ATTRIBUTE" , Parameters("ATTRIBUTE" )) && SG_MODULE_PARAMETER_SET("INTERPOL" , Parameters("INTERPOL" )) && SG_MODULE_PARAMETER_SET("COORD_X" , Parameters("COORD_X" )) && SG_MODULE_PARAMETER_SET("COORD_Y" , Parameters("COORD_Y" )) && SG_MODULE_PARAMETER_SET("INTERCEPT" , Parameters("INTERCEPT" )) && SG_MODULE_PARAMETER_SET("METHOD" , Parameters("METHOD" )) && SG_MODULE_PARAMETER_SET("P_VALUE" , Parameters("P_VALUE" )) ); //--------------------------------------------- // use zone polygon as mask for copying zonal regression result to final regression grid if( !bResult ) { SG_UI_Process_Set_Okay(); // don't stop overall work flow, if tool execution failed for current zone } else { #pragma omp parallel for // speed up using multiple processors for(int y=0; yContains(Get_System()->Get_Grid_to_World(x, y)) ) { pRegression->Set_Value(x, y, Regression.asDouble(x, y)); } } } } } } //----------------------------------------------------- SG_UI_Progress_Lock(false); //----------------------------------------------------- Set_Residuals(pPoints, pRegression); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoint_Zonal_Multi_Grid_Regression::Set_Residuals(CSG_Shapes *pPoints, CSG_Grid *pRegression) { CSG_Shapes *pResiduals = Parameters("RESIDUALS")->asShapes(); int iAttribute = Parameters("ATTRIBUTE")->asInt (); if( !pRegression || !pResiduals ) { return( false ); } //----------------------------------------------------- pResiduals->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), Parameters("ATTRIBUTE")->asString(), _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); int Interpolation = Parameters("INTERPOL")->asInt(); //----------------------------------------------------- for(int iShape=0; iShapeGet_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; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { double zGrid; TSG_Point Point = pShape->Get_Point(iPoint, iPart); if( pRegression->Get_Value(Point, zGrid, Interpolation) ) { CSG_Shape *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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/table_trend.h0000664000175000017500000001126512565125413027317 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Table_Trend.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // table_trend.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Table_Trend_H #define HEADER_INCLUDED__Table_Trend_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Trend_Base : public CSG_Module { protected: void Initialise (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Trend m_Trend; }; //--------------------------------------------------------- class CTable_Trend : public CTable_Trend_Base { public: CTable_Trend(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Table") ); } }; //--------------------------------------------------------- class CTable_Trend_Shapes : public CTable_Trend_Base { public: CTable_Trend_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Shapes") ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Table_Trend_H saga-2.2.3/src/modules/statistics/statistics_regression/gw_regression_grid.h0000664000175000017500000001127612565125413030720 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gw_regression_grid.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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); virtual CSG_String Get_MenuPath (void) { return(_TL("A:Spatial and Geostatistics|Geographically Weighted Regression")); } protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: int m_iDependent; CSG_Distance_Weighting m_Weighting; CSG_Parameters_Search_Points m_Search; CSG_Shapes *m_pPoints; CSG_Grid *m_pPredictor, *m_pRegression, *m_pQuality, *m_pIntercept, *m_pSlope; bool Get_Model (int x, int y, CSG_Regression_Weighted &Model); bool Set_Residuals (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gw_regression_grid_H saga-2.2.3/src/modules/statistics/statistics_regression/grid_multi_grid_regression.cpp0000664000175000017500000003640612565125413032777 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_multi_grid_regression.cpp 1160 2011-09-14 15:11:54Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // grid_multi_grid_regression.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_multi_grid_regression.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Multi_Grid_Regression::CGrid_Multi_Grid_Regression(void) { //----------------------------------------------------- Set_Name (_TL("Multiple Regression Analysis (Grid and Predictor Grids)")); Set_Author ("O.Conrad (c) 2011"); Set_Description (_TW( "Linear regression analysis of one grid as dependent and multiple grids as indepentent (predictor) variables. " "Details of the regression/correlation analysis will be saved to a table. " "Optionally the regression model 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( NULL , "DEPENDENT" , _TL("Dependent Variable"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "PREDICTORS" , _TL("Predictors"), _TL(""), PARAMETER_INPUT, false ); Parameters.Add_Grid( NULL , "REGRESSION" , _TL("Regression"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "RESIDUALS" , _TL("Residuals"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Table( NULL , "INFO_COEFF" , _TL("Details: Coefficients"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Table( NULL , "INFO_MODEL" , _TL("Details: Model"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Table( NULL , "INFO_STEPS" , _TL("Details: Steps"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); 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_Value( NULL , "COORD_X" , _TL("Include X Coordinate"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "COORD_Y" , _TL("Include Y Coordinate"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL ,"METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("include all"), _TL("forward"), _TL("backward"), _TL("stepwise") ), 3 ); Parameters.Add_Value( NULL , "P_VALUE" , _TL("Significance Level"), _TL("Significance level (aka p-value) as threshold for automated predictor selection, given as percentage"), PARAMETER_TYPE_Double, 5.0, 0.0, true, 100.0, true ); Parameters.Add_Choice( NULL ,"CROSSVAL" , _TL("Cross Validation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("none"), _TL("leave one out"), _TL("2-fold"), _TL("k-fold") ), 0 ); Parameters.Add_Value( NULL , "CROSSVAL_K" , _TL("Cross Validation Subsamples"), _TL("number of subsamples for k-fold cross validation"), PARAMETER_TYPE_Int, 10, 2, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_Multi_Grid_Regression::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "CROSSVAL") ) { pParameters->Set_Enabled("CROSSVAL_K", pParameter->asInt() == 3); // k-fold } if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("P_VALUE", pParameter->asInt() > 0); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Multi_Grid_Regression::On_Execute(void) { bool bResult; double P; CSG_Strings Names; CSG_Matrix Samples; CSG_Grid *pDependent, *pRegression, *pResiduals; CSG_Parameter_Grid_List *pGrids; //----------------------------------------------------- pDependent = Parameters("DEPENDENT" )->asGrid(); pGrids = Parameters("PREDICTORS")->asGridList(); pRegression = Parameters("REGRESSION")->asGrid(); pResiduals = Parameters("RESIDUALS" )->asGrid(); P = Parameters("P_VALUE" )->asDouble() / 100.0; //----------------------------------------------------- if( !Get_Samples(pGrids, pDependent, Samples, Names) ) { return( false ); } //----------------------------------------------------- switch( Parameters("METHOD")->asInt() ) { default: case 0: bResult = m_Regression.Get_Model (Samples , &Names); break; case 1: bResult = m_Regression.Get_Model_Forward (Samples, P , &Names); break; case 2: bResult = m_Regression.Get_Model_Backward(Samples, P, &Names); break; case 3: bResult = m_Regression.Get_Model_Stepwise(Samples, P, P, &Names); break; } if( bResult == false ) { return( false ); } Message_Add(m_Regression.Get_Info(), false); //----------------------------------------------------- int CrossVal; switch( Parameters("CROSSVAL")->asInt() ) { default: CrossVal = 0; break; // none case 1: CrossVal = 1; break; // leave one out (LOOVC) case 2: CrossVal = 2; break; // 2-fold case 3: CrossVal = Parameters("CROSSVAL_K")->asInt(); break; // k-fold } if( CrossVal > 0 && m_Regression.Get_CrossValidation(CrossVal) ) { Message_Add(CSG_String::Format(SG_T("\n%s:\n" ), _TL("Cross Validation")), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%s\n" ), _TL("Type" ), Parameters("CROSSVAL")->asString() ), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%d\n" ), _TL("Samples"), m_Regression.Get_CV_nSamples() ), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%f\n" ), _TL("RMSE" ), m_Regression.Get_CV_RMSE() ), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%.2f\n"), _TL("NRMSE" ), m_Regression.Get_CV_NRMSE() * 100.0), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%.2f\n"), _TL("R2" ), m_Regression.Get_CV_R2() * 100.0), false); } //----------------------------------------------------- Set_Regression(pGrids, pDependent, pRegression, pResiduals, CSG_String::Format(SG_T("%s [%s]"), pDependent->Get_Name(), _TL("Regression Model"))); //----------------------------------------------------- if( Parameters("INFO_COEFF")->asTable() ) { Parameters("INFO_COEFF")->asTable()->Assign(m_Regression.Get_Info_Regression()); Parameters("INFO_COEFF")->asTable()->Set_Name(_TL("MLRA Coefficients")); } if( Parameters("INFO_MODEL")->asTable() ) { Parameters("INFO_MODEL")->asTable()->Assign(m_Regression.Get_Info_Model()); Parameters("INFO_MODEL")->asTable()->Set_Name(_TL("MLRA Model")); } if( Parameters("INFO_STEPS")->asTable() ) { Parameters("INFO_STEPS")->asTable()->Assign(m_Regression.Get_Info_Steps()); Parameters("INFO_STEPS")->asTable()->Set_Name(_TL("MLRA Steps")); } //----------------------------------------------------- m_Regression.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Multi_Grid_Regression::Get_Samples(CSG_Parameter_Grid_List *pGrids, CSG_Grid *pDependent, CSG_Matrix &Samples, CSG_Strings &Names) { int iGrid, x, y; double zGrid; TSG_Point p; CSG_Vector Sample; //----------------------------------------------------- int Interpolation = Parameters("INTERPOL") ->asInt(); bool bCoord_X = Parameters("COORD_X") ->asBool(); bool bCoord_Y = Parameters("COORD_Y") ->asBool(); Names += pDependent->Get_Name(); // Dependent Variable for(iGrid=0; iGridGet_Count(); iGrid++) // Independent Variables { Names += pGrids->asGrid(iGrid)->Get_Name(); } if( bCoord_X ) { Names += SG_T("X"); } if( bCoord_Y ) { Names += SG_T("Y"); } Sample.Create(1 + pGrids->Get_Count() + (bCoord_X ? 1 : 0) + (bCoord_Y ? 1 : 0)); //----------------------------------------------------- for(y=0, p.y=Get_YMin(); yis_NoData(x, y) ) { bool bAdd = true; for(iGrid=0; iGridGet_Count() && bAdd; iGrid++) { if( pGrids->asGrid(iGrid)->Get_Value(p, zGrid, Interpolation) ) { Sample[1 + iGrid] = zGrid; } else { bAdd = false; } } if( bAdd ) { Sample[0] = pDependent->asDouble(x, y); if( bCoord_X ) { Sample[1 + iGrid++] = p.x; } if( bCoord_Y ) { Sample[1 + iGrid++] = p.y; } Samples.Add_Row(Sample); } } } } //----------------------------------------------------- return( Samples.Get_NRows() >= pGrids->Get_Count() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Multi_Grid_Regression::Set_Regression(CSG_Parameter_Grid_List *pGrids, CSG_Grid *pDependent, CSG_Grid *pRegression, CSG_Grid *pResiduals, const CSG_String &Name) { //----------------------------------------------------- int iGrid, nGrids, x, y; TSG_Point p; int Interpolation = Parameters("INTERPOL")->asInt(); CSG_Grid **ppGrids = (CSG_Grid **)SG_Malloc(m_Regression.Get_nPredictors() * sizeof(CSG_Grid *)); bool bCoord_X = false; bool bCoord_Y = false; for(iGrid=0, nGrids=0; iGridGet_Count() ) { ppGrids[nGrids++] = pGrids->asGrid(m_Regression.Get_Predictor(iGrid)); } else if( m_Regression.Get_Predictor(iGrid) == pGrids->Get_Count() && Parameters("COORD_X")->asBool() ) { bCoord_X = true; } else // if( m_Regression.Get_Predictor(iGrid) > pGrids->Get_Count() || Parameters("COORD_X")->asBool() == false ) { bCoord_Y = true; } } pRegression->Set_Name(Name); if( pDependent && pResiduals ) { pResiduals->Set_Name(CSG_String::Format(SG_T("%s [%s]"), Name.c_str(), _TL("Residuals"))); } else { pResiduals = NULL; } //----------------------------------------------------- for(y=0, p.y=Get_YMin(); yGet_Value(p, zGrid, Interpolation) ) { z += m_Regression.Get_RCoeff(iGrid) * zGrid; } else { bOkay = false; } } //--------------------------------------------- if( bOkay ) { if( bCoord_X ) { z += m_Regression.Get_RCoeff(iGrid++) * Get_System()->Get_xGrid_to_World(x); } if( bCoord_Y ) { z += m_Regression.Get_RCoeff(iGrid++) * Get_System()->Get_yGrid_to_World(y); } pRegression->Set_Value (x, y, z); if( pResiduals ) { pResiduals->Set_Value(x, y, pDependent->asDouble(x, y) - z); } } else { pRegression->Set_NoData(x, y); if( pResiduals ) { pResiduals->Set_NoData(x, y); } } } } //----------------------------------------------------- SG_Free(ppGrids); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/Makefile.in0000664000175000017500000006076612622651174026744 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/statistics/statistics_regression DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libstatistics_regression_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libstatistics_regression_la_OBJECTS = \ grid_multi_grid_regression.lo gw_multi_regression.lo \ gw_multi_regression_grid.lo gw_multi_regression_points.lo \ gw_regression.lo gw_regression_grid.lo gwr_grid_downscaling.lo \ grids_trend_polynom.lo MLB_Interface.lo \ point_grid_regression.lo point_multi_grid_regression.lo \ point_trend_surface.lo point_zonal_multi_grid_regression.lo \ table_regression_multiple.lo table_trend.lo libstatistics_regression_la_OBJECTS = \ $(am_libstatistics_regression_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libstatistics_regression_la_SOURCES) DIST_SOURCES = $(libstatistics_regression_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1738 2013-06-20 11:15:45Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libstatistics_regression.la libstatistics_regression_la_SOURCES = \ grid_multi_grid_regression.cpp\ gw_multi_regression.cpp\ gw_multi_regression_grid.cpp\ gw_multi_regression_points.cpp\ gw_regression.cpp\ gw_regression_grid.cpp\ gwr_grid_downscaling.cpp\ grids_trend_polynom.cpp\ MLB_Interface.cpp\ point_grid_regression.cpp\ point_multi_grid_regression.cpp\ point_trend_surface.cpp\ point_zonal_multi_grid_regression.cpp\ table_regression_multiple.cpp\ table_trend.cpp\ grid_multi_grid_regression.h\ gw_multi_regression.h\ gw_multi_regression_grid.h\ gw_multi_regression_points.h\ gw_regression.h\ gw_regression_grid.h\ gwr_grid_downscaling.h\ grids_trend_polynom.h\ MLB_Interface.h\ point_grid_regression.h\ point_multi_grid_regression.h\ point_trend_surface.h\ point_zonal_multi_grid_regression.h\ table_regression_multiple.h\ table_trend.h libstatistics_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) --foreign src/modules/statistics/statistics_regression/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/statistics/statistics_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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libstatistics_regression.la: $(libstatistics_regression_la_OBJECTS) $(libstatistics_regression_la_DEPENDENCIES) $(EXTRA_libstatistics_regression_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libstatistics_regression_la_OBJECTS) $(libstatistics_regression_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_multi_grid_regression.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grids_trend_polynom.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gw_multi_regression.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gw_multi_regression_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gw_multi_regression_points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gw_regression.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gw_regression_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gwr_grid_downscaling.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/point_grid_regression.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/point_multi_grid_regression.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/point_trend_surface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/point_zonal_multi_grid_regression.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_regression_multiple.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table_trend.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/statistics/statistics_regression/point_multi_grid_regression.cpp0000664000175000017500000005246212571551577033216 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: point_multi_grid_regression.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "point_multi_grid_regression.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoint_Multi_Grid_Regression::CPoint_Multi_Grid_Regression(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Multiple Regression Analysis (Points and Predictor Grids)")); Set_Author ("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 , "PREDICTORS" , _TL("Predictors"), _TL(""), PARAMETER_INPUT, true ); pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ATTRIBUTE" , _TL("Dependent Variable"), _TL("") ); Parameters.Add_Table( NULL , "INFO_COEFF" , _TL("Details: Coefficients"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Table( NULL , "INFO_MODEL" , _TL("Details: Model"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Table( NULL , "INFO_STEPS" , _TL("Details: Steps"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Shapes( NULL , "RESIDUALS" , _TL("Residuals"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Grid( NULL , "REGRESSION" , _TL("Regression"), _TL("regression model applied to predictor grids"), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "REGRESCORR" , _TL("Regression with Residual Correction"), _TL("regression model applied to predictor grids with interpolated residuals added"), PARAMETER_OUTPUT_OPTIONAL ); 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_Value( NULL , "COORD_X" , _TL("Include X Coordinate"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "COORD_Y" , _TL("Include Y Coordinate"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "INTERCEPT" , _TL("Intercept"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( NULL ,"METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("include all"), _TL("forward"), _TL("backward"), _TL("stepwise") ), 3 ); Parameters.Add_Value( NULL , "P_VALUE" , _TL("Significance Level"), _TL("Significance level (aka p-value) as threshold for automated predictor selection, given as percentage"), PARAMETER_TYPE_Double, 5.0, 0.0, true, 100.0, true ); Parameters.Add_Choice( NULL ,"CROSSVAL" , _TL("Cross Validation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("none"), _TL("leave one out"), _TL("2-fold"), _TL("k-fold") ), 0 ); Parameters.Add_Value( NULL , "CROSSVAL_K" , _TL("Cross Validation Subsamples"), _TL("number of subsamples for k-fold cross validation"), PARAMETER_TYPE_Int, 10, 2, true ); Parameters.Add_Choice( NULL ,"RESIDUAL_COR" , _TL("Residual Interpolation"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Multleve B-Spline Interpolation"), _TL("Inverse Distance Weighted") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPoint_Multi_Grid_Regression::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "CROSSVAL") ) { pParameters->Set_Enabled("CROSSVAL_K", pParameter->asInt() == 3); // k-fold } if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("P_VALUE", pParameter->asInt() > 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "REGRESCORR") ) { pParameters->Set_Enabled("RESIDUAL_COR", pParameter->asGrid() != NULL); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoint_Multi_Grid_Regression::On_Execute(void) { bool bResult; int iAttribute; double P; CSG_Strings Names; CSG_Matrix Samples; CSG_Shapes *pPoints; CSG_Grid *pRegression; CSG_Parameter_Grid_List *pGrids; //----------------------------------------------------- pGrids = Parameters("PREDICTORS")->asGridList(); pRegression = Parameters("REGRESSION")->asGrid(); pPoints = Parameters("POINTS" )->asShapes(); iAttribute = Parameters("ATTRIBUTE" )->asInt(); P = Parameters("P_VALUE" )->asDouble() / 100.0; //----------------------------------------------------- if( !Get_Samples(pGrids, pPoints, iAttribute, Samples, Names) ) { return( false ); } //----------------------------------------------------- m_Regression.Set_With_Intercept(Parameters("INTERCEPT")->asBool()); switch( Parameters("METHOD")->asInt() ) { default: case 0: bResult = m_Regression.Get_Model (Samples , &Names); break; case 1: bResult = m_Regression.Get_Model_Forward (Samples, P , &Names); break; case 2: bResult = m_Regression.Get_Model_Backward(Samples, P, &Names); break; case 3: bResult = m_Regression.Get_Model_Stepwise(Samples, P, P, &Names); break; } if( bResult == false ) { Error_Set(_TL("regression analysis could not detect a significant predictor")); return( false ); } //----------------------------------------------------- Message_Add(m_Regression.Get_Info(), false); //----------------------------------------------------- int CrossVal; switch( Parameters("CROSSVAL")->asInt() ) { default: CrossVal = 0; break; // none case 1: CrossVal = 1; break; // leave one out (LOOVC) case 2: CrossVal = 2; break; // 2-fold case 3: CrossVal = Parameters("CROSSVAL_K")->asInt(); break; // k-fold } if( CrossVal > 0 && m_Regression.Get_CrossValidation(CrossVal) ) { Message_Add(CSG_String::Format(SG_T("\n%s:\n" ), _TL("Cross Validation")), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%s\n" ), _TL("Type" ), Parameters("CROSSVAL")->asString() ), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%d\n" ), _TL("Samples"), m_Regression.Get_CV_nSamples() ), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%f\n" ), _TL("RMSE" ), m_Regression.Get_CV_RMSE() ), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%.2f\n"), _TL("NRMSE" ), m_Regression.Get_CV_NRMSE() * 100.0), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%.2f\n"), _TL("R2" ), m_Regression.Get_CV_R2() * 100.0), false); } //----------------------------------------------------- Set_Regression(pGrids, pRegression, CSG_String::Format("%s.%s [%s]", pPoints->Get_Name(), Parameters("ATTRIBUTE")->asString(), _TL("Regression"))); //----------------------------------------------------- if( Parameters("INFO_COEFF")->asTable() ) { Parameters("INFO_COEFF")->asTable()->Assign(m_Regression.Get_Info_Regression()); Parameters("INFO_COEFF")->asTable()->Set_Name(_TL("MLRA Coefficients")); } if( Parameters("INFO_MODEL")->asTable() ) { Parameters("INFO_MODEL")->asTable()->Assign(m_Regression.Get_Info_Model()); Parameters("INFO_MODEL")->asTable()->Set_Name(_TL("MLRA Model")); } if( Parameters("INFO_STEPS")->asTable() ) { Parameters("INFO_STEPS")->asTable()->Assign(m_Regression.Get_Info_Steps()); Parameters("INFO_STEPS")->asTable()->Set_Name(_TL("MLRA Steps")); } //----------------------------------------------------- Set_Residuals(Parameters("RESIDUALS")->asShapes()); Set_Residual_Corr(pRegression, Parameters("RESIDUALS")->asShapes(), Parameters("REGRESCORR")->asGrid()); m_Regression.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoint_Multi_Grid_Regression::Get_Samples(CSG_Parameter_Grid_List *pGrids, CSG_Shapes *pPoints, int iAttribute, CSG_Matrix &Samples, CSG_Strings &Names) { int iGrid; double zGrid; CSG_Vector Sample; //----------------------------------------------------- int Interpolation = Parameters("INTERPOL")->asInt (); bool bCoord_X = Parameters("COORD_X" )->asBool(); bool bCoord_Y = Parameters("COORD_Y" )->asBool(); Names += pPoints->Get_Field_Name(iAttribute); // Dependent Variable for(iGrid=0; iGridGet_Count(); iGrid++) // Independent Variables { Names += pGrids->asGrid(iGrid)->Get_Name(); } if( bCoord_X ) { Names += SG_T("X"); } if( bCoord_Y ) { Names += SG_T("Y"); } Sample.Create(1 + pGrids->Get_Count() + (bCoord_X ? 1 : 0) + (bCoord_Y ? 1 : 0)); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pPoints->Get_Count()); iShape++) { CSG_Shape *pShape = pPoints->Get_Shape(iShape); if( !pShape->is_NoData(iAttribute) ) { Sample[0] = pShape->asDouble(iAttribute); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { bool bAdd = true; TSG_Point Point = pShape->Get_Point(iPoint, iPart); for(iGrid=0; iGridGet_Count() && bAdd; iGrid++) { if( pGrids->asGrid(iGrid)->Get_Value(Point, zGrid, Interpolation) ) { Sample[1 + iGrid] = zGrid; } else { bAdd = false; } } if( bAdd ) { if( bCoord_X ) { Sample[1 + iGrid++] = Point.x; } if( bCoord_Y ) { Sample[1 + iGrid++] = Point.y; } Samples.Add_Row(Sample); } } } } } //----------------------------------------------------- return( Samples.Get_NRows() >= pGrids->Get_Count() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoint_Multi_Grid_Regression::Set_Regression(CSG_Parameter_Grid_List *pGrids, CSG_Grid *pRegression, const CSG_String &Name) { if( !pRegression ) { return( false ); } //----------------------------------------------------- int iGrid, nGrids, x, y; TSG_Point p; int Interpolation = Parameters("INTERPOL")->asInt(); CSG_Grid **ppGrids = (CSG_Grid **)SG_Malloc(m_Regression.Get_nPredictors() * sizeof(CSG_Grid *)); int iCoord_X = -1; int iCoord_Y = -1; for(iGrid=0, nGrids=0; iGridGet_Count() ) { ppGrids[nGrids++] = pGrids->asGrid(m_Regression.Get_Predictor(iGrid)); } else if( m_Regression.Get_Predictor(iGrid) == pGrids->Get_Count() && Parameters("COORD_X")->asBool() ) { iCoord_X = iGrid; } else // if( m_Regression.Get_Predictor(iGrid) > pGrids->Get_Count() || Parameters("COORD_X")->asBool() == false ) { iCoord_Y = iGrid; } } pRegression->Set_Name(Name); //----------------------------------------------------- for(y=0, p.y=Get_YMin(); yGet_Value(p, zGrid, Interpolation) ) { z += m_Regression.Get_RCoeff(iGrid) * zGrid; } else { bOkay = false; } } //--------------------------------------------- if( bOkay ) { if( iCoord_X >= 0 ) { z += m_Regression.Get_RCoeff(iCoord_X) * p.x; } if( iCoord_Y >= 0 ) { z += m_Regression.Get_RCoeff(iCoord_Y) * p.y; } pRegression->Set_Value (x, y, z); } else { pRegression->Set_NoData(x, y); } } } //----------------------------------------------------- SG_Free(ppGrids); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoint_Multi_Grid_Regression::Set_Residuals(CSG_Shapes *pResiduals) { if( !pResiduals ) { return( false ); } //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS" )->asShapes(); CSG_Grid *pRegression = Parameters("REGRESSION")->asGrid(); int iAttribute = Parameters("ATTRIBUTE" )->asInt(); int Interpolation = Parameters("INTERPOL" )->asInt(); //----------------------------------------------------- pResiduals->Create(SHAPE_TYPE_Point, CSG_String::Format("%s.%s [%s]", pPoints->Get_Name(), Parameters("ATTRIBUTE")->asString(), _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(int iShape=0; iShapeGet_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; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { double zGrid; TSG_Point Point = pShape->Get_Point(iPoint, iPart); if( pRegression->Get_Value(Point, zGrid, Interpolation) ) { CSG_Shape *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 ); } //--------------------------------------------------------- bool CPoint_Multi_Grid_Regression::Set_Residual_Corr(CSG_Grid *pRegression, CSG_Shapes *pResiduals, CSG_Grid *pCorrection) { //----------------------------------------------------- if( !pCorrection ) { return( false ); } //----------------------------------------------------- CSG_Shapes Residuals; if( !pResiduals ) { if( !Set_Residuals(&Residuals) ) { return( false ); } pResiduals = &Residuals; } //----------------------------------------------------- switch( Parameters("RESIDUAL_COR")->asInt() ) { default: // Multlevel B-Spline Interpolation SG_RUN_MODULE_ExitOnError("grid_spline", 4, SG_MODULE_PARAMETER_SET("SHAPES" , pResiduals) && SG_MODULE_PARAMETER_SET("FIELD" , 2) && SG_MODULE_PARAMETER_SET("TARGET_DEFINITION", 1) // grid or grid system && SG_MODULE_PARAMETER_SET("TARGET_OUT_GRID" , pCorrection) ); break; case 1: // Inverse Distance Weighted SG_RUN_MODULE_ExitOnError("grid_gridding", 1, SG_MODULE_PARAMETER_SET("SHAPES" , pResiduals) && SG_MODULE_PARAMETER_SET("FIELD" , 2) && SG_MODULE_PARAMETER_SET("TARGET_DEFINITION", 1) // grid or grid system && SG_MODULE_PARAMETER_SET("TARGET_OUT_GRID" , pCorrection) && SG_MODULE_PARAMETER_SET("SEARCH_RANGE" , 1) // global && SG_MODULE_PARAMETER_SET("SEARCH_POINTS_ALL", 1) // all points within search distance ); break; } //----------------------------------------------------- #pragma omp parallel for for(int y=0; yis_NoData(x, y) || pCorrection->is_NoData(x, y) ) { pCorrection->Set_NoData(x, y); } else { pCorrection->Add_Value(x, y, pRegression->asDouble(x, y)); } } } pCorrection->Set_Name(CSG_String::Format("%s.%s [%s]", Parameters("POINTS")->asShapes()->Get_Name(), Parameters("ATTRIBUTE")->asString(), _TL("Residual Corrected Regression"))); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // //----------------------------------------------------- // Parameters.Add_Choice( // NULL ,"CORRECTION" , _TL("Adjustment"), // _TL(""), // CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), // _TL("Smith"), // _TL("Wherry 1"), // _TL("Wherry 2"), // _TL("Olkin & Pratt"), // _TL("Pratt"), // _TL("Claudy 3") // ), 1 // ); // // TSG_Regression_Correction m_Correction; // // switch( Parameters("CORRECTION")->asInt() ) // { // case 0: m_Correction = REGRESSION_CORR_Smith; break; // case 1: m_Correction = REGRESSION_CORR_Wherry_1; break; // case 2: m_Correction = REGRESSION_CORR_Wherry_2; break; // case 3: m_Correction = REGRESSION_CORR_Olkin_Pratt; break; // case 4: m_Correction = REGRESSION_CORR_Pratt; break; // case 5: m_Correction = REGRESSION_CORR_Claudy_3; break; // } // /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/point_grid_regression.cpp0000664000175000017500000002453212565125413031766 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: point_grid_regression.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "point_grid_regression.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoint_Grid_Regression::CPoint_Grid_Regression(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Regression Analysis (Points and Predictor Grid)")); Set_Author (SG_T("O.Conrad (c) 2004")); Set_Description (_TW( "Regression analysis of point attributes with a grid as predictor. " "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 , "PREDICTOR" , _TL("Predictor"), _TL(""), PARAMETER_INPUT ); pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ATTRIBUTE" , _TL("Dependent Variable"), _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("PREDICTOR" )->asGrid(); pRegression = Parameters("REGRESSION")->asGrid(); pShapes = Parameters("POINTS" )->asShapes(); iAttribute = Parameters("ATTRIBUTE" )->asInt(); pResiduals = Parameters("RESIDUAL" )->asShapes(); 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]"), Parameters("ATTRIBUTE")->asString(), _TL("Regression Model"))); 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, CSG_String::Format(SG_T("%s [%s]"), Parameters("ATTRIBUTE")->asString(), _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; iShapeGet_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; iPartGet_Part_Count(); iPart++) { for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { if( pGrid->Get_Value(Point = pShape->Get_Point(iPoint, iPart), zGrid, m_Interpolation) ) { 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; yis_NoData(x, y) ) pRegression->Set_NoData(x, y); else pRegression->Set_Value (x, y, m_Regression.Get_y(pGrid->asDouble(x, y))); } } 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; iPointGet_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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/gw_regression.h0000664000175000017500000001134412565125413027707 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gw_regression.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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); virtual CSG_String Get_MenuPath (void) { return(_TL("A:Spatial and Geostatistics|Geographically Weighted Regression")); } protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: int m_iDependent, m_iPredictor; CSG_Parameters_Grid_Target m_Grid_Target; CSG_Distance_Weighting m_Weighting; CSG_Parameters_Search_Points m_Search; CSG_Shapes *m_pPoints; CSG_Grid *m_pIntercept, *m_pSlope, *m_pQuality; int Set_Variables (int x, int y); bool Get_Model (int x, int y, CSG_Regression_Weighted &Model); bool Set_Residuals (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GW_Regression_H saga-2.2.3/src/modules/statistics/statistics_regression/gw_multi_regression.h0000664000175000017500000001146012565125413031120 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gw_multi_regression.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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); virtual CSG_String Get_MenuPath (void) { return(_TL("A:Spatial and Geostatistics|Geographically Weighted Regression")); } protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: int m_iDependent, *m_iPredictor, m_nPredictors; CSG_Parameters_Grid_Target m_Grid_Target; CSG_Distance_Weighting m_Weighting; CSG_Parameters_Search_Points m_Search; CSG_Shapes *m_pPoints; CSG_Grid *m_pQuality, *m_pIntercept, **m_pSlopes; bool Initialize (void); void Finalize (void); bool Get_Model (int x, int y, CSG_Regression_Weighted &Model); bool Set_Residuals (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gw_multi_regression_H saga-2.2.3/src/modules/statistics/statistics_regression/point_grid_regression.h0000664000175000017500000001075312565125413031433 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: point_grid_regression.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 saga-2.2.3/src/modules/statistics/statistics_regression/grids_trend_polynom.h0000664000175000017500000001071512565125413031114 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grids_trend_polynom.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // grids_trend_polynom.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grids_trend_polynom_H #define HEADER_INCLUDED__grids_trend_polynom_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrids_Trend : public CSG_Module_Grid { public: CGrids_Trend(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grids_trend_polynom_H saga-2.2.3/src/modules/statistics/statistics_regression/table_regression_multiple.cpp0000664000175000017500000003375512565125413032641 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table_regression_multiple.cpp 1098 2011-06-16 16:06:32Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // table_regression_multiple.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "table_regression_multiple.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTable_Regression_Multiple_Base::Initialise(void) { //----------------------------------------------------- Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Multiple linear regression analysis using ordinary least squares." )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters("TABLE"); Parameters.Add_Table_Field( pNode , "DEPENDENT" , _TL("Dependent Variable"), _TL("") ); Parameters.Add_Parameters( pNode , "PREDICTORS" , _TL("Predictors"), _TL("") ); Parameters.Add_Table( NULL , "INFO_COEFF" , _TL("Details: Coefficients"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Table( NULL , "INFO_MODEL" , _TL("Details: Model"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Table( NULL , "INFO_STEPS" , _TL("Details: Steps"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL ,"METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("include all"), _TL("forward"), _TL("backward"), _TL("stepwise") ), 3 ); Parameters.Add_Value( NULL , "P_VALUE" , _TL("Significance Level"), _TL("Significance level (aka p-value) as threshold for automated predictor selection, given as percentage"), PARAMETER_TYPE_Double, 5.0, 0.0, true, 100.0, true ); Parameters.Add_Choice( NULL ,"CROSSVAL" , _TL("Cross Validation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("none"), _TL("leave one out"), _TL("2-fold"), _TL("k-fold") ), 0 ); Parameters.Add_Value( NULL , "CROSSVAL_K" , _TL("Cross Validation Subsamples"), _TL("number of subsamples for k-fold cross validation"), PARAMETER_TYPE_Int, 10, 2, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTable_Regression_Multiple_Base::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("TABLE")) ) { CSG_Table *pTable = pParameter->asTable(); CSG_Parameters *pPredictors = pParameters->Get_Parameter("PREDICTORS")->asParameters(); pPredictors->Del_Parameters(); if( pTable ) { for(int i=0; iGet_Field_Count(); i++) { if( SG_Data_Type_is_Numeric(pTable->Get_Field_Type(i)) ) { pPredictors->Add_Value(NULL, SG_Get_String(i, 0), pTable->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false); } } } } return( true ); } //--------------------------------------------------------- int CTable_Regression_Multiple_Base::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("METHOD")) ) { pParameters->Set_Enabled("P_VALUE", pParameter->asInt() > 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CROSSVAL")) ) { pParameters->Get_Parameter("CROSSVAL_K")->Set_Enabled(pParameter->asInt() == 3); // k-fold } return( 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTable_Regression_Multiple_Base::On_Execute(void) { //----------------------------------------------------- CSG_Parameters *pPredictors = Parameters("PREDICTORS")->asParameters(); if( pPredictors->Get_Count() <= 0 ) { Message_Add(_TL("no predictors available")); return( false ); } //----------------------------------------------------- int Dependent, iPredictor, nPredictors, *Predictors, iSample; CSG_Strings Names; CSG_Table *pTable; Dependent = Parameters("DEPENDENT")->asInt(); Predictors = new int[pPredictors->Get_Count()]; pTable = Parameters("TABLE")->asTable(); Names += pTable->Get_Field_Name(Dependent); for(iPredictor=0, nPredictors=0; iPredictorGet_Count(); iPredictor++) // Independent Variables { if( pPredictors->Get_Parameter(iPredictor)->asBool() ) { Names += pTable->Get_Field_Name( Predictors[nPredictors++] = CSG_String(pPredictors->Get_Parameter(iPredictor)->Get_Identifier()).asInt() ); } } if( nPredictors <= 0 ) { Message_Add(_TL("no predictors in selection")); delete[](Predictors); return( false ); } //----------------------------------------------------- CSG_Vector Sample(1 + nPredictors); CSG_Matrix Samples; for(iSample=0; iSampleGet_Count(); iSample++) { CSG_Table_Record *pRecord = pTable->Get_Record(iSample); if( !pRecord->is_NoData(Dependent) ) { bool bOkay = true; Sample[0] = pRecord->asDouble(Dependent); for(iPredictor=0; iPredictoris_NoData(Predictors[iPredictor]) ) { Sample[1 + iPredictor] = pRecord->asDouble(Predictors[iPredictor]); } else { bOkay = false; } } if( bOkay ) { Samples.Add_Row(Sample); } } } if( Samples.Get_NRows() <= 0 ) { Message_Add(_TL("no valid samples in data set")); delete[](Predictors); return( false ); } //----------------------------------------------------- CSG_Regression_Multiple Regression; double P = Parameters("P_VALUE")->asDouble(); switch( Parameters("METHOD")->asInt() ) { default: case 0: if( !Regression.Get_Model (Samples , &Names) ) return( false ); break; case 1: if( !Regression.Get_Model_Forward (Samples, P , &Names) ) return( false ); break; case 2: if( !Regression.Get_Model_Backward(Samples, P, &Names) ) return( false ); break; case 3: if( !Regression.Get_Model_Stepwise(Samples, P, P, &Names) ) return( false ); break; } Message_Add(Regression.Get_Info(), false); //----------------------------------------------------- int CrossVal; switch( Parameters("CROSSVAL")->asInt() ) { default: CrossVal = 0; break; // none case 1: CrossVal = 1; break; // leave one out (LOOVC) case 2: CrossVal = 2; break; // 2-fold case 3: CrossVal = Parameters("CROSSVAL_K")->asInt(); break; // k-fold } if( CrossVal > 0 && Regression.Get_CrossValidation(CrossVal) ) { Message_Add(CSG_String::Format(SG_T("\n%s:\n" ), _TL("Cross Validation")), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%s\n" ), _TL("Type" ), Parameters("CROSSVAL")->asString()), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%d\n" ), _TL("Samples"), Regression.Get_CV_nSamples() ), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%f\n" ), _TL("RMSE" ), Regression.Get_CV_RMSE() ), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%.2f\n"), _TL("NRMSE" ), Regression.Get_CV_NRMSE() * 100.0), false); Message_Add(CSG_String::Format(SG_T("\t%s:\t%.2f\n"), _TL("R2" ), Regression.Get_CV_R2() * 100.0), false); } //----------------------------------------------------- if( Parameters("INFO_COEFF")->asTable() ) { Parameters("INFO_COEFF")->asTable()->Assign(Regression.Get_Info_Regression()); Parameters("INFO_COEFF")->asTable()->Set_Name(_TL("MLRA Coefficients")); } if( Parameters("INFO_MODEL")->asTable() ) { Parameters("INFO_MODEL")->asTable()->Assign(Regression.Get_Info_Model()); Parameters("INFO_MODEL")->asTable()->Set_Name(_TL("MLRA Model")); } if( Parameters("INFO_STEPS")->asTable() ) { Parameters("INFO_STEPS")->asTable()->Assign(Regression.Get_Info_Steps()); Parameters("INFO_STEPS")->asTable()->Set_Name(_TL("MLRA Steps")); } //----------------------------------------------------- CSG_Table *pResults = Parameters("RESULTS")->asTable(); if( pResults != NULL && pResults != pTable ) { if( pResults->Get_ObjectType() == DATAOBJECT_TYPE_Shapes && pTable ->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ) { ((CSG_Shapes *)pResults)->Create(*((CSG_Shapes *)pTable)); } else { pResults->Create(*pTable); } pResults->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pTable->Get_Name(), _TL("Regression"))); pTable = pResults; } //----------------------------------------------------- int Offset = pTable->Get_Field_Count(); pTable->Add_Field(_TL("PREDICTED"), SG_DATATYPE_Double); pTable->Add_Field(_TL("RESIDUAL" ), SG_DATATYPE_Double); for(iSample=0; iSampleGet_Count(); iSample++) { CSG_Table_Record *pRecord = pTable->Get_Record(iSample); bool bOkay = false; double z = Regression.Get_RConst(); if( !pRecord->is_NoData(Dependent) ) { for(iPredictor=0, bOkay=true; iPredictoris_NoData(Predictors[iPredictor]) ) { z += Regression.Get_RCoeff(Regression.Get_Predictor(iPredictor)) * pRecord->asDouble(Predictors[iPredictor]); } else { bOkay = false; } } } if( bOkay ) { pRecord->Set_Value(Offset + 0, z); pRecord->Set_Value(Offset + 1, z - pRecord->asDouble(Dependent)); } else { pRecord->Set_NoData(Offset + 0); pRecord->Set_NoData(Offset + 1); } } if( pTable != Parameters("RESULTS")->asTable() ) { DataObject_Update(pTable); } //----------------------------------------------------- delete[](Predictors); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Regression_Multiple::CTable_Regression_Multiple(void) : CTable_Regression_Multiple_Base() { Set_Name (_TL("Multiple Linear Regression Analysis")); Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "RESULTS" , _TL("Results"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Initialise(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Regression_Multiple_Shapes::CTable_Regression_Multiple_Shapes(void) : CTable_Regression_Multiple_Base() { Set_Name (_TL("Multiple Linear Regression Analysis (Shapes)")); Parameters.Add_Shapes( NULL , "TABLE" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "RESULTS" , _TL("Results"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Initialise(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/gw_multi_regression_points.cpp0000664000175000017500000002557212565125413033060 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gw_multi_regression_points.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // gw_multi_regression_points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gw_multi_regression_points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGW_Multi_Regression_Points::CGW_Multi_Regression_Points(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("GWR for Multiple Predictors")); Set_Author ("O.Conrad (c) 2010"); Set_Description (_TW( "Geographically Weighted Regression for multiple predictors. " "Regression details are stored in a copy of input points.\n" "Reference:\n" ) + GWR_References); //----------------------------------------------------- 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_Fields( pNode , "PREDICTORS" , _TL("Predictors"), _TL("") ); Parameters.Add_Shapes( NULL , "REGRESSION" , _TL("Regression"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); //----------------------------------------------------- m_Weighting.Set_Weighting(SG_DISTWGHT_GAUSS); m_Weighting.Create_Parameters(&Parameters, false); //----------------------------------------------------- m_Search.Create(&Parameters, Parameters.Add_Node(NULL, "NODE_SEARCH", _TL("Search Options"), _TL("")), 16); Parameters("SEARCH_RANGE" )->Set_Value(1); Parameters("SEARCH_POINTS_ALL")->Set_Value(1); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGW_Multi_Regression_Points::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "POINTS") ) { m_Search.On_Parameter_Changed(pParameters, pParameter); pParameters->Set_Parameter("DW_BANDWIDTH", GWR_Fit_To_Density(pParameter->asShapes(), 4.0, 1)); } return( 1 ); } //--------------------------------------------------------- int CGW_Multi_Regression_Points::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Search.On_Parameters_Enable(pParameters, pParameter); m_Weighting.Enable_Parameters(pParameters); return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression_Points::Initialize(void) { //----------------------------------------------------- m_pPoints = Parameters("REGRESSION")->asShapes(); m_Weighting.Set_Parameters(&Parameters); //----------------------------------------------------- int iDependent = Parameters("DEPENDENT")->asInt (); CSG_Shapes *pPoints = Parameters("POINTS" )->asShapes(); m_pPoints->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s.%s [%s]"), pPoints->Get_Name(), pPoints->Get_Field_Name(iDependent), _TL("GWR"))); m_pPoints->Add_Field(pPoints->Get_Field_Name(iDependent), SG_DATATYPE_Double); //----------------------------------------------------- CSG_Parameter_Table_Fields *pFields = Parameters("PREDICTORS")->asTableFields(); if( (m_nPredictors = pFields->Get_Count()) <= 0 ) { Error_Set(_TL("no predictors have been selected")); return( false ); } //----------------------------------------------------- int i; for(i=0; iAdd_Field(pPoints->Get_Field_Name(pFields->Get_Index(i)), SG_DATATYPE_Double); } m_pPoints->Add_Field("DEPENDENT" , SG_DATATYPE_Double); // m_nPredictors + 0 m_pPoints->Add_Field("R2" , SG_DATATYPE_Double); // m_nPredictors + 1 m_pPoints->Add_Field("REGRESSION", SG_DATATYPE_Double); // m_nPredictors + 2 m_pPoints->Add_Field("RESIDUAL" , SG_DATATYPE_Double); // m_nPredictors + 3 m_pPoints->Add_Field("INTERCEPT" , SG_DATATYPE_Double); // m_nPredictors + 4 for(i=0; iAdd_Field(CSG_String::Format("%s.%s", _TL("SLOPE"), pPoints->Get_Field_Name(pFields->Get_Index(i))), SG_DATATYPE_Double); } for(int iPoint=0; iPointGet_Count(); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); bool bOkay = !pPoint->is_NoData(iDependent); for(i=0; bOkay && iis_NoData(pFields->Get_Index(i)); } if( bOkay ) { CSG_Shape *pAdd = m_pPoints->Add_Shape(pPoint, SHAPE_COPY_GEOM); for(i=0; iSet_Value(i, pPoint->asDouble(pFields->Get_Index(i))); } pAdd->Set_Value(m_nPredictors, pPoint->asDouble(iDependent)); } } //----------------------------------------------------- if( m_pPoints->Get_Count() == 0 ) { Error_Set(_TL("invalid data")); return( false ); } if( !m_Search.Initialize(m_pPoints, -1) ) { Error_Set(_TL("failed to create searche engine")); return( false ); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- void CGW_Multi_Regression_Points::Finalize(void) { m_Search.Finalize(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression_Points::On_Execute(void) { //----------------------------------------------------- if( !Initialize() ) { Finalize(); return( false ); } //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, m_pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = m_pPoints->Get_Shape(iPoint); CSG_Regression_Weighted Model; if( Get_Model(pPoint->Get_Point(0), Model) ) { double Regression = 0.0; for(int i=0; i<=m_nPredictors; i++) { pPoint->Set_Value(m_nPredictors + 4 + i, Model[i]); Regression += i == 0 ? Model[i] : Model[i] * pPoint->asDouble(i); } pPoint->Set_Value(m_nPredictors + 1, Model.Get_R2()); pPoint->Set_Value(m_nPredictors + 2, Regression); pPoint->Set_Value(m_nPredictors + 3, pPoint->asDouble(0) - Regression); // Residual } } //----------------------------------------------------- Finalize(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression_Points::Get_Model(const TSG_Point &Point, CSG_Regression_Weighted &Model) { //----------------------------------------------------- int nPoints = m_Search.Set_Location(Point); CSG_Vector Predictors(m_nPredictors); Model.Destroy(); for(int iPoint=0; iPointGet_Shape((int)iz) : m_pPoints->Get_Shape(iPoint); for(int iPredictor=0; iPredictorasDouble(iPredictor); } Model.Add_Sample( m_Weighting.Get_Weight(SG_Get_Distance(Point, pPoint->Get_Point(0))), pPoint->asDouble(m_nPredictors), Predictors ); } //----------------------------------------------------- return( Model.Calculate() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/gw_multi_regression.cpp0000664000175000017500000002572612571551577031500 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gw_multi_regression.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gw_multi_regression.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGW_Multi_Regression::CGW_Multi_Regression(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("GWR for Multiple Predictors (Gridded Model Output)")); Set_Author ("O.Conrad (c) 2010"); Set_Description (_TW( "Geographically Weighted Regression for multiple predictors. " "Predictors have to be supplied as attributes of ingoing points data. " "Regression model parameters are generated as continuous fields, i.e. as grids.\n" "Reference:\n" ) + GWR_References); //----------------------------------------------------- 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_Fields( pNode , "PREDICTORS" , _TL("Predictors"), _TL("") ); Parameters.Add_Shapes( NULL , "REGRESSION" , _TL("Regression"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); //----------------------------------------------------- m_Grid_Target.Create(&Parameters, false, NULL, "TARGET_"); m_Grid_Target.Add_Grid("QUALITY" , _TL("Quality" ), false); m_Grid_Target.Add_Grid("INTERCEPT", _TL("Intercept"), false); Parameters.Add_Grid_List( NULL , "SLOPES" , _TL("Slopes"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- m_Weighting.Set_Weighting(SG_DISTWGHT_GAUSS); m_Weighting.Create_Parameters(&Parameters, false); //----------------------------------------------------- m_Search.Create(&Parameters, Parameters.Add_Node(NULL, "NODE_SEARCH", _TL("Search Options"), _TL("")), 16); Parameters("SEARCH_RANGE" )->Set_Value(1); Parameters("SEARCH_POINTS_ALL")->Set_Value(1); //----------------------------------------------------- m_iPredictor = NULL; m_pSlopes = NULL; } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGW_Multi_Regression::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "POINTS") ) { m_Grid_Target.Set_User_Defined(pParameters, pParameter->asShapes()); m_Search.On_Parameter_Changed(pParameters, pParameter); pParameters->Set_Parameter("DW_BANDWIDTH", GWR_Fit_To_Density(pParameter->asShapes(), 4.0, 1)); } return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CGW_Multi_Regression::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Search.On_Parameters_Enable(pParameters, pParameter); m_Weighting.Enable_Parameters(pParameters); return( m_Grid_Target.On_Parameters_Enable(pParameters, pParameter) ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression::Initialize(void) { CSG_Parameter_Table_Fields *pFields = Parameters("PREDICTORS")->asTableFields(); if( (m_nPredictors = pFields->Get_Count()) > 0 ) { m_iPredictor = new int[m_nPredictors]; for(int i=0; iGet_Index(i); } return( true ); } return( false ); } //--------------------------------------------------------- void CGW_Multi_Regression::Finalize(void) { SG_DELETE_ARRAY(m_iPredictor); SG_FREE_SAFE (m_pSlopes); m_Search.Finalize(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression::On_Execute(void) { //----------------------------------------------------- m_pPoints = Parameters("POINTS" )->asShapes(); m_iDependent = Parameters("DEPENDENT")->asInt (); //----------------------------------------------------- if( !Initialize() ) { Finalize(); return( false ); } if( !m_Search.Initialize(m_pPoints, -1) ) { Finalize(); return( false ); } //----------------------------------------------------- m_Grid_Target.Cmd_Update(m_pPoints); // if called from saga_cmd m_Weighting.Set_Parameters(&Parameters); m_pQuality = m_Grid_Target.Get_Grid("QUALITY"); m_pIntercept = m_Grid_Target.Get_Grid("INTERCEPT"); if( !m_pQuality || !m_pIntercept ) { Finalize(); return( false ); } m_pQuality ->Set_Name(CSG_String::Format(SG_T("%s (%s)"), Parameters("DEPENDENT")->asString(), _TL("GWR Quality"))); m_pIntercept->Set_Name(CSG_String::Format(SG_T("%s (%s)"), Parameters("DEPENDENT")->asString(), _TL("GWR Intercept"))); //----------------------------------------------------- CSG_Parameter_Grid_List *pSlopes = Parameters("SLOPES")->asGridList(); m_pSlopes = (CSG_Grid **)SG_Calloc(m_nPredictors, sizeof(CSG_Grid *)); for(int i=0; iAdd_Item(m_pSlopes[i] = SG_Create_Grid(m_pQuality->Get_System())); m_pSlopes[i]->Set_Name(CSG_String::Format(SG_T("%s (%s)"), Parameters("DEPENDENT")->asString(), m_pPoints->Get_Field_Name(m_iPredictor[i]))); } //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, m_pIntercept->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { CSG_Regression_Weighted Model; if( Get_Model(x, y, Model) ) { m_pQuality ->Set_Value(x, y, Model.Get_R2()); m_pIntercept->Set_Value(x, y, Model[0]); for(int i=0; iSet_Value(x, y, Model[i + 1]); } } else { m_pQuality ->Set_NoData(x, y); m_pIntercept->Set_NoData(x, y); for(int i=0; iSet_NoData(x, y); } } } } //----------------------------------------------------- Finalize(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Multi_Regression::Get_Model(int x, int y, CSG_Regression_Weighted &Model) { //----------------------------------------------------- TSG_Point Point = m_pIntercept->Get_System().Get_Grid_to_World(x, y); int nPoints = m_Search.Set_Location(Point); CSG_Vector Predictors(m_nPredictors); Model.Destroy(); for(int iPoint=0; iPointGet_Shape((int)iz) : m_pPoints->Get_Shape(iPoint); if( !pPoint->is_NoData(m_iDependent) ) { bool bOkay = true; for(int iPredictor=0; iPredictoris_NoData(m_iPredictor[iPredictor]) ) { Predictors[iPredictor] = pPoint->asDouble(m_iPredictor[iPredictor]); } else { bOkay = false; } } if( bOkay ) { Model.Add_Sample( m_Weighting.Get_Weight(SG_Get_Distance(Point, pPoint->Get_Point(0))), pPoint->asDouble(m_iDependent), Predictors ); } } } //----------------------------------------------------- return( Model.Calculate() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/MLB_Interface.cpp0000664000175000017500000001534612565125413027765 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Regression") ); case MLB_INFO_Category: return( _TL("Spatial and Geostatistics") ); case MLB_INFO_Author: return( _TL("O.Conrad (c) 2010" )); case MLB_INFO_Description: return( _TL("Tools for regression analyses.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Spatial and 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 "point_zonal_multi_grid_regression.h" #include "gw_regression.h" #include "gw_regression_grid.h" #include "gw_multi_regression.h" #include "gw_multi_regression_grid.h" #include "gw_multi_regression_points.h" #include "gwr_grid_downscaling.h" #include "grid_multi_grid_regression.h" #include "grids_trend_polynom.h" #include "table_trend.h" #include "table_regression_multiple.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 15: return( new CPoint_Zonal_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 ); case 7: return( new CGW_Multi_Regression_Points ); case 14: return( new CGWR_Grid_Downscaling ); case 8: return( new CGrid_Multi_Grid_Regression ); case 9: return( new CGrids_Trend ); case 10: return( new CTable_Trend ); case 11: return( new CTable_Trend_Shapes ); case 12: return( new CTable_Regression_Multiple ); case 13: return( new CTable_Regression_Multiple_Shapes ); //----------------------------------------------------- case 19: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double GWR_Fit_To_Density(CSG_Shapes *pPoints, double Bandwidth, int Rounding) { if (pPoints && pPoints->Get_Count() > 0 && pPoints->Get_Extent().Get_Area() > 0.0) { double d = sqrt(pPoints->Get_Extent().Get_Area() / pPoints->Get_Count()); // get a rough estimation of point density for band width suggestion if (Bandwidth > 0.0) { d *= Bandwidth; } if (Rounding > 0) { d = SG_Get_Rounded_To_SignificantFigures(d, Rounding); } return(d); } return(-1.0); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/point_trend_surface.cpp0000664000175000017500000003355712571551577031447 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: point_trend_surface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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("Polynomial 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 , "ATTRIBUTE" , _TL("Attribute"), _TL("") ); Parameters.Add_Shapes( NULL , "RESIDUALS" , _TL("Residuals"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "POLYNOM" , _TL("Polynom"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("simple planar surface"), // a + bx + cy _TL("bi-linear saddle"), // a + bx + cy + dxy _TL("quadratic surface"), // a + bx + cy + dxy + ex2 + fy2 _TL("cubic surface"), // a + bx + cy + dxy + ex2 + fy2 + gx2y + hxy2 + ix3 + iy3 _TL("user defined") ), 0 ); pNode = Parameters.Add_Node( NULL , "NODE_USER" , _TL("User Defined Polynomial"), _TL("") ); Parameters.Add_Value( pNode , "XORDER" , _TL("Maximum X Order"), _TL(""), PARAMETER_TYPE_Int, 4, 1, true ); Parameters.Add_Value( pNode , "YORDER" , _TL("Maximum Y Order"), _TL(""), PARAMETER_TYPE_Int, 4, 1, true ); Parameters.Add_Value( pNode , "TORDER" , _TL("Maximum Total Order"), _TL(""), PARAMETER_TYPE_Int, 4, 0, true ); //----------------------------------------------------- m_Grid_Target.Create(&Parameters, true, NULL, "TARGET_"); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPoint_Trend_Surface::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "POINTS") ) { m_Grid_Target.Set_User_Defined(pParameters, pParameter->asShapes()); } return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CPoint_Trend_Surface::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "POLYNOM") ) { pParameters->Set_Enabled("NODE_USER", pParameter->asInt() == 4); } return( m_Grid_Target.On_Parameters_Enable(pParameters, pParameter) ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoint_Trend_Surface::On_Execute(void) { int iAttribute; CSG_Shapes *pPoints, *pResiduals; CSG_Grid *pRegression; //----------------------------------------------------- pPoints = Parameters("POINTS" )->asShapes(); pResiduals = Parameters("RESIDUALS")->asShapes(); iAttribute = Parameters("ATTRIBUTE")->asInt(); switch( Parameters("POLYNOM")->asInt() ) { case 0: m_xOrder = 1; m_yOrder = 1; m_tOrder = 1; break; // simple planar surface // a + bx + cy case 1: m_xOrder = 1; m_yOrder = 1; m_tOrder = 2; break; // bi-linear saddle"), // a + bx + cy + dxy case 2: m_xOrder = 2; m_yOrder = 2; m_tOrder = 2; break; // quadratic surface"), // a + bx + cy + dxy + ex2 + fy2 case 3: m_xOrder = 3; m_yOrder = 3; m_tOrder = 3; break; // cubic surface"), // a + bx + cy + dxy + ex2 + fy2 + gx2y + hxy2 + ix3 + iy3 case 4: m_xOrder = Parameters("XORDER")->asInt(); m_yOrder = Parameters("YORDER")->asInt(); m_tOrder = Parameters("TORDER")->asInt(); break; } //----------------------------------------------------- if( !Get_Regression(pPoints, iAttribute) ) { return( false ); } Set_Message(); //----------------------------------------------------- m_Grid_Target.Cmd_Update(pPoints); // if called from saga_cmd if( (pRegression = m_Grid_Target.Get_Grid()) == NULL ) { return( false ); } //----------------------------------------------------- pRegression->Set_Name(CSG_String::Format(SG_T("%s [%s]"), Parameters("ATTRIBUTE")->asString(), _TL("Trend Surface"))); Set_Regression(pRegression); Set_Residuals(pPoints, iAttribute, pResiduals, pRegression); m_Coefficients.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CPoint_Trend_Surface::Get_Power(const SG_Char *Value, int Power) { if( Power > 0 ) { if( Power > 1 ) { return( CSG_String::Format(SG_T("%s%d"), Value, Power) ); } return( Value ); } return( SG_T("") ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoint_Trend_Surface::Get_Regression(CSG_Shapes *pPoints, int iAttribute) { //----------------------------------------------------- int i, j, Field; m_Names.Clear(); m_Names += pPoints->Get_Name(); for(i=1; i<=m_xOrder; i++) { m_Names += Get_Power(SG_T("x"), i); } for(i=1; i<=m_yOrder; i++) { m_Names += Get_Power(SG_T("y"), i); for(j=1; j<=m_xOrder && iGet_Count()); X.Create(m_Names.Get_Count(), pPoints->Get_Count()); xPow.Create(m_xOrder + 1); yPow.Create(m_yOrder + 1); xPow[0] = 1.0; yPow[0] = 1.0; //----------------------------------------------------- for(int iShape=0; iShapeGet_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); TSG_Point Point = pShape->Get_Point(0); Y[iShape] = zShape; X[iShape][0] = 1.0; for(i=1, Field=1; i<=m_xOrder; i++) { X[iShape][Field++] = xPow[i] = xPow[i - 1] * Point.x; } for(i=1; i<=m_yOrder; i++) { X[iShape][Field++] = yPow[i] = yPow[i - 1] * Point.y; for(j=1; j<=m_xOrder && iGet_YMin(); yGet_NY() && Set_Progress(y, pRegression->Get_NY()); y++, Point.y+=pRegression->Get_Cellsize()) { for(x=0, Point.x=pRegression->Get_XMin(); xGet_NX(); x++, Point.x+=pRegression->Get_Cellsize()) { z = m_Coefficients[0]; for(i=1, Field=1; i<=m_xOrder; i++) { z += m_Coefficients[Field++] * (xPow[i] = xPow[i - 1] * Point.x); } for(i=1; i<=m_yOrder; i++) { z += m_Coefficients[Field++] * (yPow[i] = yPow[i - 1] * Point.y); for(j=1; j<=m_xOrder && iSet_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("POLYNOM" , SG_DATATYPE_Double); pResiduals->Add_Field("RESIDUAL", SG_DATATYPE_Double); //------------------------------------------------- for(iShape=0; iShapeGet_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; iPartGet_Part_Count(); iPart++) { for(iPoint=0; iPointGet_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(void) { int i; CSG_String s; //----------------------------------------------------- s += CSG_String::Format(SG_T("\n%s:"), _TL("Regression")); //----------------------------------------------------- s += CSG_String::Format(SG_T("\n z = A")); for(i=1; i /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const CSG_String GWR_References = "- Fotheringham, S.A., Brunsdon, C., Charlton, M. (2002):" " Geographically Weighted Regression: the analysis of spatially varying relationships. John Wiley & Sons." " online.\n" "\n" "- Fotheringham, S.A., Charlton, M., Brunsdon, C. (1998):" " Geographically weighted regression: a natural evolution of the expansion method for spatial data analysis." " Environment and Planning A 30(11), 1905–1927." " online.\n" "\n" "- Lloyd, C. (2010):" " Spatial Data Analysis - An Introduction for GIS Users. Oxford, 206p.\n"; //--------------------------------------------------------- double GWR_Fit_To_Density(CSG_Shapes *pPoints, double Bandwidth, int Rounding = 1); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__statistics_regression_H saga-2.2.3/src/modules/statistics/statistics_regression/gw_regression_grid.cpp0000664000175000017500000002661312565125413031254 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gw_regression_grid.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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)"), Parameters("DEPENDENT")->asString(), s, m_pPredictor->Get_Name())); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGW_Regression_Grid::CGW_Regression_Grid(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("GWR for Single Predictor Grid")); Set_Author ("O.Conrad (c) 2010"); Set_Description (_TW( "Geographically Weighted Regression for a single predictor supplied as grid, " "to which the regression model is applied. Further details can be stored optionally.\n" "Reference:\n" ) + GWR_References); //----------------------------------------------------- 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 ); //----------------------------------------------------- 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 ); //----------------------------------------------------- m_Weighting.Set_Weighting(SG_DISTWGHT_GAUSS); m_Weighting.Create_Parameters(&Parameters, false); //----------------------------------------------------- m_Search.Create(&Parameters, Parameters.Add_Node(NULL, "NODE_SEARCH", _TL("Search Options"), _TL("")), 16); Parameters("SEARCH_RANGE" )->Set_Value(1); Parameters("SEARCH_POINTS_ALL")->Set_Value(1); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGW_Regression_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "POINTS") ) { m_Search.On_Parameter_Changed(pParameters, pParameter); pParameters->Set_Parameter("DW_BANDWIDTH", GWR_Fit_To_Density(pParameter->asShapes(), 4.0, 1)); } return( 1 ); } //--------------------------------------------------------- int CGW_Regression_Grid::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Search.On_Parameters_Enable(pParameters, pParameter); m_Weighting.Enable_Parameters(pParameters); return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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_Weighting.Set_Parameters(&Parameters); //----------------------------------------------------- if( !m_Search.Initialize(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")); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) && Get_Model(x, y, Model)) { SG_GRID_PTR_SAFE_SET_VALUE(m_pRegression, x, y, Model[0] + Model[1] * m_pPredictor->asDouble(x, y)); SG_GRID_PTR_SAFE_SET_VALUE(m_pIntercept , x, y, Model[0]); SG_GRID_PTR_SAFE_SET_VALUE(m_pSlope , x, y, Model[1]); SG_GRID_PTR_SAFE_SET_VALUE(m_pQuality , x, y, Model.Get_CV_R2()); } else { SG_GRID_PTR_SAFE_SET_NODATA(m_pRegression, x, y); SG_GRID_PTR_SAFE_SET_NODATA(m_pIntercept , x, y); SG_GRID_PTR_SAFE_SET_NODATA(m_pSlope , x, y); SG_GRID_PTR_SAFE_SET_NODATA(m_pQuality , x, y); } } } //----------------------------------------------------- Set_Residuals(); m_Search.Finalize(); DataObject_Update(m_pIntercept); DataObject_Update(m_pSlope); DataObject_Update(m_pQuality); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGW_Regression_Grid::Get_Model(int x, int y, CSG_Regression_Weighted &Model) { //----------------------------------------------------- TSG_Point Point = Get_System()->Get_Grid_to_World(x, y); int nPoints = m_Search.Set_Location(Point); Model.Destroy(); for(int iPoint=0; iPointGet_Shape((int)iz) : m_pPoints->Get_Shape(iPoint); if( !pPoint->is_NoData(m_iDependent) && m_pPredictor->Get_Value(pPoint->Get_Point(0), iz) ) { Model.Add_Sample( m_Weighting.Get_Weight(SG_Get_Distance(Point, pPoint->Get_Point(0))), pPoint->asDouble(m_iDependent), CSG_Vector(1, &iz) ); } } //----------------------------------------------------- return( Model.Calculate() ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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; iShapeGet_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; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/point_zonal_multi_grid_regression.h0000664000175000017500000001045612565125413034050 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: point_zonal_multi_grid_regression.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // point_zonal_multi_grid_regression.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__point_zonal_multi_grid_regression_H #define HEADER_INCLUDED__point_zonal_multi_grid_regression_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoint_Zonal_Multi_Grid_Regression : public CSG_Module_Grid { public: CPoint_Zonal_Multi_Grid_Regression(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool Set_Residuals (CSG_Shapes *pShapes, CSG_Grid *pRegression); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__point_zonal_multi_grid_regression_H saga-2.2.3/src/modules/statistics/statistics_regression/gwr_grid_downscaling.cpp0000664000175000017500000003503012565125413031557 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gwr_grid_downscaling.cpp 1633 2013-03-22 13:35:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // gwr_grid_downscaling.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gwr_grid_downscaling.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGWR_Grid_Downscaling::CGWR_Grid_Downscaling(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("GWR for Grid Downscaling")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "References:\n" "- Fotheringham, S.A., Brunsdon, C., Charlton, M. (2002):" " Geographically Weighted Regression: the analysis of spatially varying relationships. John Wiley & Sons." " online.\n" "\n" "- Fotheringham, S.A., Charlton, M., Brunsdon, C. (1998):" " Geographically weighted regression: a natural evolution of the expansion method for spatial data analysis." " Environment and Planning A 30(11), 1905–1927." " online.\n" "\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 , "REG_RESCORR" , _TL("Regression with Residual Correction"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); //----------------------------------------------------- pNode = Parameters.Add_Grid_System( NULL , "GRID_SYSTEM" , _TL("Grid System"), _TL("") ); Parameters.Add_Grid( pNode , "DEPENDENT" , _TL("Dependent Variable"), _TL(""), PARAMETER_INPUT, false ); Parameters.Add_Grid( pNode , "QUALITY" , _TL("Coefficient of Determination"), _TL(""), PARAMETER_OUTPUT, false ); Parameters.Add_Grid( pNode , "RESIDUALS" , _TL("Residuals"), _TL(""), PARAMETER_OUTPUT, false ); Parameters.Add_Grid_List( pNode , "MODEL" , _TL("Regression Parameters"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, false ); Parameters.Add_Value( NULL , "MODEL_OUT" , _TL("Output of Model Parameters"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- pNode = Parameters.Add_Choice( NULL , "SEARCH_RANGE" , _TL("Search Range"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("local"), _TL("global") ) ); Parameters.Add_Value( pNode , "SEARCH_RADIUS" , _TL("Search Distance [Cells]"), _TL(""), PARAMETER_TYPE_Int, 10, 1, true ); m_Search.Get_Weighting().Set_Weighting(SG_DISTWGHT_GAUSS); m_Search.Get_Weighting().Set_BandWidth(7.0); m_Search.Get_Weighting().Create_Parameters(&Parameters, false); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGWR_Grid_Downscaling::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SEARCH_RANGE")) ) { pParameters->Get_Parameter("SEARCH_RADIUS")->Set_Enabled(pParameter->asInt() == 0); // local } m_Search.Get_Weighting().Enable_Parameters(pParameters); return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGWR_Grid_Downscaling::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Grid_List *pPredictors = Parameters("PREDICTORS")->asGridList(); if( (m_nPredictors = pPredictors->Get_Count()) <= 0 ) { return( false ); } m_pDependent = Parameters("DEPENDENT")->asGrid(); if( !m_pDependent->Get_Extent().Intersects(Get_System()->Get_Extent()) ) { return( false ); } //----------------------------------------------------- int i; Process_Set_Text(_TL("upscaling of predictors")); m_pPredictors = (CSG_Grid **)SG_Calloc(m_nPredictors , sizeof(CSG_Grid *)); m_pModel = (CSG_Grid **)SG_Calloc(m_nPredictors + 1, sizeof(CSG_Grid *)); for(i=0; iGet_System()); m_pPredictors[i] ->Assign(pPredictors->asGrid(i), GRID_INTERPOLATION_NearestNeighbour); // GRID_INTERPOLATION_Mean_Cells m_pModel [i] = SG_Create_Grid(m_pDependent->Get_System()); m_pModel [i] ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPredictors->asGrid(i)->Get_Name(), _TL("Factor"))); } m_pModel[m_nPredictors] = SG_Create_Grid(m_pDependent->Get_System()); m_pModel[m_nPredictors] ->Set_Name(_TL("Intercept")); //----------------------------------------------------- Process_Set_Text(_TL("model creation")); bool bResult = Get_Model(); //----------------------------------------------------- for(i=0; iasGrid(i); } //----------------------------------------------------- if( bResult ) { Process_Set_Text(_TL("downscaling")); bResult = Set_Model(); } //----------------------------------------------------- if( Parameters("MODEL_OUT")->asBool() ) { CSG_Parameter_Grid_List *pModel = Parameters("MODEL")->asGridList(); pModel->Del_Items(); pModel->Add_Item(m_pModel[m_nPredictors]); for(i=0; iAdd_Item(m_pModel[i]); } } else { for(i=0; i<=m_nPredictors; i++) { delete(m_pModel[i]); } } SG_FREE_SAFE(m_pModel); SG_FREE_SAFE(m_pPredictors); return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGWR_Grid_Downscaling::Set_Model(double x, double y, double &Value, double &Residual) { if( !m_pModel[m_nPredictors]->Get_Value(x, y, Value, GRID_INTERPOLATION_BSpline) ) { return( false ); } double Model, Predictor; for(int i=0; iGet_Value(x, y, Model , GRID_INTERPOLATION_BSpline, false, true) || !m_pPredictors[i]->Get_Value(x, y, Predictor, GRID_INTERPOLATION_BSpline, false, true) ) { return( false ); } Value += Model * Predictor; } if( !m_pResiduals->Get_Value(x, y, Residual, GRID_INTERPOLATION_BSpline) ) { Residual = 0.0; } return( true ); } //--------------------------------------------------------- bool CGWR_Grid_Downscaling::Set_Model(void) { CSG_Grid *pRegression = Parameters("REGRESSION" )->asGrid(); CSG_Grid *pReg_ResCorr = Parameters("REG_RESCORR")->asGrid(); pRegression->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pDependent->Get_Name(), _TL("GWR"))); if( pReg_ResCorr ) { pReg_ResCorr->Set_Name(CSG_String::Format(SG_T("%s [%s, %s]"), m_pDependent->Get_Name(), _TL("GWR"), _TL("Residual Correction"))); } for(int y=0; ySet_Value(x, y, Value); if( pReg_ResCorr ) { pReg_ResCorr->Set_Value(x, y, Value + Residual); } } else { pRegression->Set_NoData(x, y); if( pReg_ResCorr ) { pReg_ResCorr->Set_NoData(x, y); } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGWR_Grid_Downscaling::Get_Model(void) { //----------------------------------------------------- m_pQuality = Parameters("QUALITY" )->asGrid(); m_pQuality ->Set_Name(CSG_String::Format(SG_T("%s [%s, %s]"), m_pDependent->Get_Name(), _TL("GWR"), _TL("Quality"))); m_pResiduals = Parameters("RESIDUALS")->asGrid(); m_pResiduals ->Set_Name(CSG_String::Format(SG_T("%s [%s, %s]"), m_pDependent->Get_Name(), _TL("GWR"), _TL("Residuals"))); //----------------------------------------------------- m_Search.Get_Weighting().Set_Parameters(&Parameters); m_Search.Set_Radius(Parameters("SEARCH_RANGE")->asInt() == 0 ? Parameters("SEARCH_RADIUS")->asInt() : 1 + (int)(SG_Get_Length(m_pDependent->Get_NX(), m_pDependent->Get_NY())) ); //----------------------------------------------------- CSG_Grid_System System(m_pDependent->Get_System()); for(int y=0; ySet_Value(x, y, Model.Get_R2()); m_pModel[m_nPredictors]->Set_Value(x, y, Model[0]); // intercept for(int i=0; iSet_Value(x, y, Model[i + 1]); } } else { m_pQuality->Set_NoData(x, y); for(int i=0; i<=m_nPredictors; i++) { m_pModel[i]->Set_NoData(x, y); } m_pResiduals->Set_NoData(x, y); } } } //----------------------------------------------------- m_Search.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGWR_Grid_Downscaling::Get_Model(int x, int y, CSG_Regression_Weighted &Model) { //----------------------------------------------------- CSG_Vector Predictors(m_nPredictors); Model.Destroy(); //----------------------------------------------------- for(int i=0, ix, iy; iis_InGrid(ix, iy) ) { for(int iPredictor=0; iPredictor0.0; iPredictor++) { if( !m_pPredictors[iPredictor]->is_NoData(ix, iy) ) { Predictors[iPredictor] = m_pPredictors[iPredictor]->asDouble(ix, iy); } else { Weight = 0.0; } } if( Weight > 0.0 ) { Model.Add_Sample(Weight, m_pDependent->asDouble(ix, iy), Predictors); } } } //----------------------------------------------------- if( Model.Calculate() ) { m_pResiduals->Set_NoData(x, y); if( m_pDependent->is_NoData(x, y) ) { return( true ); } double Value = Model[0]; for(int iPredictor=0; iPredictoris_NoData(x, y) ) { return( true ); } Value += Model[1 + iPredictor] * m_pPredictors[iPredictor]->asDouble(x, y); } m_pResiduals->Set_Value(x, y, m_pDependent->asDouble(x, y) - Value); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_regression/gwr_grid_downscaling.h0000664000175000017500000001122112565125413031220 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gwr_grid_downscaling.h 1549 2012-11-29 16:38:50Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_regression // // // //-------------------------------------------------------// // // // gwr_grid_downscaling.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gwr_grid_downscaling_H #define HEADER_INCLUDED__gwr_grid_downscaling_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGWR_Grid_Downscaling : public CSG_Module_Grid { public: CGWR_Grid_Downscaling(void); virtual CSG_String Get_MenuPath (void) { return(_TL("A:Spatial and Geostatistics|Geographically Weighted Regression")); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_nPredictors; CSG_Grid_Cell_Addressor m_Search; CSG_Grid *m_pDependent, **m_pPredictors, **m_pModel, *m_pQuality, *m_pResiduals; bool Set_Model (double x, double y, double &Value, double &Residual); bool Set_Model (void); bool Get_Model (void); bool Get_Model (int x, int y, CSG_Regression_Weighted &Model); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gwr_grid_downscaling_H saga-2.2.3/src/modules/statistics/statistics_regression/point_trend_surface.h0000664000175000017500000001131312565125413031063 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: point_trend_surface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_xOrder, m_yOrder, m_tOrder; CSG_Parameters_Grid_Target m_Grid_Target; CSG_Vector m_Coefficients; CSG_Strings m_Names; CSG_String Get_Power (const SG_Char *Value, int Power); bool Get_Regression (CSG_Shapes *pPoints, int iAttribute); bool Set_Regression (CSG_Grid *pRegression); bool Set_Residuals (CSG_Shapes *pPoints, int iAttribute, CSG_Shapes *pResiduals, CSG_Grid *pRegression); void Set_Message (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__point_trend_surface_H saga-2.2.3/src/modules/statistics/statistics_regression/gw_multi_regression_grid.h0000664000175000017500000001176212565125413032132 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gw_multi_regression_grid.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Spatial and Geostatistics|Geographically Weighted Regression") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_nPredictors; CSG_Grid **m_pPredictors, **m_pModel, *m_pQuality; CSG_Grid_System m_dimModel; CSG_Distance_Weighting m_Weighting; CSG_Parameters_Search_Points m_Search; CSG_Shapes m_Points; bool Initialize (CSG_Shapes *pPoints, int iDependent, CSG_Parameter_Grid_List *pPredictors); void Finalize (void); bool Get_Model (void); bool Get_Model (int x, int y, CSG_Regression_Weighted &Model); bool Set_Model (void); bool Set_Model (double x, double y, double &Value); bool Set_Residuals (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gw_multi_regression_grid_H saga-2.2.3/src/modules/statistics/Makefile.am0000664000175000017500000000026312565125413022261 0ustar00oconradoconrad00000000000000if WITH_GUI SUBDIRS = statistics_points statistics_kriging statistics_grid statistics_regression else SUBDIRS = statistics_points statistics_grid statistics_regression endif saga-2.2.3/src/modules/statistics/statistics_grid/0000775000175000017500000000000012634325747023434 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Directional_Statistics.h0000664000175000017500000001107012565125413031441 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Directional_Statistics.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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, double *s); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GSGrid_Directional_Statistics_H saga-2.2.3/src/modules/statistics/statistics_grid/grid_pca.cpp0000664000175000017500000003716612565125413025714 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_pca.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // grid_pca.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_pca.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_PCA::CGrid_PCA(void) { //----------------------------------------------------- Set_Name (_TL("Principle Components Analysis")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "Principle Components Analysis (PCA) for grids. " "Implementation based on F. Murtagh's " "code " "as provided by the " "StatLib web site.\n" "\n" "References:\n" "Bahrenberg, G., Giese, E., Nipper, J. (1992): Statistische Methoden in der Geographie 2 - Multivariate Statistik. pp.198-277.\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "PCA" , _TL("Principle Components"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Table( NULL , "EIGEN" , _TL("Eigen Vectors"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("correlation matrix"), _TL("variance-covariance matrix"), _TL("sums-of-squares-and-cross-products matrix") ), 1 ); Parameters.Add_Value( NULL , "NFIRST" , _TL("Number of Components"), _TL("maximum number of calculated first components; set to zero to get all"), PARAMETER_TYPE_Int, 3, 0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_PCA::On_Execute(void) { CSG_Vector Eigen_Values; CSG_Matrix Eigen_Vectors, Matrix; //----------------------------------------------------- m_pGrids = Parameters("GRIDS" )->asGridList(); m_Method = Parameters("METHOD")->asInt(); m_nFeatures = m_pGrids->Get_Count(); //----------------------------------------------------- if( !Get_Matrix(Matrix) ) { Error_Set(_TL("matrix initialisation failed")); return( false ); } //----------------------------------------------------- if( !SG_Matrix_Eigen_Reduction(Matrix, Eigen_Vectors, Eigen_Values) ) { Error_Set(_TL("Eigen reduction failed")); return( false ); } //----------------------------------------------------- Print_Eigen_Values (Eigen_Values ); Print_Eigen_Vectors(Eigen_Vectors); Get_Components(Eigen_Vectors); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CGrid_PCA::is_NoData(sLong iCell) { for(int iFeature=0; iFeatureasGrid(iFeature)->is_NoData(iCell) ) { return( true ); } } return( false ); } //--------------------------------------------------------- inline double CGrid_PCA::Get_Value(sLong iCell, int iFeature) { CSG_Grid *pGrid = m_pGrids->asGrid(iFeature); switch( m_Method ) { default: case 0: // Correlation matrix: Center and reduce the column vectors. return( (pGrid->asDouble(iCell) - pGrid->Get_Mean()) / (sqrt(Get_NCells() * pGrid->Get_Variance())) ); case 1: // Variance-covariance matrix: Center the column vectors. return( (pGrid->asDouble(iCell) - pGrid->Get_Mean()) ); case 2: // Sums-of-squares-and-cross-products matrix return( (pGrid->asDouble(iCell)) ); } } //--------------------------------------------------------- bool CGrid_PCA::Get_Matrix(CSG_Matrix &Matrix) { int j1, j2; sLong iCell; Matrix.Create(m_nFeatures, m_nFeatures); Matrix.Set_Zero(); switch( m_Method ) { //----------------------------------------------------- default: case 0: // Correlation matrix: Center and reduce the column vectors. for(j1=0; j1 0.0 ? 100.0 / Sum : 0.0; Message_Add(CSG_String::Format(SG_T("\n%s, %s, %s\n"), _TL("explained variance"), _TL("explained cumulative variance"), _TL("Eigenvalue")), false); for(i=m_nFeatures-1; i>=0; i--) { Cum += Eigen_Values[i]; Message_Add(CSG_String::Format(SG_T("%d.\t%.2f\t%.2f\t%f\n"), m_nFeatures - i, Sum * Eigen_Values[i], Sum * Cum, Eigen_Values[i] ), false ); } } //--------------------------------------------------------- void CGrid_PCA::Print_Eigen_Vectors(CSG_Matrix &Eigen_Vectors) { Message_Add(CSG_String::Format(SG_T("\n%s:\n"), _TL("Eigenvectors")), false); for(int i=0; i=0; j--) { Message_Add(CSG_String::Format(SG_T("%.4f\t"), Eigen_Vectors[i][j]), false); } Message_Add(m_pGrids->asGrid(i)->Get_Name(), false); Message_Add(SG_T("\n"), false); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_PCA::Get_Components(CSG_Matrix &Eigen_Vectors) { int i; /////////////////////////////////////////////////////// //----------------------------------------------------- CSG_Matrix E(m_nFeatures, m_nFeatures); for(i=0; iasTable(); if( pEigen ) { pEigen->Destroy(); pEigen->Set_Name(_TL("PCA Eigen Vectors")); for(i=0; iAdd_Field(m_pGrids->asGrid(i)->Get_Name(), SG_DATATYPE_Double); } for(i=0; iAdd_Record(); for(int j=0; jSet_Value(j, E[j][i]); } } } /////////////////////////////////////////////////////// //----------------------------------------------------- int nComponents = Parameters("NFIRST")->asInt(); if( nComponents <= 0 || nComponents > m_nFeatures ) { nComponents = m_nFeatures; } //----------------------------------------------------- CSG_Parameter_Grid_List *pPCA = Parameters("PCA")->asGridList(); pPCA->Del_Items(); for(i=0; iAdd_Item(SG_Create_Grid(*Get_System())); pPCA->asGrid(i)->Set_Name(CSG_String::Format(SG_T("%s %d"), _TL("Component"), i + 1)); } //----------------------------------------------------- for(int y=0; yasGrid(i)->is_NoData(x, y) ) { bNoData = true; } else { X[i] = m_pGrids->asGrid(i)->asDouble(x, y); } } if( bNoData ) { for(i=0; iasGrid(i)->Set_NoData(x, y); } } else { CSG_Vector Y = E * X; for(i=0; iasGrid(i)->Set_Value(x, y, Y[i]); } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_PCA_Inverse::CGrid_PCA_Inverse(void) { //----------------------------------------------------- Set_Name (_TL("Inverse Principle Components Rotation")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Inverse principle components rotation for grids. " "\n" "References:\n" "Bahrenberg, G., Giese, E., Nipper, J. (1992): Statistische Methoden in der Geographie 2 - Multivariate Statistik. pp.198-277.\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "PCA" , _TL("Principle Components"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "EIGEN" , _TL("Eigen Vectors"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_PCA_Inverse::On_Execute(void) { int i, nFeatures; CSG_Table *pEigen; //----------------------------------------------------- CSG_Parameter_Grid_List *pPCA, *pGrids; pPCA = Parameters("PCA" )->asGridList(); pGrids = Parameters("GRIDS")->asGridList(); pEigen = Parameters("EIGEN")->asTable(); //----------------------------------------------------- nFeatures = pEigen->Get_Count(); if( nFeatures != pEigen->Get_Field_Count() ) { Error_Set(_TL("warning: number of Eigen vectors and components differs.")); if( nFeatures > pEigen->Get_Field_Count() ) { nFeatures = pEigen->Get_Field_Count(); } } if( nFeatures != pPCA->Get_Count() ) { Error_Set(_TL("warning: number of component grids and components differs.")); if( nFeatures > pPCA->Get_Count() ) { nFeatures = pPCA->Get_Count(); } } if( nFeatures < 2 ) { Error_Set(_TL("nothing to do. transformation needs at least two components.")); return( false ); } //----------------------------------------------------- CSG_Matrix E(nFeatures, nFeatures); for(i=0; iGet_Record(i); for(int j=0; jasDouble(j); } } if( !E.Set_Inverse() ) { Error_Set(_TL("matrix inversion failed")); return( false ); } //----------------------------------------------------- pGrids->Del_Items(); for(i=0; iAdd_Item(SG_Create_Grid(*Get_System())); pGrids->asGrid(i)->Set_Name(CSG_String::Format(SG_T("%s %d"), _TL("Feature"), i + 1)); } //----------------------------------------------------- for(int y=0; yasGrid(i)->is_NoData(x, y) ) { bNoData = true; } else { Y[i] = pPCA->asGrid(i)->asDouble(x, y); } } if( bNoData ) { for(i=0; iasGrid(i)->Set_NoData(x, y); } } else { CSG_Vector X = E * Y; for(i=0; iasGrid(i)->Set_Value(x, y, X[i]); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_grid/grid_autocorrelation.h0000664000175000017500000001005712565125413030016 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_autocorrelation.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // grid_autocorrelation.h // // // // Copyright (C) 2010 by // // Jan Papmeier // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_autocorrelation_H #define HEADER_INCLUDED__grid_autocorrelation_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Autocorrelation : public CSG_Module_Grid { public: CGrid_Autocorrelation(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_autocorrelation_H saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Variance.h0000664000175000017500000001164112565125413026526 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Variance.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // GSGrid_Variance.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GSGrid_Variance_H #define HEADER_INCLUDED__GSGrid_Variance_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGSGrid_Variance : public CSG_Module_Grid { public: CGSGrid_Variance(void); virtual ~CGSGrid_Variance(void); protected: virtual bool On_Execute (void); private: int maxRadius, *Z, *x_diff, *y_diff, *rLength; double Exponent, // Exponent fuer "inverse distance" Gewichte (calc_Steigung). *V, *m, *g; CSG_Grid *pInput, *pOutput, *pRadius; void Initialize (void); void Finalize (void); void Init_Radius (void); double Get_Laenge (int x, int y); double Get_GSGrid_Variance (int x, int y, int iRadius, int &Count); double Get_Steigung (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GSGrid_Variance_H saga-2.2.3/src/modules/statistics/statistics_grid/grid_pca.h0000664000175000017500000001231512565125413025346 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_pca.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // grid_pca.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_pca_H #define HEADER_INCLUDED__grid_pca_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_PCA : public CSG_Module_Grid { public: CGrid_PCA(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Principle Components") ); } protected: virtual bool On_Execute (void); private: int m_Method, m_nFeatures; CSG_Parameter_Grid_List *m_pGrids; bool is_NoData (sLong iCell); double Get_Value (sLong iCell, int iFeature); bool Get_Matrix (CSG_Matrix &Matrix); void Print_Eigen_Values (CSG_Vector &Eigen_Values); void Print_Eigen_Vectors (CSG_Matrix &Eigen_Vectors); bool Get_Components (CSG_Matrix &Eigen_Vectors); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_PCA_Inverse : public CSG_Module_Grid { public: CGrid_PCA_Inverse(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Principle Components") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_pca_H saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Statistics.h0000664000175000017500000001163512565125413027133 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Statistics.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // GSGrid_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GSGrid_Statistics_H #define HEADER_INCLUDED__GSGrid_Statistics_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGSGrid_Statistics : public CSG_Module_Grid { public: CGSGrid_Statistics(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGSGrid_Statistics_To_Table : public CSG_Module_Grid { public: CGSGrid_Statistics_To_Table(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GSGrid_Statistics_H saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Variance.cpp0000664000175000017500000002260112565125413027057 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Variance.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // GSGrid_Variance.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "GSGrid_Variance.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGSGrid_Variance::CGSGrid_Variance(void) { Set_Name (_TL("Representativeness (Grid)")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Representativeness - calculation of the variance within a given search radius.\n" "\n" "Reference:\n" "- Boehner, J., Koethe, R., Trachinow, C. (1997): " "'Weiterentwicklung der automatischen Reliefanalyse auf der Basis von Digitalen Gelaendemodellen', " "Goettinger Geographische Abhandlungen, Vol.100, p.3-21\n" )); Parameters.Add_Grid( NULL , "INPUT" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "RESULT" , _TL("Representativeness"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Radius (Cells)"), _TL(""), PARAMETER_TYPE_Int, 10 ); Parameters.Add_Value( NULL , "EXPONENT", _TL("Exponent"), _TL(""), PARAMETER_TYPE_Double, 1 ); } //--------------------------------------------------------- CGSGrid_Variance::~CGSGrid_Variance(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGSGrid_Variance::On_Execute(void) { int x, y; //----------------------------------------------------- pInput = Parameters("INPUT" )->asGrid(); pOutput = Parameters("RESULT" )->asGrid(); maxRadius = Parameters("RADIUS" )->asInt(); Exponent = Parameters("EXPONENT" )->asDouble(); //----------------------------------------------------- Initialize(); //----------------------------------------------------- for(y=0; ySet_Value(x,y, Get_Laenge(x,y) ); } } //----------------------------------------------------- Finalize(); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CGSGrid_Variance::Initialize(void) { pOutput->Assign_NoData(); V = (double *)malloc((maxRadius + 2) * sizeof(double)); Z = (int *)malloc((maxRadius + 2) * sizeof(int )); g = (double *)malloc((maxRadius + 2) * sizeof(double)); m = (double *)malloc((maxRadius + 2) * sizeof(double)); rLength = (int *)malloc((maxRadius + 2) * sizeof(int )); Init_Radius(); } //--------------------------------------------------------- void CGSGrid_Variance::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; } } //--------------------------------------------------------- void CGSGrid_Variance::Finalize(void) { free(V); free(Z); free(rLength); free(g); free(m); free(x_diff); free(y_diff); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CGSGrid_Variance::Get_Laenge(int x, int y) { int iRadius, Count; double d; //----------------------------------------------------- V[0] = Get_GSGrid_Variance(x,y,1,Count); Z[0] = Count; for(iRadius=1; iRadiusasDouble(x,y); for(i=rLength[iRadius-1], Count=0; i= Get_NX() ) ix = Get_NX() - 1; iy = y + y_diff[i]; if( iy < 0 ) iy = 0; else if( iy >= Get_NY() ) iy = Get_NY() - 1; d = z - pInput->asDouble(ix,iy); Variance += d * d; } return( Variance ); } //--------------------------------------------------------- double CGSGrid_Variance::Get_Steigung(void) { int i; double summe_mg, summe_g; //----------------------------------------------------- // Steigungen berechnen... m[0] = V[0] / Get_Cellsize(); for(i=1; iasParameters()->Assign(m_Cells.Get_Weighting().Get_Parameters()); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGSGrid_Directional_Statistics::On_Execute(void) { int Radius; double Direction, Tolerance, s[id_Count]; CSG_Shapes *pPoints; //----------------------------------------------------- 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(); pPoints = Parameters("POINTS") ->asShapes(); //----------------------------------------------------- if( !(m_pMean || m_pDifMean || m_pMin || m_pMax || m_pRange || m_pVar || m_pStdDev || m_pStdDevLo || m_pStdDevHi || m_pPercent || pPoints) ) { Message_Dlg(_TL("no target 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 ); } //----------------------------------------------------- if( m_pMean || m_pDifMean || m_pMin || m_pMax || m_pRange || m_pVar || m_pStdDev || m_pStdDevLo || m_pStdDevHi || m_pPercent ) { for(int y=0; ySet_Value(x, y, s[id_Mean ]); if( m_pDifMean ) m_pDifMean ->Set_Value(x, y, s[id_DifMean ]); if( m_pMin ) m_pMin ->Set_Value(x, y, s[id_Min ]); if( m_pMax ) m_pMax ->Set_Value(x, y, s[id_Max ]); if( m_pRange ) m_pRange ->Set_Value(x, y, s[id_Range ]); if( m_pVar ) m_pVar ->Set_Value(x, y, s[id_Var ]); if( m_pStdDev ) m_pStdDev ->Set_Value(x, y, s[id_StdDev ]); if( m_pStdDevLo ) m_pStdDevLo ->Set_Value(x, y, s[id_StdDevLo]); if( m_pStdDevHi ) m_pStdDevHi ->Set_Value(x, y, s[id_StdDevHi]); if( m_pDevMean ) m_pDevMean ->Set_Value(x, y, s[id_DevMean ]); if( m_pPercent ) m_pPercent ->Set_Value(x, y, s[id_Percent ]); } else { 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); } } } } //----------------------------------------------------- if( pPoints ) { if( Parameters("POINTS_OUT")->asShapes() && Parameters("POINTS_OUT")->asShapes() != pPoints ) { pPoints = Parameters("POINTS_OUT")->asShapes(); pPoints->Create(*Parameters("POINTS")->asShapes()); pPoints->Set_Name(CSG_String::Format(SG_T("%s [a: %.2f, d: %.2f]"), _TL("Directional Statistics"), Direction * M_RAD_TO_DEG, Tolerance * M_RAD_TO_DEG)); } int x, y, id_Offset = pPoints->Get_Field_Count(); pPoints->Add_Field(_TL("MEAN") , SG_DATATYPE_Double); pPoints->Add_Field(_TL("DIFF_MEAN") , SG_DATATYPE_Double); pPoints->Add_Field(_TL("MIN") , SG_DATATYPE_Double); pPoints->Add_Field(_TL("MAX") , SG_DATATYPE_Double); pPoints->Add_Field(_TL("RANGE") , SG_DATATYPE_Double); pPoints->Add_Field(_TL("VARIANCE") , SG_DATATYPE_Double); pPoints->Add_Field(_TL("STDDEV") , SG_DATATYPE_Double); pPoints->Add_Field(_TL("STDDEV_LO") , SG_DATATYPE_Double); pPoints->Add_Field(_TL("STDDEV_HI") , SG_DATATYPE_Double); pPoints->Add_Field(_TL("STDDEV_MEAN") , SG_DATATYPE_Double); pPoints->Add_Field(_TL("PERCENTILE") , SG_DATATYPE_Double); for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); if( Get_System()->Get_World_to_Grid(x, y, pPoint->Get_Point(0)) && Get_Statistics(x, y, s) ) { for(int i=0; iSet_Value(id_Offset + i, s[i]); } } else { for(int i=0; iSet_NoData(id_Offset + i); } } } DataObject_Update(pPoints); } //----------------------------------------------------- m_Cells.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGSGrid_Directional_Statistics::Get_Statistics(int x, int y, double *s) { 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 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 ) { s[id_Mean ] = Statistics.Get_Mean(); s[id_DifMean ] = m_pGrid->asDouble(x, y) - Statistics.Get_Mean(); s[id_Min ] = Statistics.Get_Minimum(); s[id_Max ] = Statistics.Get_Maximum(); s[id_Range ] = Statistics.Get_Range(); s[id_Var ] = Statistics.Get_Variance(); s[id_StdDev ] = Statistics.Get_StdDev(); s[id_StdDevLo] = Statistics.Get_Mean() - Statistics.Get_StdDev(); s[id_StdDevHi] = Statistics.Get_Mean() + Statistics.Get_StdDev(); s[id_DevMean ] = Statistics.Get_StdDev() > 0.0 ? ((z - Statistics.Get_Mean()) / Statistics.Get_StdDev()) : 0.0; s[id_Percent ] = 100.0 * nLower / (double)Statistics.Get_Count(); return( true ); } } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_grid/grid_autocorrelation.cpp0000664000175000017500000001633712565125413030360 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_autocorrelation.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // grid_autocorrelastion.cpp // // // // Copyright (C) 2010 by // // Jan Papmeier // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_autocorrelation.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Autocorrelation::CGrid_Autocorrelation(void) { //----------------------------------------------------- Set_Name (_TL("Global Moran's I for Grids")); Set_Author (SG_T("Jan Papmeier (c) 2010")); Set_Description (_TW( "Global spatial autocorrelation for grids calculated as Moran's I.\n" "\n" "References:\n" "- Lloyd, C.D. (2010): Spatial data analysis - An introduction for GIS users. Oxford. 206p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL, "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL, "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL, "CONTIGUITY" , _TL("Case of contiguity"), _TL("Choose case: Rook's case contiguity compares only cell wich share an edge. Queen's case contiguity compares also cells which share just corners."), CSG_String::Format(SG_T("%s|%s|"), _TL("Rook"), _TL("Queen") ), 1 ); Parameters.Add_Value( NULL, "DIALOG" , _TL("Show Result in Dialog"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Autocorrelation::On_Execute(void) { int nContiguity, nNeighbours; double Sum; CSG_Grid *pGrid; CSG_Table *pResult; //----------------------------------------------------- pGrid = Parameters("GRID") ->asGrid(); pResult = Parameters("RESULT") ->asTable(); switch( Parameters("CONTIGUITY")->asInt() ) { case 0: nContiguity = 2; break; // Rook's case case 1: default: nContiguity = 1; break; // Queen's case } //----------------------------------------------------- nNeighbours = 0; Sum = 0.0; for(int y=0; yis_NoData(x, y) ) { double dz = pGrid->asDouble(x, y) - pGrid->Get_Mean(); for(int i=0; i<8; i+=nContiguity) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( pGrid->is_InGrid(ix, iy) ) { nNeighbours ++; Sum += dz * (pGrid->asDouble(ix, iy) - pGrid->Get_Mean()); } } } } } //----------------------------------------------------- if( nNeighbours <= 1 ) { Message_Add(_TL("not enough neighbours")); return( false ); } //----------------------------------------------------- double Moran_I = (pGrid->Get_NCells() * Sum) / (pGrid->Get_Variance() * pGrid->Get_NCells() * nNeighbours); if( pResult->Get_Field_Count() != 8 || SG_STR_CMP(_TL("Moran's I"), pResult->Get_Name()) ) { pResult->Destroy(); pResult->Set_Name(_TL("Moran's I")); pResult->Add_Field(_TL("GRID") , SG_DATATYPE_String); pResult->Add_Field(_TL("CONTIGUITY"), SG_DATATYPE_String); pResult->Add_Field(_TL("MORAN_I") , SG_DATATYPE_Double); pResult->Add_Field(_TL("NEIGHBORS") , SG_DATATYPE_Int); pResult->Add_Field(_TL("NCELLS") , SG_DATATYPE_Int); pResult->Add_Field(_TL("MEAN") , SG_DATATYPE_Double); pResult->Add_Field(_TL("VARIATION") , SG_DATATYPE_Double); pResult->Add_Field(_TL("SUM") , SG_DATATYPE_Double); } CSG_Table_Record *pRecord = pResult->Add_Record(); pRecord->Set_Value(0, pGrid->Get_Name()); pRecord->Set_Value(1, nContiguity == 2 ? _TL("Rook's case") : _TL("Queen's case")); pRecord->Set_Value(2, Moran_I); pRecord->Set_Value(3, nNeighbours); pRecord->Set_Value(4, pGrid->Get_NCells()); pRecord->Set_Value(5, pGrid->Get_Mean()); pRecord->Set_Value(6, pGrid->Get_Variance() * pGrid->Get_NCells()); pRecord->Set_Value(7, Sum); Message_Add(CSG_String::Format(SG_T("\n%s (%s): %f\n"), _TL("Moran's I"), pGrid->Get_Name(), Moran_I), false); if( Parameters("DIALOG")->asBool() ) { Message_Dlg(CSG_String::Format(SG_T("%s: %f"), _TL("Moran's I"), Moran_I), pGrid->Get_Name()); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Variance_Radius.h0000664000175000017500000001121412565125413030031 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Variance_Radius.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // GSGrid_Variance_Radius.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GSGrid_Variance_Radius_H #define HEADER_INCLUDED__GSGrid_Variance_Radius_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGSGrid_Variance_Radius : public CSG_Module_Grid { public: CGSGrid_Variance_Radius(void); virtual ~CGSGrid_Variance_Radius(void); protected: virtual bool On_Execute (void); private: bool bWriteGridsize; int **Check, maxRadius; double stopVariance; CSG_Grid *pGrid, *pResult, *pInput, *pInputQ; void Initialize (void); void Finalize (void); double Get_Radius (int xPoint, int yPoint); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GSGrid_Variance_Radius_H saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Zonal_Statistics.cpp0000664000175000017500000005021712565125413030630 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Zonal_Statistics.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: reklovw@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 categorical grids (e.g. " "landcover, soil, ...). It is possible to calculate descriptive statistics (n, 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.\n\n" "The module has four different modes of operation:\n" "(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.\n" "(2) a zonal grid and additional categorical grids are used as " "input. This results in a contingency table with the number of cells in each UCU.\n" "(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.\n" "(4) a zonal grid, additional categorical 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 operation, the output table contains information about the categorical " "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" "" "" "" "" "
    ID ZoneID 1stCatID 2ndCatCount UCUN 1stContMIN 1stContMAX 1stContMEAN 1stContSTDDEV 1stContSUM 1stCont
    0 2 6 6 6 708.5 862.0 734.5 62.5 4406.8
    0 3 4 106 106 829.1 910.1 848.8 28.5 89969.0
    " )); Parameters.Add_Grid( NULL, "ZONES" , _TL("Zone Grid"), _TL("Grid defining the zones to analyse. This grid also acts as a mask. Coding: NoData / categorial values."), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL, "CATLIST" , _TL("Categorical Grids"), _TL("Grids used to delineate the UCUs. Coding: NoData / categorical 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: NoData / 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) CSG_String sTabName = Parameters("OUTTAB")->asString(); if (pOutTab != NULL) { pOutTab->Destroy(); pOutTab->Set_Name(sTabName); } newZone = new CList_Conti(); // create first list entry (dummy) startList = newZone; for(y=0; yasInt(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; iGridsub == 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; iGridstats == 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->n += 1; 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->n += 1; 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; iGridasGrid(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 UCU", SG_DATATYPE_Int); for( iGrid=0; iGridasGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.')); fieldName = tmpName; if (bShortNames && fieldName.Length()+1 > 10) fieldName.Remove(9, fieldName.Length()-9); pOutTab->Add_Field(CSG_String::Format(SG_T("%sN") , fieldName.c_str()), SG_DATATYPE_Int); 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()+1 > 10) fieldName.Remove(9, fieldName.Length()-9); pOutTab->Add_Field(CSG_String::Format(SG_T("%sN") , fieldName.c_str()), SG_DATATYPE_Int); 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); } int iStatFields = 6; // number of table fields: n, min, max, mean, stddev, sum 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; iGridstats; else runStats = runStats->next; pRecord->Set_Value(catLevel+2+iGrid*iStatFields, runStats->n); pRecord->Set_Value(catLevel+3+iGrid*iStatFields, runStats->min); pRecord->Set_Value(catLevel+4+iGrid*iStatFields, runStats->max); pRecord->Set_Value(catLevel+5+iGrid*iStatFields, runStats->sum/runStats->n); pRecord->Set_Value(catLevel+6+iGrid*iStatFields, sqrt((runStats->dev - runStats->n*pow(runStats->sum/runStats->n, 2)) / (runStats->n - 1))); // sample //pRecord->Set_Value(catLevel+6+iGrid*iStatFields, sqrt((runStats->dev - pow(runStats->sum/runStats->n, 2)) / runStats->n)); // population pRecord->Set_Value(catLevel+7+iGrid*iStatFields, runStats->sum); } if( pAspect != NULL ) { iGrid = nStatGrids * iStatFields; int n; double min, max, sumYcomp, sumXcomp, val, valYcomp, valXcomp; if( nStatGrids == 0 ) runStats = runSub->stats; else runStats = runStats->next; n = runStats->n; min = runStats->min; max = runStats->max; sumXcomp = runStats->sum; runStats = runStats->next; sumYcomp = runStats->sum; pRecord ->Set_Value(catLevel+2+iGrid, n); pRecord ->Set_Value(catLevel+3+iGrid, min*M_RAD_TO_DEG); pRecord ->Set_Value(catLevel+4+iGrid, max*M_RAD_TO_DEG); valXcomp = sumXcomp / n; valYcomp = sumYcomp / n; 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+5+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); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_grid/Makefile.in0000664000175000017500000005746512622651174025513 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/statistics/statistics_grid DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libstatistics_grid_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libstatistics_grid_la_OBJECTS = fast_representativeness.lo \ grid_autocorrelation.lo grid_latlon_statistics.lo grid_pca.lo \ multiband_variation.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 libstatistics_grid_la_OBJECTS = $(am_libstatistics_grid_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libstatistics_grid_la_SOURCES) DIST_SOURCES = $(libstatistics_grid_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1554 2012-12-05 18:29:04Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libstatistics_grid.la libstatistics_grid_la_SOURCES = \ fast_representativeness.cpp\ grid_autocorrelation.cpp\ grid_latlon_statistics.cpp\ grid_pca.cpp\ multiband_variation.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\ fast_representativeness.h\ grid_autocorrelation.h\ grid_latlon_statistics.h\ grid_pca.h\ multiband_variation.h\ GSGrid_Directional_Statistics.h\ GSGrid_Residuals.h\ GSGrid_Statistics.h\ GSGrid_Variance.h\ GSGrid_Variance_Radius.h\ GSGrid_Zonal_Statistics.h\ MLB_Interface.h libstatistics_grid_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) --foreign src/modules/statistics/statistics_grid/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/statistics/statistics_grid/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libstatistics_grid.la: $(libstatistics_grid_la_OBJECTS) $(libstatistics_grid_la_DEPENDENCIES) $(EXTRA_libstatistics_grid_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libstatistics_grid_la_OBJECTS) $(libstatistics_grid_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSGrid_Directional_Statistics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSGrid_Residuals.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSGrid_Statistics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSGrid_Variance.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSGrid_Variance_Radius.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSGrid_Zonal_Statistics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fast_representativeness.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_autocorrelation.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_latlon_statistics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_pca.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multiband_variation.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/statistics/statistics_grid/grid_latlon_statistics.cpp0000664000175000017500000001670012565125413030703 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_latlon_statistics.cpp 1252 2011-12-15 15:43:13Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // grid_latlon_statistics.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_latlon_statistics.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Statistics_Latitudinal::CGrid_Statistics_Latitudinal(void) { //----------------------------------------------------- Set_Name (_TL("Longitudinal Grid Statistics")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "STATS" , _TL("Latitudinal Statistics"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Statistics_Latitudinal::On_Execute(void) { CSG_Grid *pGrid = Parameters("GRID" )->asGrid(); CSG_Table *pTable = Parameters("STATS")->asTable(); pTable->Destroy(); pTable->Set_Name(CSG_String::Format(SG_T("%s [%s]"), _TL("Latitudinal Statistics"), pGrid->Get_Name())); pTable->Add_Field(SG_T("Y" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("MEAN" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("MIN" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("MAX" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("STDDEV"), SG_DATATYPE_Double); for(int y=0; yasDouble(x, y); } CSG_Table_Record *pRecord = pTable->Add_Record(); pRecord->Set_Value(0, pGrid->Get_System().Get_yGrid_to_World(y)); pRecord->Set_Value(1, Statistics.Get_Mean ()); pRecord->Set_Value(2, Statistics.Get_Minimum()); pRecord->Set_Value(3, Statistics.Get_Maximum()); pRecord->Set_Value(4, Statistics.Get_StdDev ()); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Statistics_Meridional::CGrid_Statistics_Meridional(void) { //----------------------------------------------------- Set_Name (_TL("Meridional Grid Statistics")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "STATS" , _TL("Meridional Statistics"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Statistics_Meridional::On_Execute(void) { CSG_Grid *pGrid = Parameters("GRID" )->asGrid(); CSG_Table *pTable = Parameters("STATS")->asTable(); pTable->Destroy(); pTable->Set_Name(CSG_String::Format(SG_T("%s [%s]"), _TL("Meridional Statistics"), pGrid->Get_Name())); pTable->Add_Field(SG_T("X" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("MEAN" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("MIN" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("MAX" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("STDDEV"), SG_DATATYPE_Double); for(int x=0; xasDouble(x, y); } CSG_Table_Record *pRecord = pTable->Add_Record(); pRecord->Set_Value(0, pGrid->Get_System().Get_xGrid_to_World(x)); pRecord->Set_Value(1, Statistics.Get_Mean ()); pRecord->Set_Value(2, Statistics.Get_Minimum()); pRecord->Set_Value(3, Statistics.Get_Maximum()); pRecord->Set_Value(4, Statistics.Get_StdDev ()); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_grid/multiband_variation.h0000664000175000017500000001102612565125413027627 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: multiband_variation.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // multiband_variation.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__multiband_variation_H #define HEADER_INCLUDED__multiband_variation_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMultiBand_Variation : public CSG_Module_Grid { public: CMultiBand_Variation(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Grid_Cell_Addressor m_Cells; CSG_Parameter_Grid_List *m_pBands; CSG_Grid m_Mask, *m_pMean, *m_pStdDev, *m_pDiff; bool Get_Variation (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__multiband_variation_H saga-2.2.3/src/modules/statistics/statistics_grid/grid_latlon_statistics.h0000664000175000017500000001142012565125413030342 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_latlon_statistics.h 1252 2011-12-15 15:43:13Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // grid_latlon_statistics.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_latlon_statistics_H #define HEADER_INCLUDED__grid_latlon_statistics_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Statistics_Latitudinal : public CSG_Module_Grid { public: CGrid_Statistics_Latitudinal(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Statistics_Meridional : public CSG_Module_Grid { public: CGrid_Statistics_Meridional(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_latlon_statistics_H saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Statistics.cpp0000664000175000017500000003670312565125413027471 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Statistics.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // GSGrid_Statistics.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "GSGrid_Statistics.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGSGrid_Statistics::CGSGrid_Statistics(void) { Set_Name (_TL("Statistics for Grids")); Set_Author (SG_T("O.Conrad (c) 2005")); Set_Description (_TW( "Calculates statistical properties (arithmetic mean, minimum, maximum, " "variance, standard deviation) for each cell position for the values of " "the selected grids." )); Parameters.Add_Grid_List( NULL, "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid(NULL, "MEAN" , _TL("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, "SUM" , _TL("Sum") , _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, "PCTL" , _TL("Percentile") , _TL(""), PARAMETER_OUTPUT_OPTIONAL); Parameters.Add_Value( NULL, "PCTL_VAL", _TL("Percentile"), _TL(""), PARAMETER_TYPE_Double, 50.0, 0.0, true, 100.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGSGrid_Statistics::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("PCTL")) ) { pParameters->Get_Parameter("PCTL_VAL")->Set_Enabled(pParameter->asGrid() != NULL); } return( 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGSGrid_Statistics::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); if( pGrids->Get_Count() <= 1 ) { Error_Set(_TL("no grids in selection")); return( false ); } //----------------------------------------------------- CSG_Grid *pMean = Parameters("MEAN" )->asGrid(); CSG_Grid *pMin = Parameters("MIN" )->asGrid(); CSG_Grid *pMax = Parameters("MAX" )->asGrid(); CSG_Grid *pRange = Parameters("RANGE" )->asGrid(); CSG_Grid *pSum = Parameters("SUM" )->asGrid(); CSG_Grid *pVar = Parameters("VAR" )->asGrid(); CSG_Grid *pStdDev = Parameters("STDDEV" )->asGrid(); CSG_Grid *pStdDevLo = Parameters("STDDEVLO")->asGrid(); CSG_Grid *pStdDevHi = Parameters("STDDEVHI")->asGrid(); CSG_Grid *pPercentile = Parameters("PCTL" )->asGrid(); if( !pMean && !pMin && !pMax && !pRange && !pSum && !pVar && !pStdDev && !pStdDevLo && !pStdDevHi && !pPercentile ) { Error_Set(_TL("no parameter output specified")); return( false ); } double dRank = Parameters("PCTL_VAL")->asDouble() / 100.0; //----------------------------------------------------- for(int y=0; yGet_Count(); i++) { if( !pGrids->asGrid(i)->is_NoData(x, y) ) { double z = pGrids->asGrid(i)->asDouble(x, y); s.Add_Value(z); if( pPercentile ) { if( Values.Get_Field_Count() == 0 ) { Values.Add_Field("Z", SG_DATATYPE_Double); } Values.Add_Record()->Set_Value(0, z); } } } //----------------------------------------- if( s.Get_Count() <= 0 ) { if( pMean ) pMean ->Set_NoData(x, y); if( pMin ) pMin ->Set_NoData(x, y); if( pMax ) pMax ->Set_NoData(x, y); if( pRange ) pRange ->Set_NoData(x, y); if( pSum ) pSum ->Set_NoData(x, y); if( pVar ) pVar ->Set_NoData(x, y); if( pStdDev ) pStdDev ->Set_NoData(x, y); if( pStdDevLo ) pStdDevLo ->Set_NoData(x, y); if( pStdDevHi ) pStdDevHi ->Set_NoData(x, y); if( pPercentile ) pPercentile ->Set_NoData(x, y); } else { if( pMean ) pMean ->Set_Value(x, y, s.Get_Mean()); if( pMin ) pMin ->Set_Value(x, y, s.Get_Minimum()); if( pMax ) pMax ->Set_Value(x, y, s.Get_Maximum()); if( pRange ) pRange ->Set_Value(x, y, s.Get_Range()); if( pSum ) pSum ->Set_Value(x, y, s.Get_Sum()); if( pVar ) pVar ->Set_Value(x, y, s.Get_Variance()); if( pStdDev ) pStdDev ->Set_Value(x, y, s.Get_StdDev()); if( pStdDevLo ) pStdDevLo ->Set_Value(x, y, s.Get_Mean() - s.Get_StdDev()); if( pStdDevHi ) pStdDevHi ->Set_Value(x, y, s.Get_Mean() + s.Get_StdDev()); if( pPercentile ) { Values.Set_Index(0, TABLE_INDEX_Ascending); pPercentile->Set_Value(x, y, Values.Get_Record_byIndex((int)(dRank * s.Get_Count()))->asDouble(0)); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGSGrid_Statistics_To_Table::CGSGrid_Statistics_To_Table(void) { Set_Name (_TL("Save Grid Statistics to Table")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Calculates statistical properties (arithmetic mean, minimum, maximum, " "variance, standard deviation) for each of the given grids and saves " "it to a table." )); Parameters.Add_Grid_List( NULL, "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL, "STATS" , _TL("Statistics for Grids"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value(NULL, "DATA_CELLS" , _TL("Number of Data Cells") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "NODATA_CELLS", _TL("Number of No-Data Cells") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "CELLSIZE" , _TL("Cellsize") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "MEAN" , _TL("Arithmetic Mean") , _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(NULL, "MIN" , _TL("Minimum") , _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(NULL, "MAX" , _TL("Maximum") , _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(NULL, "RANGE" , _TL("Range") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "VAR" , _TL("Variance") , _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(NULL, "STDDEV" , _TL("Standard Deviation") , _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(NULL, "STDDEVLO" , _TL("Mean less Standard Deviation"), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "STDDEVHI" , _TL("Mean plus Standard Deviation"), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "PCTL" , _TL("Percentile") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value( NULL, "PCTL_VAL", _TL("Percentile"), _TL(""), PARAMETER_TYPE_Double, 50.0, 0.0, true, 100.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGSGrid_Statistics_To_Table::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("PCTL")) ) { pParameters->Get_Parameter("PCTL_VAL")->Set_Enabled(pParameter->asBool()); } return( 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGSGrid_Statistics_To_Table::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); if( pGrids->Get_Count() < 1 ) { Error_Set(_TL("no grids in selection")); return( false ); } //----------------------------------------------------- CSG_Table *pTable = Parameters("STATS")->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("Statistics for Grids")); pTable->Add_Field(_TL("NAME"), SG_DATATYPE_String); if( Parameters("DATA_CELLS" )->asBool() ) pTable->Add_Field(_TL("DATA_CELLS" ), SG_DATATYPE_Int); if( Parameters("NODATA_CELLS")->asBool() ) pTable->Add_Field(_TL("NODATA_CELLS"), SG_DATATYPE_Int); if( Parameters("CELLSIZE" )->asBool() ) pTable->Add_Field(_TL("CELLSIZE" ), SG_DATATYPE_Double); if( Parameters("MEAN" )->asBool() ) pTable->Add_Field(_TL("MEAN" ), SG_DATATYPE_Double); if( Parameters("MIN" )->asBool() ) pTable->Add_Field(_TL("MIN" ), SG_DATATYPE_Double); if( Parameters("MAX" )->asBool() ) pTable->Add_Field(_TL("MAX" ), SG_DATATYPE_Double); if( Parameters("RANGE" )->asBool() ) pTable->Add_Field(_TL("RANGE" ), SG_DATATYPE_Double); if( Parameters("VAR" )->asBool() ) pTable->Add_Field(_TL("VAR" ), SG_DATATYPE_Double); if( Parameters("STDDEV" )->asBool() ) pTable->Add_Field(_TL("STDDEV" ), SG_DATATYPE_Double); if( Parameters("STDDEVLO" )->asBool() ) pTable->Add_Field(_TL("STDDEVLO" ), SG_DATATYPE_Double); if( Parameters("STDDEVHI" )->asBool() ) pTable->Add_Field(_TL("STDDEVHI" ), SG_DATATYPE_Double); if( Parameters("PCTL" )->asBool() ) pTable->Add_Field(_TL("PCTL" ), SG_DATATYPE_Double); if( pTable->Get_Field_Count() <= 1 ) { Error_Set(_TL("no parameter output specified")); return( false ); } double dRank = Parameters("PCTL")->asBool() ? Parameters("PCTL_VAL")->asDouble() : -1.0; //----------------------------------------------------- for(int i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Grid *pGrid = pGrids->asGrid(i); CSG_Table_Record *pRecord = pTable->Add_Record(); pRecord->Set_Value("NAME" , pGrid->Get_Name()); pRecord->Set_Value("DATA_CELLS" , pGrid->Get_NCells() - pGrid->Get_NoData_Count()); pRecord->Set_Value("NODATA_CELLS", pGrid->Get_NoData_Count()); pRecord->Set_Value("CELLSIZE" , pGrid->Get_Cellsize()); pRecord->Set_Value("MEAN" , pGrid->Get_Mean()); pRecord->Set_Value("MIN" , pGrid->Get_ZMin()); pRecord->Set_Value("MAX" , pGrid->Get_ZMax()); pRecord->Set_Value("RANGE" , pGrid->Get_ZRange()); pRecord->Set_Value("VAR" , pGrid->Get_Variance()); pRecord->Set_Value("STDDEV" , pGrid->Get_StdDev()); pRecord->Set_Value("STDDEVLO" , pGrid->Get_Mean() - pGrid->Get_StdDev()); pRecord->Set_Value("STDDEVHI" , pGrid->Get_Mean() + pGrid->Get_StdDev()); if( dRank > 0.0 && dRank < 100.0 ) { pRecord->Set_Value("PCTL", pGrid->Get_Percentile(dRank)); // this is a time consuming operation } } if( dRank > 0.0 && dRank < 100.0 ) { pTable->Set_Field_Name(pTable->Get_Field_Count() - 1, CSG_String::Format(SG_T("%s%02d"), _TL("PCTL"), (int)dRank)); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_grid/fast_representativeness.cpp0000664000175000017500000003522212565125413031101 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: fast_representativeness.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@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, " "pdf\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; sLong i; sLong 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 (yGet_NY() && x < pOrgInput->Get_NX()) Pow2Grid->Set_Value(x, y, pOrgInput->asFloat(x, y)); else { if(x >= pOrgInput->Get_NX()&&yGet_NY()) Pow2Grid->Set_Value(x, y,pOrgInput->asFloat(2*pOrgInput->Get_NX()-x-1, y)); if(y >= pOrgInput->Get_NY()&& xGet_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->Standardise(); 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; sLong 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); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_grid/fast_representativeness.h0000664000175000017500000001062112565125413030542 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: fast_representativeness.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@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 saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Residuals.h0000664000175000017500000001126312565125413026731 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Residuals.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // GSGrid_Residuals.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GSGrid_Residuals_H #define HEADER_INCLUDED__GSGrid_Residuals_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGSGrid_Residuals : public CSG_Module_Grid { public: CGSGrid_Residuals(void); protected: virtual bool On_Execute (void); private: CSG_Grid_Cell_Addressor m_Cells; CSG_Grid *m_pGrid, *m_pMean, *m_pDiff, *m_pStdDev, *m_pRange, *m_pMin, *m_pMax, *m_pDevMean, *m_pPercent; bool Get_Statistics (int x, int y, bool bCenter); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GSGrid_Residuals_H saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Variance_Radius.cpp0000664000175000017500000002256412565125413030376 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Variance_Radius.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // GSGrid_Variance_Radius.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "GSGrid_Variance_Radius.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGSGrid_Variance_Radius::CGSGrid_Variance_Radius(void) { Set_Name (_TL("Radius of Variance (Grid)")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Find the radius within which the cell values exceed the given variance criterium. " "This module is closely related to the representativeness calculation " "(variance within given search radius). " "For easier usage, the variance criterium is entered as standard deviation value. " )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "INPUT" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "RESULT" , _TL("Variance Radius"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "VARIANCE" , _TL("Standard Deviation"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Maximum Search Radius (cells)"), _TL(""), PARAMETER_TYPE_Int , 20 ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Type of Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Cells"), _TL("Map Units") ), 0 ); //----------------------------------------------------- pInput = NULL; pInputQ = NULL; Check = NULL; maxRadius = 0; } //--------------------------------------------------------- CGSGrid_Variance_Radius::~CGSGrid_Variance_Radius(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGSGrid_Variance_Radius::On_Execute(void) { int x, y; //----------------------------------------------------- stopVariance = M_SQR(Parameters("VARIANCE")->asDouble()); maxRadius = Parameters("RADIUS") ->asInt(); bWriteGridsize = Parameters("OUTPUT") ->asInt() == 0; pGrid = Parameters("INPUT") ->asGrid(); pResult = Parameters("RESULT") ->asGrid(); pResult->Set_Name(CSG_String::Format(SG_T("%s >= %f"), _TL("Radius with Variance"), stopVariance)); //----------------------------------------------------- Initialize(); for(y=0; ySet_Value(x, y, Get_Radius(x, y)); } } Finalize(); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CGSGrid_Variance_Radius::Initialize(void) { int x, y; double d; //----------------------------------------------------- pInput = SG_Create_Grid(pGrid); pInputQ = SG_Create_Grid(pGrid); for(y=0; yasDouble(x,y); pInput ->Set_Value(x, y, d ); pInputQ ->Set_Value(x, y, d*d); } } //----------------------------------------------------- // Radius Check-Matrix erstellen... Check = (int **)malloc((maxRadius + 1) * sizeof(int *)); for(y=0; y<=maxRadius; y++) { Check[y] = (int *)malloc((maxRadius + 1) * sizeof(int)); for(x=0; x<=maxRadius; x++) { // Check[y][x] = (int)sqrt(x*x + y*y); Check[y][x] = (int)sqrt((x + 0.5) * (x + 0.5) + (y + 0.5) * (y + 0.5)); } } } //--------------------------------------------------------- void CGSGrid_Variance_Radius::Finalize(void) { if( pInput ) { delete(pInput); pInput = NULL; } if( pInputQ ) { delete(pInputQ); pInputQ = NULL; } if( Check ) { for(int y=0; y<=maxRadius; y++) { free(Check[y]); } free(Check); Check = NULL; maxRadius = 0; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CGSGrid_Variance_Radius::Get_Radius(int xPoint, int yPoint) { const double sqrt2 = 1.0 / sqrt(2.0); int x, y, dx, dy, sRadius, Radius = 0, nValues = 0; double ArithMean, Variance, Sum = 0.0, SumQ = 0.0; do { sRadius = (int)(sqrt2 * (double)Radius - 4.0); if( sRadius < 0 ) sRadius = 0; //------------------------------------------------- for(dy=sRadius; dy<=Radius; dy++) { for(dx=sRadius; dx<=Radius; dx++) { if(Check[dy][dx] == Radius) { y = yPoint - dy; if(y>=0) { x = xPoint - dx; if(x>=0) { Sum += pInput->asDouble(x,y); SumQ += pInputQ->asDouble(x,y); nValues++; } x = xPoint + dx; if(xasDouble(x,y); SumQ += pInputQ->asDouble(x,y); nValues++; } } y = yPoint + dy; if(y=0) { Sum += pInput->asDouble(x,y); SumQ += pInputQ->asDouble(x,y); nValues++; } x = xPoint + dx; if(xasDouble(x,y); SumQ += pInputQ->asDouble(x,y); nValues++; } } } } } //------------------------------------------------- if(nValues) { ArithMean = Sum / nValues; Variance = SumQ / nValues - ArithMean * ArithMean; // Andre, das ist die Formel aus deinem Buch... // Variance = (SumQ - nValues * ArithMean * ArithMean) / nValues; } else Variance = 0; Radius++; } while(Variance < stopVariance && Radius <= maxRadius); return( bWriteGridsize ? Radius : Radius * Get_Cellsize() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_grid/multiband_variation.cpp0000664000175000017500000002126012565125413030163 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: multiband_variation.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // multiband_variation.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "multiband_variation.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMultiBand_Variation::CMultiBand_Variation(void) { Set_Name (_TL("Multi-Band Variation")); Set_Author ("O.Conrad (c) 2010"); Set_Description (_TW( "Calculates for each cell the spectral variation based on feature space distances " "to the centroid for all cells in specified neighbourhood. " "The average distance has been used for Spectral Variation Hypothesis (SVH).\n" "\nReferences:\n" "- Palmer, M.W., Earls, P., Hoagland, B.W., White, P.S., Wohlgemuth, T. (2002): " "Quantitative tools for perfecting species lists. Environmetrics 13, 121–137.\n" )); Parameters.Add_Grid_List( NULL , "BANDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "MEAN" , _TL("Mean Distance"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "STDDEV" , _TL("Standard Deviation"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "DIFF" , _TL("Distance"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Radius [Cells]"), _TL(""), PARAMETER_TYPE_Int, 1.0, 1.0, true ); m_Cells.Get_Weighting().Create_Parameters(&Parameters, false); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CMultiBand_Variation::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( m_Cells.Get_Weighting().Enable_Parameters(pParameters) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMultiBand_Variation::On_Execute(void) { //----------------------------------------------------- m_pBands = Parameters("BANDS" )->asGridList(); m_pMean = Parameters("MEAN" )->asGrid(); m_pStdDev = Parameters("STDDEV")->asGrid(); m_pDiff = Parameters("DIFF" )->asGrid(); //----------------------------------------------------- if( m_pBands->Get_Count() < 1 ) { Error_Set(_TL("no input")); return( false ); } //----------------------------------------------------- m_Cells.Get_Weighting().Set_Parameters(&Parameters); if( !m_Cells.Set_Radius(Parameters("RADIUS")->asInt()) ) { Error_Set(_TL("failed to set radius")); return( false ); } //----------------------------------------------------- int x, y; m_Mask.Create(*Get_System(), SG_DATATYPE_Byte); m_Mask.Set_NoData_Value(0); for(y=0; yGet_Count() && !bNoData; iBand++) { if( m_pBands->asGrid(iBand)->is_NoData(x, y) ) { bNoData = true; } } m_Mask.Set_Value(x, y, bNoData ? 0 : 1); } } //----------------------------------------------------- for(y=0; yGet_Count()); //------------------------------------------------- for(iCell=0, Weights=0.0; iCellGet_Count(); iBand++) { Centroid[iBand] += iWeight * m_pBands->asGrid(iBand)->asDouble(ix, iy); } Weights += iWeight; } } //------------------------------------------------- if( Weights > 0.0 ) { CSG_Simple_Statistics s; Centroid *= 1.0 / Weights; for(iCell=0; iCellGet_Count(); iBand++) { Distance += SG_Get_Square(Centroid[iBand] - m_pBands->asGrid(iBand)->asDouble(ix, iy)); } s.Add_Value(sqrt(Distance), iWeight); if( ix == x && iy == y ) { if( m_pDiff ) m_pDiff->Set_Value(x, y, sqrt(Distance)); } } } if( m_pMean ) m_pMean ->Set_Value(x, y, s.Get_Mean()); if( m_pStdDev ) m_pStdDev->Set_Value(x, y, s.Get_StdDev()); return( true ); } } //----------------------------------------------------- if( m_pMean ) m_pMean ->Set_NoData(x, y); if( m_pStdDev ) m_pStdDev ->Set_NoData(x, y); if( m_pDiff ) m_pDiff ->Set_NoData(x, y); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Residuals.cpp0000664000175000017500000002236612634252545027276 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Residuals.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_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 (Cells)") , _TL(""), PARAMETER_TYPE_Int, 7, 1, true); Parameters.Add_Value( NULL, "BCENTER" , _TL("Include Center Cell") , _TL(""), PARAMETER_TYPE_Bool, 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); //----------------------------------------------------- bool bSquare = Parameters("MODE")->asBool() ? false : true; m_Cells.Get_Weighting().Set_Parameters(Parameters("WEIGHTING")->asParameters()); if( !m_Cells.Set_Radius(Parameters("RADIUS")->asInt(), bSquare) ) { return( false ); } bool bCenter = Parameters("BCENTER")->asBool(); //----------------------------------------------------- for(int y=0; yis_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 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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/statistics/statistics_grid/MLB_Interface.cpp0000664000175000017500000001310112565125413026515 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Grids") ); case MLB_INFO_Category: return( _TL("Spatial and Geostatistics") ); case MLB_INFO_Author: return( SG_T("O.Conrad, V.Wichmann (c) 2002-10" )); case MLB_INFO_Description: return( _TL("Tools for spatial and geostatistical analyses.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Spatial and Geostatistics|Grids") ); } } //--------------------------------------------------------- // 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_Statistics.h" #include "GSGrid_Zonal_Statistics.h" #include "GSGrid_Directional_Statistics.h" #include "grid_autocorrelation.h" #include "grid_pca.h" #include "multiband_variation.h" #include "grid_latlon_statistics.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { 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 ); case 7: return( new CGrid_Autocorrelation ); case 8: return( new CGrid_PCA ); case 9: return( new CMultiBand_Variation ); case 10: return( new CGrid_PCA_Inverse ); case 11: return( new CGrid_Statistics_Latitudinal ); case 12: return( new CGrid_Statistics_Meridional ); case 13: return( new CGSGrid_Statistics_To_Table ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/statistics/statistics_grid/Makefile.am0000664000175000017500000000215612565125413025463 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1554 2012-12-05 18:29:04Z oconrad $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libstatistics_grid.la libstatistics_grid_la_SOURCES =\ fast_representativeness.cpp\ grid_autocorrelation.cpp\ grid_latlon_statistics.cpp\ grid_pca.cpp\ multiband_variation.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\ fast_representativeness.h\ grid_autocorrelation.h\ grid_latlon_statistics.h\ grid_pca.h\ multiband_variation.h\ GSGrid_Directional_Statistics.h\ GSGrid_Residuals.h\ GSGrid_Statistics.h\ GSGrid_Variance.h\ GSGrid_Variance_Radius.h\ GSGrid_Zonal_Statistics.h\ MLB_Interface.h libstatistics_grid_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/statistics/statistics_grid/MLB_Interface.h0000664000175000017500000000743212565125413026174 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__statistics_grid_H #define HEADER_INCLUDED__statistics_grid_H //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__statistics_grid_H saga-2.2.3/src/modules/statistics/statistics_grid/GSGrid_Zonal_Statistics.h0000664000175000017500000001250212565125413030270 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GSGrid_Zonal_Statistics.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics_grid // // // //-------------------------------------------------------// // // // GSGrid_Zonal_Statistics.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: volkerwichmann@web.de // // // // contact: Volker Wichmann // // Research Associate // // Chair of Physical Geography // // KU Eichstaett-Ingolstadt // // Ostenstr. 18 // // 85072 Eichstaett // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GSGrid_Zonal_Statistics_H #define HEADER_INCLUDED__GSGrid_Zonal_Statistics_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CList_Stat { public: CList_Stat(void) { n = 0; min = max = 0.0; sum = dev = 0.0; next = NULL; dummy = true; }; ~CList_Stat(void) { if( next != NULL ) delete(next); next = NULL; }; int n; double min, max, sum, dev; bool dummy; CList_Stat *next; }; //--------------------------------------------------------- class CList_Conti { public: CList_Conti(void) { cat = 0; count = 0; next = NULL; previous = NULL; parent = NULL; sub = NULL; stats = NULL; dummy = true; }; ~CList_Conti(void) { if( stats != NULL ) delete(stats); if( sub != NULL ) delete(sub); sub = NULL; if( next != NULL ) delete(next); next = NULL; }; int cat, count; bool dummy; CList_Conti *next, *previous, *parent, *sub; CList_Stat *stats; }; //--------------------------------------------------------- class CGSGrid_Zonal_Statistics : public CSG_Module_Grid { public: CGSGrid_Zonal_Statistics(void); virtual ~CGSGrid_Zonal_Statistics(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GSGrid_Zonal_Statistics_H saga-2.2.3/src/modules/climate/0000775000175000017500000000000012634325735017456 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/climate/Makefile.in0000664000175000017500000004552312622651156021530 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/climate DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 = climate_tools 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) --foreign src/modules/climate/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/climate/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/climate/climate_tools/0000775000175000017500000000000012634325736022315 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/climate/climate_tools/milankovic.h0000664000175000017500000001341512565125417024623 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: milankovic.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // milankovic.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__milankovic_H #define HEADER_INCLUDED__milankovic_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMilankovic : public CSG_Module { public: CMilankovic(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Earth's Orbital Parameters") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMilankovic_SR_Location : public CSG_Module { public: CMilankovic_SR_Location(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Earth's Orbital Parameters") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMilankovic_SR_Day_Location : public CSG_Module { public: CMilankovic_SR_Day_Location(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Earth's Orbital Parameters") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMilankovic_SR_Monthly_Global : public CSG_Module { public: CMilankovic_SR_Monthly_Global(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Earth's Orbital Parameters") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__milankovic_H saga-2.2.3/src/modules/climate/climate_tools/etp_hargreave.h0000664000175000017500000001254112565125417025302 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: etp_hargreave.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // etp_hargreave.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__etp_hargreave_H #define HEADER_INCLUDED__etp_hargreave_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPET_Hargreave_Grid : public CSG_Module_Grid { public: CPET_Hargreave_Grid(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Evapotranspiration") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPET_Hargreave_Table : public CSG_Module { public: CPET_Hargreave_Table(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Evapotranspiration") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPET_Day_To_Hour : public CSG_Module { public: CPET_Day_To_Hour(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Evapotranspiration") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__etp_hargreave_H saga-2.2.3/src/modules/climate/climate_tools/grid_levels_interpolation.cpp0000664000175000017500000005516112565125417030274 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Level_Interpolation.cpp 1380 2012-04-26 12:02:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // Grid_Level_Interpolation.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_levels_interpolation.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Levels_Interpolation::CGrid_Levels_Interpolation(void) { //----------------------------------------------------- Set_Author (SG_T("O.Conrad (c) 2012")); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "VARIABLE" , _TL("Variable"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Choice( NULL , "X_SOURCE" , _TL("Get Heights from ..."), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("table"), _TL("grid list") ), 1 ); Parameters.Add_Grid_List( NULL , "X_GRIDS" , _TL("Level Heights"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "X_GRIDS_CHECK" , _TL("Minimum Height"), _TL("if set, only values with level heights above DEM will be used"), PARAMETER_INPUT_OPTIONAL, true ); Parameters.Add_FixedTable( NULL , "X_TABLE" , _TL("Level Heights"), _TL("") )->asTable()->Add_Field(_TL("Height"), SG_DATATYPE_Double); Parameters.Add_Choice( NULL , "H_METHOD" , _TL("Horizontal Interpolation Method"), _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 , "V_METHOD" , _TL("Vertical Interpolation Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("linear"), _TL("spline"), _TL("polynomial trend"), _TL("polynomial trend (coefficient interpolation)") ), 0 ); Parameters.Add_Value( NULL , "LINEAR_SORTED" , _TL("Sorted Levels"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "SPLINE_ALL" , _TL("Pre-analyze"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "TREND_ORDER" , _TL("Polynomial Order"), _TL(""), PARAMETER_TYPE_Int, 3, 1, true ); //----------------------------------------------------- for(int i=0; i<10; i++) { Parameters("X_TABLE")->asTable()->Add_Record()->Set_Value(0, i + 1); } Add_Parameters("INTERNAL", "", ""); m_Coeff = NULL; } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_Levels_Interpolation::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("V_METHOD")) ) { pParameters->Get_Parameter("LINEAR_SORTED")->Set_Enabled(pParameter->asInt() == 0); pParameters->Get_Parameter("SPLINE_ALL" )->Set_Enabled(pParameter->asInt() == 1); pParameters->Get_Parameter("TREND_ORDER" )->Set_Enabled(pParameter->asInt() >= 2); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("X_SOURCE")) ) { pParameters->Get_Parameter("X_TABLE" )->Set_Enabled(pParameter->asInt() == 0); pParameters->Get_Parameter("X_GRIDS" )->Set_Enabled(pParameter->asInt() == 1); pParameters->Get_Parameter("X_GRIDS_CHECK")->Set_Enabled(pParameter->asInt() == 1); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Initialize(const CSG_Rect &Extent) { //----------------------------------------------------- m_pVariables = Parameters("VARIABLE" )->asGridList(); m_pXGrids = Parameters("X_GRIDS" )->asGridList(); m_pXTable = Parameters("X_TABLE" )->asTable(); m_xSource = Parameters("X_SOURCE" )->asInt(); m_hMethod = Parameters("H_METHOD" )->asInt(); m_vMethod = Parameters("V_METHOD" )->asInt(); m_Linear_bSorted = Parameters("LINEAR_SORTED")->asBool(); m_Spline_bAll = Parameters("SPLINE_ALL" )->asBool() == false; m_Trend_Order = Parameters("TREND_ORDER" )->asInt(); //----------------------------------------------------- if( m_pVariables->Get_Count() != (m_xSource == 0 ? m_pXTable->Get_Count() : m_pXGrids->Get_Count()) ) { Error_Set(_TL("variable and height levels have to be of same number")); return( false ); } if( m_vMethod == 1 && m_pVariables->Get_Count() <= m_Trend_Order ) { Error_Set(_TL("fitting a polynom of ith order needs at least i + 1 samples")); return( false ); } if( !Extent.Intersects(Get_System()->Get_Extent(true)) ) { Error_Set(_TL("target area is distinct from levels area ")); return( false ); } //----------------------------------------------------- CSG_Grid *pHeight_Min = m_xSource == 1 && Parameters("X_GRIDS_CHECK") ? Parameters("X_GRIDS_CHECK")->asGrid() : NULL; if( pHeight_Min ) { if( !Get_Parameters("INTERNAL")->Get_Parameter("X_GRIDS") ) { Get_Parameters("INTERNAL")->Add_Grid_List(NULL, "X_GRIDS", "", "", PARAMETER_INPUT_OPTIONAL); } CSG_Parameter_Grid_List *pXGrids = Get_Parameters("INTERNAL")->Get_Parameter("X_GRIDS")->asGridList(); for(int i=0; iGet_Count(); i++) { CSG_Grid *pHeight = SG_Create_Grid(*m_pXGrids->asGrid(i)); #pragma omp parallel for for(int y=0; yasDouble(x, y) < pHeight_Min->asDouble(x, y) ) { pHeight->Set_NoData(x, y); } } } pXGrids->Add_Item(pHeight); } m_pXGrids = pXGrids; } //----------------------------------------------------- if( m_vMethod == 3 ) // polynom coefficient interpolation { int i; m_Coeff = new CSG_Grid[1 + m_Trend_Order]; for(i=0; i<=m_Trend_Order; i++) { m_Coeff[i].Create(*Get_System()); } #pragma omp parallel for private(i) for(int y=0; yGet_Count(); i++) { double Height, Variable; if( Get_Height(p_x, p_y, i, Height) && Get_Variable(p_x, p_y, i, Variable) ) { Trend.Add_Data(Height, Variable); } } if( Trend.Get_Trend() ) { for(i=0; i<=m_Trend_Order; i++) { m_Coeff[i].Set_Value(x, y, Trend.Get_Coefficient(i)); } } else { for(i=0; i<=m_Trend_Order; i++) { m_Coeff[i].Set_NoData(x, y); } } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Finalize(void) { if( Get_Parameters("INTERNAL")->Get_Parameter("X_GRIDS") && Get_Parameters("INTERNAL")->Get_Parameter("X_GRIDS")->asGridList() == m_pXGrids ) { for(int i=0; iGet_Count(); i++) { delete(m_pXGrids->asGrid(i)); } m_pXGrids->Del_Items(); } if( m_Coeff ) { delete[](m_Coeff); m_Coeff = NULL; } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CGrid_Levels_Interpolation::Get_Variable(double x, double y, int iLevel) { return( m_pVariables->asGrid(iLevel)->Get_Value(x, y, m_hMethod) ); } //--------------------------------------------------------- inline bool CGrid_Levels_Interpolation::Get_Variable(double x, double y, int iLevel, double &Variable) { return( m_pVariables->asGrid(iLevel)->Get_Value(x, y, Variable, m_hMethod) ); } //--------------------------------------------------------- inline double CGrid_Levels_Interpolation::Get_Height(double x, double y, int iLevel) { if( m_xSource == 0 ) { return( m_pXTable->Get_Record(iLevel)->asDouble(0) ); } return( m_pXGrids->asGrid(iLevel)->Get_Value(x, y, m_hMethod) ); } //--------------------------------------------------------- inline bool CGrid_Levels_Interpolation::Get_Height(double x, double y, int iLevel, double &Height) { if( m_xSource == 0 ) { Height = m_pXTable->Get_Record(iLevel)->asDouble(0); return( true ); } return( m_pXGrids->asGrid(iLevel)->Get_Value(x, y, Height, m_hMethod) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Values(double x, double y, double z, int &iLevel, CSG_Table &Values) { Values.Destroy(); Values.Add_Field("h", SG_DATATYPE_Double); Values.Add_Field("v", SG_DATATYPE_Double); for(int i=0; iGet_Count(); i++) { double Height, Variable; if( Get_Height(x, y, i, Height) && Get_Variable(x, y, i, Variable) ) { CSG_Table_Record *pRecord = Values.Add_Record(); pRecord->Set_Value(0, Height); pRecord->Set_Value(1, Variable); } } if( Values.Get_Count() < 2 || !Values.Set_Index(0, TABLE_INDEX_Ascending) ) { return( false ); } for(iLevel=1; iLevel z ) { return( true ); } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CGrid_Levels_Interpolation::Get_Value(double x, double y, double z, double &Value) { switch( m_vMethod ) { default: case 0: // linear if( m_Linear_bSorted ) { return( Get_Linear_Sorted(x, y, z, Value) ); } return( Get_Linear(x, y, z, Value) ); case 1: // spline if( m_Spline_bAll ) { return( Get_Spline_All(x, y, z, Value) ); } return( Get_Spline(x, y, z, Value) ); case 2: // polynomial trend return( Get_Trend(x, y, z, Value) ); case 3: // polynomial trend (coefficient interpolation) return( Get_Trend_Coeff(x, y, z, Value) ); } } //--------------------------------------------------------- inline bool CGrid_Levels_Interpolation::Get_Value(const TSG_Point &p, double z, double &Value) { return( Get_Value(p.x, p.y, z, Value) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Linear_Sorted(double x, double y, double z, double &Value) { int iLevel; for(iLevel=1; iLevelGet_Count()-1; iLevel++) { if( Get_Height(x, y, iLevel) > z ) { break; } } //----------------------------------------------------- double z0 = Get_Height(x, y, iLevel - 1); double z1 = Get_Height(x, y, iLevel ); if( z0 < z1 ) { double v0 = Get_Variable(x, y, iLevel - 1); double v1 = Get_Variable(x, y, iLevel ); Value = v0 + (z - z0) * (v1 - v0) / (z1 - z0); return( true ); } return( false ); } //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Linear(double x, double y, double z, double &Value) { int iLevel; CSG_Table Values; if( !Get_Values(x, y, z, iLevel, Values) ) { return( false ); } //----------------------------------------------------- double z0 = Values[iLevel - 1][0]; double z1 = Values[iLevel ][0]; if( z0 < z1 ) { double v0 = Values[iLevel - 1][1]; double v1 = Values[iLevel ][1]; Value = v0 + (z - z0) * (v1 - v0) / (z1 - z0); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Spline_All(double x, double y, double z, double &Value) { CSG_Spline Spline; for(int i=0; iGet_Count(); i++) { double Height, Variable; if( Get_Height(x, y, i, Height) && Get_Variable(x, y, i, Variable) ) { Spline.Add(Height, Variable); } } if( Spline.Get_Value(z, Value) ) { return( true ); } return( false ); } //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Spline(double x, double y, double z, double &Value) { int iLevel; CSG_Table Values; if( !Get_Values(x, y, z, iLevel, Values) ) { return( false ); } if( Values.Get_Count() < 3 ) { return( Get_Linear(x, y, z, Value) ); } if( iLevel >= Values.Get_Count() - 1 ) { iLevel--; } CSG_Spline Spline; if( iLevel > 1 ) { Spline.Add(Values[iLevel - 2][0], Values[iLevel - 2][1]); } Spline.Add(Values[iLevel - 1][0], Values[iLevel - 1][1]); Spline.Add(Values[iLevel ][0], Values[iLevel ][1]); Spline.Add(Values[iLevel + 1][0], Values[iLevel + 1][1]); return( Spline.Get_Value(z, Value) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Trend(double x, double y, double z, double &Value) { CSG_Trend_Polynom Trend; Trend.Set_Order(m_Trend_Order); for(int i=0; iGet_Count(); i++) { double Height, Variable; if( Get_Height(x, y, i, Height) && Get_Variable(x, y, i, Variable) ) { Trend.Add_Data(Height, Variable); } } if( Trend.Get_Trend() ) { Value = Trend.Get_Value(z); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Trend_Coeff(double x, double y, double z, double &Value) { double Coeff, zPower = 1.0; Value = 0.0; for(int i=0; i<=m_Trend_Order; i++) { if( !m_Coeff[i].Get_Value(x, y, Coeff, m_hMethod) ) { return( false ); } Value += Coeff * zPower; zPower *= z; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Levels_to_Surface::CGrid_Levels_to_Surface(void) { //----------------------------------------------------- Set_Name (_TL("Multi Level to Surface Interpolation")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Grid_System( NULL , "SYSTEM" , _TL("Grid system"), _TL("") ); Parameters.Add_Grid( pNode , "SURFACE" , _TL("Surface"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( pNode , "RESULT" , _TL("Interpolation"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- bool CGrid_Levels_to_Surface::On_Execute(void) { //----------------------------------------------------- CSG_Grid *pSurface = Parameters("SURFACE")->asGrid(); CSG_Grid *pResult = Parameters("RESULT" )->asGrid(); if( !(pSurface->Get_System() == pResult->Get_System()) ) { Error_Set(_TL("surface and result grids have to share the same grid system")); return( false ); } if( !Initialize(pSurface->Get_Extent()) ) { Finalize(); return( false ); } //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, pSurface->Get_NY()); y++) { double p_y = pSurface->Get_YMin() + y * pSurface->Get_Cellsize(); #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double Value, p_x = pSurface->Get_XMin() + x * pSurface->Get_Cellsize(); if( !pSurface->is_NoData(x, y) && Get_Value(p_x, p_y, pSurface->asDouble(x, y), Value) ) { pResult->Set_Value(x, y, Value); } else { pResult->Set_NoData(x, y); } } } //----------------------------------------------------- Finalize(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Levels_to_Points::CGrid_Levels_to_Points(void) { //----------------------------------------------------- Set_Name (_TL("Multi Level to Points Interpolation")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "ZFIELD" , _TL("Height"), _TL("") ); Parameters.Add_Shapes( pNode , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_String( NULL , "NAME" , _TL("Field Name"), _TL(""), _TL("Variable") ); } //--------------------------------------------------------- bool CGrid_Levels_to_Points::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS")->asShapes(); if( !Initialize(pPoints->Get_Extent()) ) { Finalize(); return( false ); } //----------------------------------------------------- if( Parameters("RESULT")->asShapes() && Parameters("RESULT")->asShapes() != pPoints ) { Parameters("RESULT")->asShapes()->Create(*pPoints); pPoints = Parameters("RESULT")->asShapes(); } //----------------------------------------------------- int zField = Parameters("ZFIELD")->asInt(); int vField = pPoints->Get_Field_Count(); CSG_String Name = Parameters("NAME")->asString(); if( Name.is_Empty() ) Name = _TL("Variable"); pPoints->Add_Field(Name, SG_DATATYPE_Double); //----------------------------------------------------- // #pragma omp parallel for for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); double Value; if( !pPoint->is_NoData(zField) && Get_Value(pPoint->Get_Point(0), pPoint->asDouble(zField), Value) ) { pPoint->Set_Value(vField, Value); } else { pPoint->Set_NoData(vField); } } //----------------------------------------------------- if( Parameters("RESULT")->asShapes() == NULL ) { DataObject_Update(pPoints); } Finalize(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/climate/climate_tools/etp_hargreave.cpp0000664000175000017500000004371512602774414025643 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: etp_hargreave.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // etp_hargreave.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "etp_hargreave.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double Get_Radiation_TopOfAtmosphere (int DayOfYear, double Latitude_Rad) { double sinLat = sin(Latitude_Rad); double cosLat = cos(Latitude_Rad); double tanLat = tan(Latitude_Rad); // relative distance between sun and earth on any Julian day double dR = 0.033 * cos(DayOfYear * 2.0 * M_PI / 365.0) + 1.0; // solar declination in radians and sunset hour angle double SunHgt = 0.4093 * sin(DayOfYear * 2.0 * M_PI / 365.0 - 1.405); double SunDir = acos(-tanLat * tan(SunHgt)); // water equivalent of extraterrestrial radiation (mm/day) double R0 = 15.392 * dR * (SunDir * sinLat * sin(SunHgt) + cosLat * cos(SunHgt) * sin(SunDir)); return( R0 ); } //--------------------------------------------------------- double Get_PET_Hargreave (double R0, double Tmean, double Tmin, double Tmax) { return( 0.0023 * R0 * (Tmean + 17.8) * sqrt(Tmax - Tmin) ); // potential evapotranspiration per day } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPET_Hargreave_Grid::CPET_Hargreave_Grid(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("PET (after Hargreaves, Grid)")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "Estimation of daily potential evapotranspiration from daily average, minimum and maximum temperatures " "using Hargreave's empirical equation. In order to estimate extraterrestrial net radiation " "geographic latitude of observation and Julian day have to be supplied too. " "\nReferences:\n" "- Ambikadevi, K.M. (2004): Simulation of Evapotranspiration and Rainfall-runoff for the Stillwater River Watershed in Central Massachusetts. " "Environmental & Water Resources Engineering Masters Projects, University of Massachusetts, Amherst " "online\n" "- Hargraeves, G.H., Samani, Z.A. (1985): Reference crop evapotranspiration from ambient air temperatures. " "Paper presented in ASAE Regional Meeting, Grand Junction, Colorado. " "online\n" "Allen, R.G., Pereira, L.S., Raes, D., Smith, M. (1998): Crop evapotranspiration - Guidelines for computing crop water requirements. " "FAO Irrigation and drainage paper 56. " "online\n" )); //----------------------------------------------------- Parameters.Add_Grid(NULL, "T" , _TL("Mean Temperature" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "T_MIN", _TL("Minimum Temperature" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "T_MAX", _TL("Maximum Temperature" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "PET" , _TL("Potential Evapotranspiration"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Value( NULL , "LAT" , _TL("Latitude [Degree]"), _TL(""), PARAMETER_TYPE_Double, 53.0, -90.0, true, 90.0, true ); pNode = Parameters.Add_Choice( NULL , "TIME" , _TL("Time"), _TL(""), CSG_String::Format("%s|%s|", _TL("day"), _TL("month") ), 0 ); Parameters.Add_Choice( pNode , "MONTH" , _TL("Month"), _TL(""), CSG_DateTime::Get_Month_Choices(), CSG_DateTime::Get_Current_Month() ); Parameters.Add_Value( pNode , "DAY" , _TL("Day of Month"), _TL(""), PARAMETER_TYPE_Int, CSG_DateTime::Get_Current_Day(), 1, true, 31, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPET_Hargreave_Grid::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "T") ) { pParameters->Set_Enabled("LAT", pParameter->asGrid() && pParameter->asGrid()->Get_Projection().is_Okay() == false); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "TIME") ) { pParameters->Set_Enabled("DAY", pParameter->asInt() == 0); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPET_Hargreave_Grid::On_Execute(void) { //----------------------------------------------------- const int DaysBefore[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; const int DaysCount [12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //----------------------------------------------------- CSG_Grid *pTavg = Parameters("T" )->asGrid(); CSG_Grid *pTmin = Parameters("T_MIN")->asGrid(); CSG_Grid *pTmax = Parameters("T_MAX")->asGrid(); CSG_Grid *pPET = Parameters("PET" )->asGrid(); //----------------------------------------------------- CSG_Grid Lat, *pLat = NULL; if( pTavg->Get_Projection().is_Okay() ) { bool bResult; CSG_Grid Lon; SG_RUN_MODULE(bResult, "pj_proj4", 17, // geographic coordinate grids SG_MODULE_PARAMETER_SET("GRID", pTavg) && SG_MODULE_PARAMETER_SET("LON" , &Lon) && SG_MODULE_PARAMETER_SET("LAT" , &Lat) ) if( bResult ) { pLat = &Lat; } } //----------------------------------------------------- int bDaily = Parameters("TIME")->asInt() == 0; CSG_DateTime Date( (CSG_DateTime::TSG_DateTime)(bDaily ? Parameters("DAY")->asInt() : 15), (CSG_DateTime::Month)Parameters("MONTH")->asInt() ); int Day = Date.Get_DayOfYear(); int nDays = Date.Get_NumberOfDays(Parameters("MONTH")->asInt()); double R0_const = Get_Radiation_TopOfAtmosphere(Day, Parameters("LAT")->asDouble() * M_DEG_TO_RAD); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) || pTmin->is_NoData(x, y) || pTmax->is_NoData(x, y) || (pLat && pLat->is_NoData(x, y)) ) { pPET->Set_NoData(x, y); } else { double PET = Get_PET_Hargreave(pLat ? Get_Radiation_TopOfAtmosphere(Day, pLat->asDouble(x, y) * M_DEG_TO_RAD) : R0_const, pTavg->asDouble(x, y), pTmin->asDouble(x, y), pTmax->asDouble(x, y) ); pPET->Set_Value(x, y, bDaily ? PET : PET * nDays); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPET_Hargreave_Table::CPET_Hargreave_Table(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("PET (after Hargreaves, Table)")); Set_Author ("O.Conrad (c) 2011"); Set_Description (_TW( "Estimation of daily potential evapotranspiration from daily average, minimum and maximum temperatures " "using Hargreave's empirical equation. In order to estimate extraterrestrial net radiation " "geographic latitude of observation and Julian day have to be supplied too. " "\nReferences:\n" "- Ambikadevi, K.M. (2004): Simulation of Evapotranspiration and Rainfall-runoff for the Stillwater River Watershed in Central Massachusetts. " "Environmental & Water Resources Engineering Masters Projects, University of Massachusetts, Amherst " "online\n" "- Hargraeves, G.H., Samani, Z.A. (1985): Reference crop evapotranspiration from ambient air temperatures. " "Paper presented in ASAE Regional Meeting, Grand Junction, Colorado. " "online\n" "FAO Irrigation and drainage paper 56. " "online\n" )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Data"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "JD" , _TL("Julian Day"), _TL("") ); Parameters.Add_Table_Field( pNode , "T" , _TL("Mean Temperature"), _TL("") ); Parameters.Add_Table_Field( pNode , "T_MIN" , _TL("Minimum Temperature"), _TL("") ); Parameters.Add_Table_Field( pNode , "T_MAX" , _TL("Maximum Temperature"), _TL("") ); Parameters.Add_Value( pNode , "LAT" , _TL("Latitude"), _TL(""), PARAMETER_TYPE_Double, 53.0, -90.0, true, 90.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPET_Hargreave_Table::On_Execute(void) { //----------------------------------------------------- int fDay, fT, fTmin, fTmax, fET; double Lat; CSG_Table *pTable; pTable = Parameters("TABLE")->asTable (); Lat = Parameters("LAT" )->asDouble() * M_DEG_TO_RAD; fDay = Parameters("JD" )->asInt (); fT = Parameters("T" )->asInt (); fTmin = Parameters("T_MIN")->asInt (); fTmax = Parameters("T_MAX")->asInt (); fET = pTable->Get_Field_Count(); pTable->Add_Field("ET", SG_DATATYPE_Double); //----------------------------------------------------- for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); if( pRecord->is_NoData(fDay) || pRecord->is_NoData(fTmin) || pRecord->is_NoData(fTmax) ) { pRecord->Set_NoData(fET); } else { pRecord->Set_Value(fET, Get_PET_Hargreave(Get_Radiation_TopOfAtmosphere( pRecord->asInt (fDay ), Lat), pRecord->asDouble(fT ), pRecord->asDouble(fTmin), pRecord->asDouble(fTmax)) ); } } //----------------------------------------------------- DataObject_Update(pTable); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPET_Day_To_Hour::CPET_Day_To_Hour(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Daily to Hourly PET")); Set_Author ("O.Conrad (c) 2011"); Set_Description (_TW( "Derive hourly from daily evapotranspiration using sinusoidal distribution. " "\nReferences:\n" "- Ambikadevi, K.M. (2004): Simulation of Evapotranspiration and Rainfall-runoff for the Stillwater River Watershed in Central Massachusetts. " "Environmental & Water Resources Engineering Masters Projects, University of Massachusetts, Amherst " "online\n" )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "DAYS" , _TL("Daily Data"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "JD" , _TL("Julian Day"), _TL("") ); Parameters.Add_Table_Field( pNode , "ET" , _TL("Evapotranspiration"), _TL("") ); Parameters.Add_Table_Field( pNode , "P" , _TL("Precipitation"), _TL(""), true ); Parameters.Add_Table( NULL , "HOURS" , _TL("Hourly Data"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( pNode , "LAT" , _TL("Latitude"), _TL(""), PARAMETER_TYPE_Double, 53.0, -90.0, true, 90.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPET_Day_To_Hour::On_Execute(void) { int fJD, fET, fP; double sinLat, cosLat, sinHgt; CSG_Table *pDays, *pHours; //----------------------------------------------------- pDays = Parameters("DAYS" )->asTable(); pHours = Parameters("HOURS")->asTable(); fJD = Parameters("JD" )->asInt(); fET = Parameters("ET" )->asInt(); fP = Parameters("P" )->asInt(); sinLat = sin(Parameters("LAT") ->asDouble() * M_DEG_TO_RAD); cosLat = cos(Parameters("LAT") ->asDouble() * M_DEG_TO_RAD); sinHgt = 0.0; // -0.0145; // >> -50'' desired height of horizon pHours->Destroy(); pHours->Set_Name(CSG_String::Format("%s [%s]", pDays->Get_Name(), _TL("h"))); pHours->Add_Field("JULIAN_DAY", SG_DATATYPE_Int); pHours->Add_Field("HOUR" , SG_DATATYPE_Int); pHours->Add_Field("ET" , SG_DATATYPE_Double); if( fP >= 0 ) { pHours->Add_Field("P", SG_DATATYPE_Double); } //----------------------------------------------------- for(int iDay=0; iDayGet_Count() && Set_Progress(iDay, pDays->Get_Count()); iDay++) { CSG_Table_Record *pDay = pDays->Get_Record(iDay); int JD; double P, ET, D, dT, fT, sRise, sSet; JD = pDay->asInt (fJD); ET = pDay->asDouble(fET); if( fP >= 0 ) { P = pDay->asDouble(fP ); } D = 0.40954 * sin(0.0172 * (JD - 79.349740)); // sun's declination dT = 12.0 * acos((sinHgt - sinLat * sin(D)) / (cosLat * cos(D))) / M_PI; fT = -0.1752 * sin(0.033430 * JD + 0.5474) - 0.1340 * sin(0.018234 * JD - 0.1939); sRise = 12.0 - dT - fT; sSet = 12.0 + dT - fT; for(int iHour=0; iHour<24; iHour++) { CSG_Table_Record *pHour = pHours->Add_Record(); pHour->Set_Value(0, JD); pHour->Set_Value(1, iHour); if( fP >= 0 ) { pHour->Set_Value(3, P / 24.0); } if( sRise <= iHour && iHour <= sSet ) { pHour->Set_Value(2, ET * (1.0 - cos(2.0 * M_PI * (iHour - sRise) / (sSet - sRise))) / 2.0); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/climate/climate_tools/daily_sun.cpp0000664000175000017500000002156412602774414025014 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: daily_sun.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // daily_sun.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "daily_sun.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDaily_Sun::CDaily_Sun(void) { //----------------------------------------------------- Set_Name (_TL("Sunrise and Sunset")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid(NULL, "TARGET" , _TL("Target System"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "SUNRISE", _TL("Sunrise" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "SUNSET" , _TL("Sunset" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "LENGTH" , _TL("Day Length" ), _TL(""), PARAMETER_OUTPUT); //----------------------------------------------------- Parameters.Add_Value( NULL , "YEAR" , _TL("Year"), _TL(""), PARAMETER_TYPE_Int, CSG_DateTime::Get_Current_Year() ); Parameters.Add_Choice( NULL , "MONTH" , _TL("Month"), _TL(""), CSG_DateTime::Get_Month_Choices(), CSG_DateTime::Get_Current_Month() ); Parameters.Add_Value( NULL , "DAY" , _TL("Day of Month"), _TL(""), PARAMETER_TYPE_Int, CSG_DateTime::Get_Current_Day(), 1, true, 31, true ); Parameters.Add_Choice( NULL , "TIME" , _TL("Time"), _TL(""), CSG_String::Format("%s|%s|", _TL("local"), _TL("world") ) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CDaily_Sun::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double SG_Range_Set_0_to_24(double Value) { Value = fmod(Value, 24.0); return( Value < 0.0 ? Value + 24.0 : Value ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDaily_Sun::On_Execute(void) { //----------------------------------------------------- CSG_Grid *pTarget = Parameters("TARGET")->asGrid(); if( !pTarget->Get_Projection().is_Okay() ) { Error_Set(_TL("target's spatial reference system is undefined")); return( false ); } CSG_Grid Lon(*Get_System()), Lat(*Get_System()); SG_RUN_MODULE_ExitOnError("pj_proj4", 17, // geographic coordinate grids SG_MODULE_PARAMETER_SET("GRID", pTarget) && SG_MODULE_PARAMETER_SET("LON" , &Lon) && SG_MODULE_PARAMETER_SET("LAT" , &Lat) ) Lon *= M_DEG_TO_RAD; Lat *= M_DEG_TO_RAD; //----------------------------------------------------- CSG_Grid *pSunset = Parameters("SUNSET" )->asGrid(); CSG_Grid *pSunrise = Parameters("SUNRISE")->asGrid(); CSG_Grid *pDuration = Parameters("LENGTH" )->asGrid(); bool bWorld = Parameters("TIME")->asInt() == 1; //----------------------------------------------------- CSG_DateTime Time((CSG_DateTime::TSG_DateTime)Parameters("DAY")->asInt(), (CSG_DateTime::Month)Parameters("MONTH")->asInt(), Parameters("YEAR")->asInt()); Time.Reset_Time(); Message_Add(Time.Format("\n%A, %d. %B %Y"), false); //----------------------------------------------------- double Dec, RA, RAm, T; SG_Get_Sun_Position(Time, RA, Dec); T = ((int)Time.Get_JDN() - 2451545.0 ) / 36525.0; // Number of Julian centuries since 2000/01/01 at 12 UT (JDN = 2451545.0) RAm = fmod(18.71506921 + 2400.0513369 * T + (2.5862e-5 - 1.72e-9 * T) * T*T, 24.0); RA = fmod(RA * 12.0 / M_PI, 24.0); if( RA < 0.0 ) RA += 24.0; T = 1.0027379 * (RAm - RA); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { pSunrise ->Set_NoData(x, y); pSunset ->Set_NoData(x, y); pDuration->Set_NoData(x, y); } else { double dT = (sin(-Lat.asDouble(x, y) / 60.0) - sin(Lat.asDouble(x, y)) * sin(Dec)) / (cos(Lat.asDouble(x, y)) * cos(Dec)); if( dT > 1.0 ) { pSunrise ->Set_NoData(x, y); pSunset ->Set_NoData(x, y); pDuration->Set_Value (x, y, 0.0); } else if( dT < -1.0 ) { pSunrise ->Set_NoData(x, y); pSunset ->Set_NoData(x, y); pDuration->Set_Value (x, y, 24.0); } else { dT = acos(dT) * 12.0 / M_PI; double Sunrise = SG_Range_Set_0_to_24(12.0 - dT - T); double Sunset = SG_Range_Set_0_to_24(12.0 + dT - T); pDuration->Set_Value(x, y, Sunset - Sunrise); if( bWorld ) { Sunrise = SG_Range_Set_0_to_24(Sunrise - M_RAD_TO_DEG * Lon.asDouble(x, y) / 15.0); Sunset = SG_Range_Set_0_to_24(Sunset - M_RAD_TO_DEG * Lon.asDouble(x, y) / 15.0); } pSunrise ->Set_Value(x, y, Sunrise); pSunset ->Set_Value(x, y, Sunset ); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/climate/climate_tools/Makefile.in0000664000175000017500000005514012622651157024363 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/climate/climate_tools DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libclimate_tools_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libclimate_tools_la_OBJECTS = daily_sun.lo etp_hargreave.lo \ grid_levels_interpolation.lo milankovic.lo MLB_Interface.lo libclimate_tools_la_OBJECTS = $(am_libclimate_tools_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libclimate_tools_la_SOURCES) DIST_SOURCES = $(libclimate_tools_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libclimate_tools.la libclimate_tools_la_SOURCES = \ daily_sun.cpp\ etp_hargreave.cpp\ grid_levels_interpolation.cpp\ milankovic.cpp\ MLB_Interface.cpp\ daily_sun.h\ etp_hargreave.h\ grid_levels_interpolation.h\ milankovic.h\ MLB_Interface.h libclimate_tools_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) --foreign src/modules/climate/climate_tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/climate/climate_tools/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libclimate_tools.la: $(libclimate_tools_la_OBJECTS) $(libclimate_tools_la_DEPENDENCIES) $(EXTRA_libclimate_tools_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libclimate_tools_la_OBJECTS) $(libclimate_tools_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/daily_sun.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/etp_hargreave.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_levels_interpolation.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/milankovic.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/climate/climate_tools/grid_levels_interpolation.h0000664000175000017500000001423212565125417027733 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_Levels_interpolation.h 1380 2012-04-26 12:02:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // grid_Levels_interpolation.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_Levels_interpolation_H #define HEADER_INCLUDED__grid_Levels_interpolation_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Levels_Interpolation : public CSG_Module_Grid { public: CGrid_Levels_Interpolation(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("R:Tools") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); bool Initialize (const CSG_Rect &Extent); bool Finalize (void); bool Get_Value (double x, double y, double z, double &Value); bool Get_Value (const TSG_Point &p, double z, double &Value); private: bool m_Linear_bSorted, m_Spline_bAll; int m_xSource, m_hMethod, m_vMethod, m_Trend_Order; CSG_Table *m_pXTable; CSG_Grid *m_Coeff; CSG_Parameter_Grid_List *m_pXGrids, *m_pVariables; double Get_Variable (double x, double y, int iLevel); bool Get_Variable (double x, double y, int iLevel, double &Variable); double Get_Height (double x, double y, int iLevel); bool Get_Height (double x, double y, int iLevel, double &Height); bool Get_Values (double x, double y, double z, int &iLevel, CSG_Table &Values); bool Get_Linear_Sorted (double x, double y, double z, double &Value); bool Get_Linear (double x, double y, double z, double &Value); bool Get_Spline_All (double x, double y, double z, double &Value); bool Get_Spline (double x, double y, double z, double &Value); bool Get_Trend (double x, double y, double z, double &Value); bool Get_Trend_Coeff (double x, double y, double z, double &Value); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Levels_to_Surface : public CGrid_Levels_Interpolation { public: CGrid_Levels_to_Surface(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Levels_to_Points : public CGrid_Levels_Interpolation { public: CGrid_Levels_to_Points(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_Levels_interpolation_H saga-2.2.3/src/modules/climate/climate_tools/milankovic.cpp0000664000175000017500000011470212565125417025157 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: milankovic.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // milankovic.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "milankovic.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SG_NINT(x) ((int)(x < 0.0 ? x - 0.5 : x + 0.5)) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSG_Solar_Position { public: CSG_Solar_Position(void); CSG_Solar_Position(long Year); static bool Get_Orbital_Parameters (int Year, double &Eccentricity, double &Obliquity, double &Perihelion); bool Get_Orbital_Position (double Day, double &SIND, double &COSD, double &SUNDIS, double &SUNLON, double &SUNLAT, double &EQTIME); bool Set_Solar_Constant (double SolarConst); double Get_Solar_Constant (void) { return( m_SolarConst ); } bool Set_Year (int Year); int Get_Year (void) { return( m_Year ); } bool Set_Day (double Day); double Get_Day (void) { return( m_Day ); } double Get_Sun_Distance (void) { return( m_SunDist ); } double Get_Sun_Lon (void) { return( m_SunLon ); } double Get_Sun_Lat (void) { return( m_SunLat ); } double Get_Zenith (void) { return( asin(m_sinDec) ); } double Get_Daily_Radiation (double Latitude); bool Get_CosZenith (double RLAT, double SIND, double COSD, double &COSZT, double &COSZS); private: int m_Year; double m_Day; double m_Eccentricity, m_Obliquity, m_Perihelion, m_SolarConst, m_sinDec, m_cosDec, m_SunDist, m_SunLon, m_SunLat, m_EqTime; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Solar_Position::CSG_Solar_Position(void) { m_SolarConst = 1367.0; m_Year = 2000; m_Day = 0.0; Get_Orbital_Parameters(m_Year, m_Eccentricity, m_Obliquity, m_Perihelion); Get_Orbital_Position (m_Day, m_sinDec, m_cosDec, m_SunDist, m_SunLon, m_SunLat, m_EqTime); } //--------------------------------------------------------- CSG_Solar_Position::CSG_Solar_Position(long Year) { m_SolarConst = 1367.0; m_Year = Year; m_Day = 0.0; Get_Orbital_Parameters(m_Year, m_Eccentricity, m_Obliquity, m_Perihelion); Get_Orbital_Position (m_Day, m_sinDec, m_cosDec, m_SunDist, m_SunLon, m_SunLat, m_EqTime); } //--------------------------------------------------------- bool CSG_Solar_Position::Set_Year(int Year) { if( m_Year != Year ) { m_Year = Year; return( Get_Orbital_Parameters(m_Year, m_Eccentricity, m_Obliquity, m_Perihelion) ); } return( true ); } //--------------------------------------------------------- bool CSG_Solar_Position::Set_Day(double Day) { if( m_Day != Day ) { m_Day = Day; return( Get_Orbital_Position(m_Day, m_sinDec, m_cosDec, m_SunDist, m_SunLon, m_SunLat, m_EqTime) ); } return( true ); } //--------------------------------------------------------- double CSG_Solar_Position::Get_Daily_Radiation(double Latitude) { double cosZT, cosZS; Get_CosZenith(Latitude, m_sinDec, m_cosDec, cosZT, cosZS); return( Get_Solar_Constant() * cosZT / (m_SunDist*m_SunDist) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // ORBPAR calculates the three orbital parameters as a function of // YEAR. The source of these calculations is: Andre L. Berger, // 1978, "Long-Term Variations of Daily Insolation and Quaternary // Climatic Changes", JAS, v.35, p.2362. Also useful is: Andre L. // Berger, May 1978, "A Simple Algorithm to Compute Long Term // Variations of Daily Insolation", published by Institut // D'Astronomie de Geophysique, Universite Catholique de Louvain, // Louvain-la Neuve, No. 18. // // Tables and equations refer to the first reference (JAS). The // corresponding table or equation in the second reference is // enclosed in parentheses. The coefficients used in this // subroutine are slightly more precise than those used in either // of the references. The generated orbital parameters are precise // within plus or minus 1000000 years from present. // // Input: YEAR = years A.D. are positive, B.C. are negative // Output: ECCEN = eccentricity of orbital ellipse // OBLIQ = latitude of Tropic of Cancer in radians // OMEGVP = longitude of perihelion = // = spatial angle from vernal equinox to perihelion // in radians with sun as angle vertex // //--------------------------------------------------------- bool CSG_Solar_Position::Get_Orbital_Parameters(int YEAR, double &ECCEN, double &OBLIQ, double &OMEGVP) { // Table 1 (2). Obliquity relative to mean ecliptic of date: OBLIQD const double TABLE1[47][3] = { { -2462.2214466, 31.609974, 251.9025 }, { -857.3232075, 32.620504, 280.8325 }, { -629.3231835, 24.172203, 128.3057 }, { -414.2804924, 31.983787, 292.7252 }, { -311.7632587, 44.828336, 15.3747 }, { 308.9408604, 30.973257, 263.7951 }, { -162.5533601, 43.668246, 308.4258 }, { -116.1077911, 32.246691, 240.0099 }, { 101.1189923, 30.599444, 222.9725 }, { -67.6856209, 42.681324, 268.7809 }, { 24.9079067, 43.836462, 316.7998 }, { 22.5811241, 47.439436, 319.6024 }, { -21.1648355, 63.219948, 143.8050 }, { -15.6549876, 64.230478, 172.7351 }, { 15.3936813, 1.010530, 28.9300 }, { 14.6660938, 7.437771, 123.5968 }, { -11.7273029, 55.782177, 20.2082 }, { 10.2742696, .373813, 40.8226 }, { 6.4914588, 13.218362, 123.4722 }, { 5.8539148, 62.583231, 155.6977 }, { -5.4872205, 63.593761, 184.6277 }, { -5.4290191, 76.438310, 267.2772 }, { 5.1609570, 45.815258, 55.0196 }, { 5.0786314, 8.448301, 152.5268 }, { -4.0735782, 56.792707, 49.1382 }, { 3.7227167, 49.747842, 204.6609 }, { 3.3971932, 12.058272, 56.5233 }, { -2.8347004, 75.278220, 200.3284 }, { -2.6550721, 65.241008, 201.6651 }, { -2.5717867, 64.604291, 213.5577 }, { -2.4712188, 1.647247, 17.0374 }, { 2.4625410, 7.811584, 164.4194 }, { 2.2464112, 12.207832, 94.5422 }, { -2.0755511, 63.856665, 131.9124 }, { -1.9713669, 56.155990, 61.0309 }, { -1.8813061, 77.448840, 296.2073 }, { -1.8468785, 6.801054, 135.4894 }, { 1.8186742, 62.209418, 114.8750 }, { 1.7601888, 20.656133, 247.0691 }, { -1.5428851, 48.344406, 256.6114 }, { 1.4738838, 55.145460, 32.1008 }, { -1.4593669, 69.000539, 143.6804 }, { 1.4192259, 11.071350, 16.8784 }, { -1.1818980, 74.291298, 160.6835 }, { 1.1756474, 11.047742, 27.5932 }, { -1.1316126, 0.636717, 348.1074 }, { 1.0896928, 12.844549, 82.6496 } }; // Table 4 (1). Fundamental elements of the ecliptic: ECCEN sin(pi) const double TABLE4[19][3] = { { .01860798, 4.207205, 28.620089 }, { .01627522, 7.346091, 193.788772 }, { -.01300660, 17.857263, 308.307024 }, { .00988829, 17.220546, 320.199637 }, { -.00336700, 16.846733, 279.376984 }, { .00333077, 5.199079, 87.195000 }, { -.00235400, 18.231076, 349.129677 }, { .00140015, 26.216758, 128.443387 }, { .00100700, 6.359169, 154.143880 }, { .00085700, 16.210016, 291.269597 }, { .00064990, 3.065181, 114.860583 }, { .00059900, 16.583829, 332.092251 }, { .00037800, 18.493980, 296.414411 }, { -.00033700, 6.190953, 145.769910 }, { .00027600, 18.867793, 337.237063 }, { .00018200, 17.425567, 152.092288 }, { -.00017400, 6.186001, 126.839891 }, { -.00012400, 18.417441, 210.667199 }, { .00001250, 0.667863, 72.108838 } }; // Table 5 (3). General precession in longitude: psi const double TABLE5[78][3] = { { 7391.0225890, 31.609974, 251.9025 }, { 2555.1526947, 32.620504, 280.8325 }, { 2022.7629188, 24.172203, 128.3057 }, { -1973.6517951, 0.636717, 348.1074 }, { 1240.2321818, 31.983787, 292.7252 }, { 953.8679112, 3.138886, 165.1686 }, { -931.7537108, 30.973257, 263.7951 }, { 872.3795383, 44.828336, 15.3747 }, { 606.3544732, 0.991874, 58.5749 }, { -496.0274038, 0.373813, 40.8226 }, { 456.9608039, 43.668246, 308.4258 }, { 346.9462320, 32.246691, 240.0099 }, { -305.8412902, 30.599444, 222.9725 }, { 249.6173246, 2.147012, 106.5937 }, { -199.1027200, 10.511172, 114.5182 }, { 191.0560889, 42.681324, 268.7809 }, { -175.2936572, 13.650058, 279.6869 }, { 165.9068833, 0.986922, 39.6448 }, { 161.1285917, 9.874455, 126.4108 }, { 139.7878093, 13.013341, 291.5795 }, { -133.5228399, 0.262904, 307.2848 }, { 117.0673811, 0.004952, 18.9300 }, { 104.6907281, 1.142024, 273.7596 }, { 95.3227476, 63.219948, 143.8050 }, { 86.7824524, 0.205021, 191.8927 }, { 86.0857729, 2.151964, 125.5237 }, { 70.5893698, 64.230478, 172.7351 }, { -69.9719343, 43.836462, 316.7998 }, { -62.5817473, 47.439436, 319.6024 }, { 61.5450059, 1.384343, 69.7526 }, { -57.9364011, 7.437771, 123.5968 }, { 57.1899832, 18.829299, 217.6432 }, { -57.0236109, 9.500642, 85.5882 }, { -54.2119253, 0.431696, 156.2147 }, { 53.2834147, 1.160090, 66.9489 }, { 52.1223575, 55.782177, 20.2082 }, { -49.0059908, 12.639528, 250.7568 }, { -48.3118757, 1.155138, 48.0188 }, { -45.4191685, 0.168216, 8.3739 }, { -42.2357920, 1.647247, 17.0374 }, { -34.7971099, 10.884985, 155.3409 }, { 34.4623613, 5.610937, 94.1709 }, { -33.8356643, 12.658184, 221.1120 }, { 33.6689362, 1.010530, 28.9300 }, { -31.2521586, 1.983748, 117.1498 }, { -30.8798701, 14.023871, 320.5095 }, { 28.4640769, 0.560178, 262.3602 }, { -27.1960802, 1.273434, 336.2148 }, { 27.0860736, 12.021467, 233.0046 }, { -26.3437456, 62.583231, 155.6977 }, { 24.7253740, 63.593761, 184.6277 }, { 24.6732126, 76.438310, 267.2772 }, { 24.4272733, 4.280910, 78.9281 }, { 24.0127327, 13.218362, 123.4722 }, { 21.7150294, 17.818769, 188.7132 }, { -21.5375347, 8.359495, 180.1364 }, { 18.1148363, 56.792707, 49.1382 }, { -16.9603104, 8.448301, 152.5268 }, { -16.1765215, 1.978796, 98.2198 }, { 15.5567653, 8.863925, 97.4808 }, { 15.4846529, 0.186365, 221.5376 }, { 15.2150632, 8.996212, 168.2438 }, { 14.5047426, 6.771027, 161.1199 }, { -14.3873316, 45.815258, 55.0196 }, { 13.1351419, 12.002811, 262.6495 }, { 12.8776311, 75.278220, 200.3284 }, { 11.9867234, 65.241008, 201.6651 }, { 11.9385578, 18.870667, 294.6547 }, { 11.7030822, 22.009553, 99.8233 }, { 11.6018181, 64.604291, 213.5577 }, { -11.2617293, 11.498094, 154.1631 }, { -10.4664199, 0.578834, 232.7153 }, { 10.4333970, 9.237738, 138.3034 }, { -10.2377466, 49.747842, 204.6609 }, { 10.1934446, 2.147012, 106.5938 }, { -10.1280191, 1.196895, 250.4676 }, { 10.0289441, 2.133898, 332.3345 }, { -10.0034259, 0.173168, 27.3039 } }; int YM1950 = YEAR - 1950; int i; double ARG; //----------------------------------------------------- // Obliquity from Table 1 (2): // OBLIQ# = 23.320556 (degrees) Equation 5.5 (15) // OBLIQD = OBLIQ# + sum[A cos(ft+delta)] Equation 1 (5) double SUMC = 0; for(i=0; i<47; i++) // Do 110 I=1,47 { ARG = M_DEG_TO_RAD * (YM1950 * TABLE1[i][1] / 3600 + TABLE1[i][2]); SUMC = SUMC + TABLE1[i][0] * cos(ARG); } // OBLIQD = 23.320556 + SUMC / 3600; OBLIQ = M_DEG_TO_RAD * (23.320556 + SUMC / 3600); //----------------------------------------------------- // Eccentricity from Table 4 (1): // ECCEN sin(pi) = sum[M sin(gt+beta)] Equation 4 (1) // ECCEN cos(pi) = sum[M cos(gt+beta)] Equation 4 (1) // ECCEN = ECCEN sqrt[sin(pi)^2 + cos(pi)^2] double ESINPI = 0; double ECOSPI = 0; for(i=0; i<19; i++) // Do 210 I=1,19 { ARG = M_DEG_TO_RAD * (YM1950 * TABLE4[i][1] / 3600 + TABLE4[i][2]); ESINPI = ESINPI + TABLE4[i][0] * sin(ARG); ECOSPI = ECOSPI + TABLE4[i][0] * cos(ARG); } ECCEN = sqrt(ESINPI*ESINPI + ECOSPI*ECOSPI); //----------------------------------------------------- // Perihelion from Equation 4,6,7 (9) and Table 4,5 (1,3): // PSI# = 50.439273 (seconds of degree) Equation 7.5 (16) // ZETA = 3.392506 (degrees) Equation 7.5 (17) // PSI = PSI# t + ZETA + sum[F sin(ft+delta)] Equation 7 (9) // PIE = atan[ECCEN sin(pi) / ECCEN cos(pi)] // OMEGVP = PIE + PSI + 3.14159 Equation 6 (4.5) double PIE = atan2(ESINPI, ECOSPI); double FSINFD = 0; for(i=0; i<78; i++) // Do 310 I=1,78 { ARG = M_DEG_TO_RAD * (YM1950 * TABLE5[i][1] / 3600 + TABLE5[i][2]); FSINFD = FSINFD + TABLE5[i][0] * sin(ARG); } double PSI = M_DEG_TO_RAD*(3.392506 + (YM1950 * 50.439273 + FSINFD) / 3600); OMEGVP = fmod(PIE + PSI + .5 * M_PI_360, M_PI_360); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // ORBIT receives orbital parameters and time of year, and returns // distance from Sun, declination angle, and Sun's overhead position. // Reference for following calculations is: V.M.Blanco and // S.W.McCuskey, 1961, "Basic Physics of the Solar System", pages // 135 - 151. Existence of Moon and heavenly bodies other than // Earth and Sun are ignored. Earth is assumed to be spherical. // // Program author: Gary L. Russell 2008/09/22 // Angles, longitude and latitude are measured in radians. // // Input: ECCEN = eccentricity of the orbital ellipse // OBLIQ = latitude of Tropic of Cancer // OMEGVP = longitude of perihelion (sometimes Pi is added) = // = spatial angle from vernal equinox to perihelion // with Sun as angle vertex // DAY = days measured since 2000 January 1, hour 0 // // Constants: EDAYzY = tropical year = Earth days per year = 365.2425 // VE2000 = days from 2000 January 1, hour 0 until vernal // equinox of year 2000 = 31 + 29 + 19 + 7.5/24 // // Intermediate quantities: // BSEMI = semi minor axis in units of semi major axis // PERIHE = perihelion in days since 2000 January 1, hour 0 // in its annual revolution about Sun // TA = true anomaly = spatial angle from perihelion to // current location with Sun as angle vertex // EA = eccentric anomaly = spatial angle measured along // eccentric circle (that circumscribes Earth's orbit) // from perihelion to point above (or below) Earth's // absisca (where absisca is directed from center of // eccentric circle to perihelion) // MA = mean anomaly = temporal angle from perihelion to // current time in units of 2*Pi per tropical year // TAofVE = TA(VE) = true anomaly of vernal equinox = - OMEGVP // EAofVE = EA(VE) = eccentric anomaly of vernal equinox // MAofVE = MA(VE) = mean anomaly of vernal equinox // SLNORO = longitude of Sun in Earth's nonrotating reference frame // VEQLON = longitude of Greenwich Meridion in Earth's nonrotating // reference frame at vernal equinox // ROTATE = change in longitude in Earth's nonrotating reference // frame from point's location on vernal equinox to its // current location where point is fixed on rotating Earth // SLMEAN = longitude of fictitious mean Sun in Earth's rotating // reference frame (normal longitude and latitude) // // Output: SIND = sin(SUNLAT) = sine of declination angle // COSD = cos(SUNLAT) = cosine of the declination angle // SUNDIS = distance to Sun in units of semi major axis // SUNLON = longitude of point on Earth directly beneath Sun // SUNLAT = latitude of point on Earth directly beneath Sun // EQTIME = Equation of Time = // = longitude of fictitious mean Sun minus SUNLON // // From the above reference: // (4-54): [1 - ECCEN*cos(EA)]*[1 + ECCEN*cos(TA)] = (1 - ECCEN^2) // (4-55): tan(TA/2) = sqrt[(1+ECCEN)/(1-ECCEN)]*tan(EA/2) // Yield: tan(EA) = sin(TA)*sqrt(1-ECCEN^2) / [cos(TA) + ECCEN] // or: tan(TA) = sin(EA)*sqrt(1-ECCEN^2) / [cos(EA) - ECCEN] // //--------------------------------------------------------- bool CSG_Solar_Position::Get_Orbital_Position(double DAY, double &SIND, double &COSD, double &SUNDIS, double &SUNLON, double &SUNLAT, double &EQTIME) { const double EDAYzY = 365.2425; const double VE2000 = 79.3125; double ECCEN = m_Eccentricity; double OBLIQ = m_Obliquity; double OMEGVP = m_Perihelion; //----------------------------------------------------- // Determine EAofVE from geometry: tan(EA) = b*sin(TA) / [e+cos(TA)] // Determine MAofVE from Kepler's equation: MA = EA - e*sin(EA) // Determine MA knowing time from vernal equinox to current day double BSEMI, TAofVE, EAofVE, MAofVE, MA; BSEMI = sqrt(1.0 - ECCEN*ECCEN); TAofVE = -OMEGVP; EAofVE = atan2(BSEMI*sin(TAofVE), ECCEN+cos(TAofVE)); MAofVE = EAofVE - ECCEN*sin(EAofVE); // PERIHE = VE2000 - MAofVE*EDAYzY/M_PI_360 MA = fmod(M_PI_360*(DAY-VE2000)/EDAYzY + MAofVE, M_PI_360); //----------------------------------------------------- // Numerically invert Kepler's equation: MA = EA - e*sin(EA) double dEA, EA = MA + ECCEN*(sin(MA) + ECCEN*sin(2*MA)/2); do { EA += (dEA = (MA - EA + ECCEN * sin(EA)) / (1.0 - ECCEN * cos(EA))); } while( fabs(dEA) > 0.1 ); // 1.0e-10 ); // 1d-10 ); //----------------------------------------------------- // Calculate distance to Sun and true anomaly SUNDIS = 1.0 - ECCEN * cos(EA); double TA = atan2(BSEMI * sin(EA), cos(EA) - ECCEN); //----------------------------------------------------- // Change reference frame to be nonrotating reference frame, angles // fixed according to stars, with Earth at center and positive x // axis be ray from Earth to Sun were Earth at vernal equinox, and // x-y plane be Earth's equatorial plane. Distance from current Sun // to this x axis is SUNDIS sin(TA-TAofVE). At vernal equinox, Sun // is located at (SUNDIS,0,0). At other times, Sun is located at: // // SUN = (SUNDIS cos(TA-TAofVE), // SUNDIS sin(TA-TAofVE) cos(OBLIQ), // SUNDIS sin(TA-TAofVE) sin(OBLIQ)) double SUNX, SUNY, SLNORO; SIND = sin(TA - TAofVE) * sin(OBLIQ); COSD = sqrt(1 - SIND*SIND); SUNX = cos(TA - TAofVE); SUNY = sin(TA - TAofVE) * cos(OBLIQ); SLNORO = atan2(SUNY, SUNX); //----------------------------------------------------- // Determine Sun location in Earth's rotating reference frame // (normal longitude and latitude) double VEQLON, ROTATE; VEQLON = M_PI_360 * VE2000 - M_PI_180 + MAofVE - TAofVE; // ! modulo 2*Pi; ROTATE = M_PI_360 * (DAY-VE2000)*(EDAYzY+1)/EDAYzY; SUNLON = fmod(SLNORO - ROTATE - VEQLON, M_PI_360); if( SUNLON > M_PI_180 ) SUNLON = SUNLON - M_PI_360; SUNLAT = asin(sin(TA - TAofVE) * sin(OBLIQ)); //----------------------------------------------------- // Determine longitude of fictitious mean Sun // Calculate Equation of Time double SLMEAN; SLMEAN = M_PI_180 - M_PI_360*(DAY - floor(DAY)); EQTIME = fmod(SLMEAN - SUNLON, M_PI_360); if( EQTIME > M_PI_180 ) EQTIME = EQTIME - M_PI_360; //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // COSZIJ calculates the daily average cosine of the zenith angle // weighted by time and weighted by sunlight. // // Input: RLAT = latitude (degrees) // SIND,COSD = sine and cosine of the declination angle // // Output: COSZT = sum(cosZ*dT) / sum(dT) // COSZS = sum(cosZ*cosZ*dT) / sum(cosZ*dT) // // Intern: DAWN = time of DAWN (temporal radians) at mean local time // DUSK = time of DUSK (temporal radians) at mean local time // //--------------------------------------------------------- bool CSG_Solar_Position::Get_CosZenith(double RLAT, double SIND, double COSD, double &COSZT, double &COSZS) { if( 0 ) // bDegree { RLAT *= M_DEG_TO_RAD; } double SINJ = sin(RLAT); double COSJ = cos(RLAT); double SJSD = SINJ*SIND; double CJCD = COSJ*COSD; if( SJSD+CJCD <= 0.0 ) { // Constant nightime at this latitude // DAWN = 999999; // DUSK = 999999; COSZT = 0.0; COSZS = 0.0; } else if( SJSD-CJCD >= 0.0 ) { // Constant daylight at this latitude double ECOSZ, QCOSZ; // DAWN = -999999; // DUSK = -999999; ECOSZ = SJSD*M_PI_360; QCOSZ = SJSD*ECOSZ + .5*CJCD*CJCD*M_PI_360; COSZT = SJSD; // ! = ECOSZ/M_PI_360 COSZS = QCOSZ/ECOSZ; } else { // Compute DAWN and DUSK (at local time) and their sines double CDUSK, DUSK, SDUSK, S2DUSK; CDUSK = -SJSD/CJCD; DUSK = acos(CDUSK); SDUSK = sqrt(CJCD*CJCD-SJSD*SJSD) / CJCD; S2DUSK = 2*SDUSK*CDUSK; // DAWN = -DUSK; // SDAWN = -SDUSK; // S2DAWN = -S2DUSK; // Nightime at initial and final times with daylight in between double ECOSZ, QCOSZ; ECOSZ = SJSD*(2*DUSK) + CJCD*(2*SDUSK); QCOSZ = SJSD*ECOSZ + CJCD*(SJSD*(2*SDUSK) + .5*CJCD*(2*DUSK + .5*(2*S2DUSK))); COSZT = ECOSZ/M_PI_360; COSZS = QCOSZ/ECOSZ; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// #define DESC_SOURCE "Orbital parameters used here are based on the work of Andre L. Berger "\ "and its implementation from the NASA Goddard Institute for Space Studies (GISS). "\ "Berger's orbital parameters are considered to be valid for approximately 1 million years.\n"\ "References:\n"\ "- Berger, A.L. (1978): Long Term Variations of Daily Insolation and Quaternary Climatic Changes. Journal of the Atmospheric Sciences, volume 35(12), 2362-2367.\n"\ "- Berger, A.L. (1978): A Simple Algorithm to Compute Long Term Variations of Daily or Monthly Insolation. Institut d'Astronomie et de Geophysique, Universite Catholique de Louvain, Louvain-la-Neuve, No. 18.\n"\ "- NASA/GISS' implementation can be found as part of an Atmosphere-Ocean Model at "\ "Determination of the Earth's Orbital Parameters" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMilankovic::CMilankovic(void) { //----------------------------------------------------- Set_Name (_TL("Earth's Orbital Parameters")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( DESC_SOURCE )); //----------------------------------------------------- Parameters.Add_Table( NULL, "ORBPAR" , _TL("Earth's Orbital Parameters"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL, "START" , _TL("Start [ka]"), _TL(""), PARAMETER_TYPE_Double, -200 ); Parameters.Add_Value( NULL, "STOP" , _TL("Stop [ka]"), _TL(""), PARAMETER_TYPE_Double, 2 ); Parameters.Add_Value( NULL, "STEP" , _TL("Step [ka]"), _TL(""), PARAMETER_TYPE_Double, 1, 0.001, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMilankovic::On_Execute(void) { //----------------------------------------------------- int Start = (int)(Parameters("START")->asDouble() * 1000.0); int Stop = (int)(Parameters("STOP" )->asDouble() * 1000.0); int Step = (int)(Parameters("STEP" )->asDouble() * 1000.0); CSG_Table *pOrbit = Parameters("ORBPAR")->asTable(); pOrbit->Destroy(); pOrbit->Set_Name(_TL("Earth's Orbital Parameters")); pOrbit->Set_NoData_Value(-9999999); pOrbit->Add_Field(_TL("Year") , SG_DATATYPE_Int); pOrbit->Add_Field(_TL("Eccentricity") , SG_DATATYPE_Double); pOrbit->Add_Field(_TL("Obliquity") , SG_DATATYPE_Double); pOrbit->Add_Field(_TL("Perihelion") , SG_DATATYPE_Double); pOrbit->Add_Field(_TL("Climatic Precession"), SG_DATATYPE_Double); //----------------------------------------------------- for(int year=Start; year<=Stop && Set_Progress(year - Start, Stop - Start); year+=Step) { double eccentricity, obliquity, perihelion; if( CSG_Solar_Position::Get_Orbital_Parameters(year, eccentricity, obliquity, perihelion) ) { CSG_Table_Record *pRecord = pOrbit->Add_Record(); pRecord->Set_Value(0, year); pRecord->Set_Value(1, eccentricity); pRecord->Set_Value(2, obliquity); pRecord->Set_Value(3, perihelion); pRecord->Set_Value(4, -eccentricity * sin(perihelion)); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMilankovic_SR_Location::CMilankovic_SR_Location(void) { //----------------------------------------------------- Set_Name (_TL("Annual Course of Daily Insolation")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( DESC_SOURCE )); //----------------------------------------------------- Parameters.Add_Table( NULL , "SOLARRAD" , _TL("Solar Radiation"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "START" , _TL("Start [ka]"), _TL(""), PARAMETER_TYPE_Double, -200 ); Parameters.Add_Value( NULL , "STOP" , _TL("Stop [ka]"), _TL(""), PARAMETER_TYPE_Double, 2 ); Parameters.Add_Value( NULL , "STEP" , _TL("Step [ka]"), _TL(""), PARAMETER_TYPE_Double, 1, 0.001, true ); Parameters.Add_Value( NULL , "LAT" , _TL("Latitude [Degree]"), _TL(""), PARAMETER_TYPE_Double, 53.0, -90.0, true, 90.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMilankovic_SR_Location::On_Execute(void) { //----------------------------------------------------- int Start = (int)(Parameters("START")->asDouble() * 1000.0); int Stop = (int)(Parameters("STOP" )->asDouble() * 1000.0); int Step = (int)(Parameters("STEP" )->asDouble() * 1000.0); double Lat = Parameters("LAT")->asDouble() * M_DEG_TO_RAD; CSG_Table *pRadiation = Parameters("SOLARRAD")->asTable(); pRadiation->Destroy(); pRadiation->Set_Name(_TL("Annual Course of Daily Insolation")); pRadiation->Set_NoData_Value(-9999999); pRadiation->Add_Field(_TL("Day") , SG_DATATYPE_Int); pRadiation->Add_Field(_TL("Zenith") , SG_DATATYPE_Double); pRadiation->Add_Field(_TL("Culmination"), SG_DATATYPE_Double); pRadiation->Add_Field(_TL("Radiation") , SG_DATATYPE_Double); //----------------------------------------------------- for(int year=Start; year<=Stop && Set_Progress(year - Start, Stop - Start); year+=Step) { Process_Set_Text(CSG_String::Format(SG_T("%s: %d"), _TL("Year"), year)); CSG_Solar_Position Position(year); pRadiation->Del_Records(); for(int day=1; day<=365 && Process_Get_Okay(); day++) { if( Position.Set_Day(day) ) { CSG_Table_Record *pRecord = pRadiation->Add_Record(); pRecord->Set_Value(0, day); pRecord->Set_Value(1, Position.Get_Zenith() * M_RAD_TO_DEG); pRecord->Set_Value(2, 90 - fabs(Lat - Position.Get_Zenith()) * M_RAD_TO_DEG); pRecord->Set_Value(3, Position.Get_Daily_Radiation(Lat)); } } DataObject_Update(pRadiation); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMilankovic_SR_Day_Location::CMilankovic_SR_Day_Location(void) { //----------------------------------------------------- Set_Name (_TL("Daily Insolation over Latitude")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( DESC_SOURCE )); //----------------------------------------------------- Parameters.Add_Table( NULL , "SOLARRAD" , _TL("Solar Radiation"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "START" , _TL("Start [ka]"), _TL(""), PARAMETER_TYPE_Double, -200 ); Parameters.Add_Value( NULL , "STOP" , _TL("Stop [ka]"), _TL(""), PARAMETER_TYPE_Double, 2 ); Parameters.Add_Value( NULL , "STEP" , _TL("Step [ka]"), _TL(""), PARAMETER_TYPE_Double, 1, 0.001, true ); Parameters.Add_Value( NULL , "DLAT" , _TL("Latitude Increment [Degree]"), _TL(""), PARAMETER_TYPE_Int, 5, 1, true, 90, true ); Parameters.Add_Value( NULL , "DAY" , _TL("Day of Year"), _TL(""), PARAMETER_TYPE_Int, 181, 0, true, 366, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMilankovic_SR_Day_Location::On_Execute(void) { int iLat, nLat; //----------------------------------------------------- int Start = (int)(Parameters("START")->asDouble() * 1000.0); int Stop = (int)(Parameters("STOP" )->asDouble() * 1000.0); int Step = (int)(Parameters("STEP" )->asDouble() * 1000.0); int Day = Parameters("DAY")->asInt(); double dLat = Parameters("DLAT")->asDouble() * M_DEG_TO_RAD; CSG_Table *pRadiation = Parameters("SOLARRAD")->asTable(); pRadiation->Destroy(); pRadiation->Set_NoData_Value(-9999999); pRadiation->Add_Field(_TL("Year") , SG_DATATYPE_Int); nLat = (int)(M_PI_180 / dLat); for(iLat=0; iLat<=nLat; iLat++) { pRadiation->Add_Field(CSG_String::Format(SG_T("LAT_%.1f"), -90.0 + iLat * M_RAD_TO_DEG * dLat), SG_DATATYPE_Double); } //----------------------------------------------------- for(int year=Start; year<=Stop && Set_Progress(year - Start, Stop - Start); year+=Step) { Process_Set_Text(CSG_String::Format(SG_T("%s: %d"), _TL("Year"), year)); CSG_Solar_Position Position(year); double sinDec, cosDec, Distance, SunLon, SunLat, EqTime, cosZT, cosZS; if( Position.Get_Orbital_Position(Day, sinDec, cosDec, Distance, SunLon, SunLat, EqTime) ) { CSG_Table_Record *pRecord = pRadiation->Add_Record(); pRecord->Set_Value(0, year); for(iLat=0; iLat<=nLat; iLat++) { Position.Get_CosZenith(-M_PI_090 + iLat * dLat, sinDec, cosDec, cosZT, cosZS); pRecord->Set_Value(1 + iLat, 1367 * cosZT / (Distance*Distance)); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMilankovic_SR_Monthly_Global::CMilankovic_SR_Monthly_Global(void) { //----------------------------------------------------- Set_Name (_TL("Monthly Global by Latitude")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( DESC_SOURCE )); //----------------------------------------------------- Parameters.Add_Table( NULL , "SOLARRAD" , _TL("Solar Radiation"), _TL(""), PARAMETER_OUTPUT ); CSG_Parameter *pNode = Parameters.Add_Table( NULL , "ALBEDO" , _TL("Albedo"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Field"), _TL("") ); Parameters.Add_Value( NULL , "YEAR" , _TL("Year [ka]"), _TL(""), PARAMETER_TYPE_Double, 2 ); Parameters.Add_Value( NULL , "DLAT" , _TL("Latitude Increment [Degree]"), _TL(""), PARAMETER_TYPE_Int, 5, 1, true, 90, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMilankovic_SR_Monthly_Global::On_Execute(void) { const int nDays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; const char *Month[12] = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; int iMonth, iDay, aDay, bDay, iLat, Lat; //----------------------------------------------------- int Year = (int)(Parameters("YEAR")->asDouble() * 1000.0); int dLat = Parameters("DLAT")->asInt(); CSG_Matrix SR(12, 181); CSG_Vector SRYear(181), SRGlobal(12), Area(181); // , Albedo(181); //----------------------------------------------------- CSG_Table *pAlbedo = Parameters("ALBEDO")->asTable(); int fAlbedo = Parameters("FIELD") ->asInt(); if( pAlbedo && pAlbedo->Get_Record_Count() != 181 ) { Message_Add(_TL("warning: albedo is ignored")); pAlbedo = NULL; } //----------------------------------------------------- for(iLat=0, Lat=-90; iLat<=180; iLat++, Lat++) { double LATN = iLat == 180 ? M_PI / 2.0 : (Lat + 0.5) * M_DEG_TO_RAD; double LATS = iLat == 0 ? -M_PI / 2.0 : (Lat - 0.5) * M_DEG_TO_RAD; Area[iLat] = 0.5 * (sin(LATN) - sin(LATS)); } //----------------------------------------------------- CSG_Solar_Position Position(Year); for(iMonth=0, bDay=1; iMonth<12; iMonth++) { aDay = bDay; bDay += nDays[iMonth]; for(iDay=aDay; iDayGet_Record(iLat)->asDouble(fAlbedo)); } SR[iLat][iMonth] += s; } } for(iLat=0; iLat<=180; iLat++) { SR[iLat][iMonth] /= nDays[iMonth]; SRGlobal[iMonth] += SR[iLat][iMonth] * Area[iLat]; SRYear[iLat] += SR[iLat][iMonth]; } } //----------------------------------------------------- CSG_Table *pRadiation = Parameters("SOLARRAD")->asTable(); CSG_Table_Record *pRecord; pRadiation->Destroy(); pRadiation->Set_Name(CSG_String::Format(SG_T("%s [%d]"), _TL("Global Irradiation"), Year)); pRadiation->Set_NoData_Value(-9999999); pRadiation->Add_Field(_TL("Lat"), SG_DATATYPE_String); for(iMonth=0; iMonth<12; iMonth++) { pRadiation->Add_Field(Month[iMonth], SG_DATATYPE_Double); } pRadiation->Add_Field(_TL("Annual"), SG_DATATYPE_Double); for(iLat=0, Lat=-90; iLat<=180; iLat+=dLat, Lat+=dLat) { pRecord = pRadiation->Add_Record(); pRecord->Set_Value(0, Lat); for(iMonth=0; iMonth<12; iMonth++) { pRecord->Set_Value(1 + iMonth, SR[iLat][iMonth]); } pRecord->Set_Value(1 + 12, SRYear[iLat] / 12.0); } pRecord = pRadiation->Add_Record(); pRecord->Set_Value(0, SG_T("global")); double SRGLAN = 0.0; for(iMonth=0; iMonth<12; iMonth++) { pRecord->Set_Value(1 + iMonth, SRGlobal[iMonth]); SRGLAN += SRGlobal[iMonth]; } pRecord->Set_Value(1 + 12, SRGLAN / 12.0); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/climate/climate_tools/MLB_Interface.cpp0000664000175000017500000001206112602774414025407 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1383 2012-04-26 15:44:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Tools") ); case MLB_INFO_Category: return( _TL("Climate") ); case MLB_INFO_Author: return( SG_T("O.Conrad (c) 2012") ); case MLB_INFO_Description: return( _TL("Tools for weather and climate data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Climate") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "grid_levels_interpolation.h" #include "milankovic.h" #include "etp_hargreave.h" #include "daily_sun.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CGrid_Levels_to_Surface ); case 1: return( new CGrid_Levels_to_Points ); case 2: return( new CMilankovic ); case 3: return( new CMilankovic_SR_Location ); case 4: return( new CMilankovic_SR_Day_Location ); case 5: return( new CMilankovic_SR_Monthly_Global ); case 8: return( new CPET_Hargreave_Grid ); case 6: return( new CPET_Hargreave_Table ); case 7: return( new CPET_Day_To_Hour ); case 9: return( new CDaily_Sun ); //----------------------------------------------------- case 10: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/climate/climate_tools/Makefile.am0000664000175000017500000000135112602774414024345 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libclimate_tools.la libclimate_tools_la_SOURCES =\ daily_sun.cpp\ etp_hargreave.cpp\ grid_levels_interpolation.cpp\ milankovic.cpp\ MLB_Interface.cpp\ daily_sun.h\ etp_hargreave.h\ grid_levels_interpolation.h\ milankovic.h\ MLB_Interface.h libclimate_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/climate/climate_tools/MLB_Interface.h0000664000175000017500000000754112565125417025064 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__climate_tools_H #define HEADER_INCLUDED__climate_tools_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef climate_tools_EXPORTS #define climate_tools_EXPORT _SAGA_DLL_EXPORT #else #define climate_tools_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__climate_tools_H saga-2.2.3/src/modules/climate/climate_tools/daily_sun.h0000664000175000017500000001074212602774414024455 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: daily_sun.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // daily_sun.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__daily_sun_H #define HEADER_INCLUDED__daily_sun_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDaily_Sun : public CSG_Module_Grid { public: CDaily_Sun(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__daily_sun_H saga-2.2.3/src/modules/climate/Makefile.am0000664000175000017500000000003112565125417021502 0ustar00oconradoconrad00000000000000SUBDIRS = climate_tools saga-2.2.3/src/modules/docs/0000775000175000017500000000000012634325736016771 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/docs/docs_pdf/0000775000175000017500000000000012634325737020553 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/docs/docs_pdf/Shapes_Report.h0000664000175000017500000001075112565125412023475 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Report.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Report.h // // // // Copyright (C) 2005 by // // Olaf Conrad, 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Report_H #define HEADER_INCLUDED__Shapes_Report_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Report : public CSG_Module { public: CShapes_Report(void); virtual ~CShapes_Report(void); protected: virtual bool On_Execute (void); private: int m_iSubtitle, m_nColumns, m_Color_Line, m_Color_Fill; double m_Cell_Height; CSG_Rect m_rTitle, m_rShape, m_rTable; CSG_Shapes *m_pShapes; class CSG_Doc_PDF *m_pPDF; bool Add_Shapes (void); bool Add_Shape (CSG_Shape *pShape, const SG_Char *Title); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Report_H saga-2.2.3/src/modules/docs/docs_pdf/Profile_Cross_Sections.h0000664000175000017500000000637112565125412025342 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Profile_Cross_Sections.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* CrossSections.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ //--------------------------------------------------------- #include "doc_pdf.h" #include /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CProfile_Cross_Sections_PDF : public CSG_Doc_PDF { public: CProfile_Cross_Sections_PDF(); ~CProfile_Cross_Sections_PDF(); void AddCrossSections(TSG_Point **,double*,TSG_Point *,int,int,int); void AddLongitudinalProfile(TSG_Point *, double*, int); void AddVolumesTable(TSG_Point *,TSG_Point **,double*,TSG_Point *,int,int,int); private: char *m_pPath; int m_iCanvasHeight; int m_iTableWidth; int m_iOffsetY; CSG_String m_sName; void AddCrossSection(TSG_Point *,TSG_Point *,int,int); void DrawGuitar(TSG_Point *,double*, int); void AddGuitarValue(double,double,double,double,int); void AdjustSections(TSG_Point *,TSG_Point *,std::vector&,std::vector&,double,int&,int&); void Intersect_Lines(double,double,double,double,double,double,double,double,double&,double&); void CalculateAreas(TSG_Point*,TSG_Point*,double,int,int,double&,double&); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CProfile_Cross_Sections : public CSG_Module_Grid { public: CProfile_Cross_Sections(void); virtual ~CProfile_Cross_Sections(void); protected: bool On_Execute(void); private: CProfile_Cross_Sections_PDF m_DocEngine; CSG_Shapes *m_pSections; double *m_pHeight; TSG_Point *m_pProfile; void CreatePDFDocs(); void AddLongitudinalProfiles(); void AddCrossSections(); double CalculatePointLineDist(double,double,double,double,double,double); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/docs/docs_pdf/Makefile.in0000664000175000017500000005622012622651160022612 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/docs/docs_pdf DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) @HAVE_HARU_TRUE@libdocs_pdf_la_DEPENDENCIES = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am__libdocs_pdf_la_SOURCES_DIST = doc_pdf.cpp MLB_Interface.cpp \ Profile_Cross_Sections.cpp Shapes_Report.cpp \ Shapes_Summary.cpp doc_pdf.h MLB_Interface.h \ Profile_Cross_Sections.h Shapes_Report.h Shapes_Summary.h @HAVE_HARU_TRUE@am_libdocs_pdf_la_OBJECTS = doc_pdf.lo \ @HAVE_HARU_TRUE@ MLB_Interface.lo Profile_Cross_Sections.lo \ @HAVE_HARU_TRUE@ Shapes_Report.lo Shapes_Summary.lo libdocs_pdf_la_OBJECTS = $(am_libdocs_pdf_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = @HAVE_HARU_TRUE@am_libdocs_pdf_la_rpath = -rpath $(pkglibdir) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdocs_pdf_la_SOURCES) DIST_SOURCES = $(am__libdocs_pdf_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @SAGA_UNICODE_TRUE@UC_DEFS = -D_SAGA_UNICODE @HAVE_HARU_TRUE@DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD @HAVE_HARU_TRUE@CXX_INCS = -I$(top_srcdir)/src/saga_core @HAVE_HARU_TRUE@AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS) $(DISABLELIBHARU) $(GOMPFLAGS) @HAVE_HARU_TRUE@AM_LDFLAGS = -fPIC -shared -avoid-version $(HARU_LIB) @HAVE_HARU_TRUE@pkglib_LTLIBRARIES = libdocs_pdf.la @HAVE_HARU_TRUE@libdocs_pdf_la_SOURCES = \ @HAVE_HARU_TRUE@doc_pdf.cpp\ @HAVE_HARU_TRUE@MLB_Interface.cpp\ @HAVE_HARU_TRUE@Profile_Cross_Sections.cpp\ @HAVE_HARU_TRUE@Shapes_Report.cpp\ @HAVE_HARU_TRUE@Shapes_Summary.cpp\ @HAVE_HARU_TRUE@doc_pdf.h\ @HAVE_HARU_TRUE@MLB_Interface.h\ @HAVE_HARU_TRUE@Profile_Cross_Sections.h\ @HAVE_HARU_TRUE@Shapes_Report.h\ @HAVE_HARU_TRUE@Shapes_Summary.h @HAVE_HARU_TRUE@libdocs_pdf_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) --foreign src/modules/docs/docs_pdf/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/docs/docs_pdf/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libdocs_pdf.la: $(libdocs_pdf_la_OBJECTS) $(libdocs_pdf_la_DEPENDENCIES) $(EXTRA_libdocs_pdf_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) $(am_libdocs_pdf_la_rpath) $(libdocs_pdf_la_OBJECTS) $(libdocs_pdf_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Profile_Cross_Sections.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Shapes_Report.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Shapes_Summary.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/doc_pdf.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/docs/docs_pdf/Shapes_Summary.cpp0000664000175000017500000003745012565125412024217 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Summary.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Summarize.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Shapes_Summary.h" #define VERY_LARGE_NUMBER 9999999999. CSG_String sParam[] = {"[Sum]", "[Mean]", "[Variance]", "[Minimum]", "[Maximum]"}; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PDF_PAGE_WIDTH_A4 596 #define PDF_PAGE_HEIGHT_A4 842 #define PDF_PAGE_WIDTH_A3 PDF_PAGE_HEIGHT_A4 #define PDF_PAGE_HEIGHT_A3 (sqrt(2.) * PDF_PAGE_HEIGHT_A4) #define OFFSET_X 50 #define OFFSET_Y 50 #define LINE_SPACEMENT 12 #define SUMMARY_LAYOUT_HEADER 50 #define MAX_SUMMARY_LAYOUT_HEIGHT (PDF_PAGE_WIDTH_A3 - 2 * OFFSET_Y - LINE_SPACEMENT) #define MAX_SUMMARY_LAYOUT_WIDTH MAX_SUMMARY_LAYOUT_HEIGHT #define SUMMARY_LAYOUT_SEPARATION 30 #define MAX_SUMMARY_TABLE_WIDTH (PDF_PAGE_HEIGHT_A3 - 2 * OFFSET_X - MAX_SUMMARY_LAYOUT_WIDTH - SUMMARY_LAYOUT_SEPARATION) #define MAX_ROWS_IN_SUMMARY_LAYOUT (MAX_SUMMARY_LAYOUT_HEIGHT / TABLE_CELL_HEIGHT) #define SUMMARY_STATISTICS_GRAPH_HEIGHT 120 #define SUMMARY_STATISTICS_GRAPH_WIDTH (PDF_PAGE_WIDTH_A4 - 2 * OFFSET_X) #define SUMMARY_STATISTICS_GRAPH_SEPARATION 120 #define GRATICULE_SEPARATION 20 #define SUMMARY_TABLE_CELL_HEIGHT 13.0 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif CShapes_Summary_PDF::CShapes_Summary_PDF(){ }//constructor CShapes_Summary_PDF::~CShapes_Summary_PDF(){} void CShapes_Summary_PDF::AddClassSummaryPage(CSG_Shapes *pShapes, CSG_Table *pTable, int iClass, CSG_String sTitle){ int i; double fPaperHeight; double fRealWidth, fRealHeight; double fX, fY; CSG_Table *pClassTable; CSG_Table_Record *pRecord; CSG_Rect CanvasExtent, TableExtent; TSG_Rect Extent; Add_Page(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE); Add_Outline_Item(sTitle.c_str()); fPaperHeight = Get_Size_Page().Get_YRange(); Draw_Text(PDF_PAGE_HEIGHT_A3 - OFFSET_X, fPaperHeight - OFFSET_Y, sTitle, 25, PDF_STYLE_TEXT_ALIGN_H_RIGHT, 0.0, SG_GET_RGB(0, 0, 0)); Draw_Line(OFFSET_X, fPaperHeight - OFFSET_Y - 5, PDF_PAGE_HEIGHT_A3 - OFFSET_X, fPaperHeight - OFFSET_Y - 5, 4 ); Extent = pShapes->Get_Extent(); fRealWidth = Extent.xMax - Extent.xMin; fRealHeight = Extent.yMax - Extent.yMin; CanvasExtent.Assign(OFFSET_X, OFFSET_Y, OFFSET_X + MAX_SUMMARY_LAYOUT_WIDTH, OFFSET_Y + MAX_SUMMARY_LAYOUT_HEIGHT); _Fit_Rectangle(CanvasExtent, fRealWidth / fRealHeight, true); CanvasExtent.Deflate(GRATICULE_SEPARATION, false); Draw_Shapes(CanvasExtent, pShapes); CanvasExtent.Inflate(GRATICULE_SEPARATION, false); /*CanvasExtent.xMin = OFFSET_X + (MAX_SUMMARY_LAYOUT_WIDTH - fWidth) / 2. - GRATICULE_SEPARATION; CanvasExtent.xMax = CanvasExtent.xMin + fWidth + 2 * GRATICULE_SEPARATION; CanvasExtent.yMin = OFFSET_Y + (MAX_SUMMARY_LAYOUT_HEIGHT - fHeight) / 2. - GRATICULE_SEPARATION; CanvasExtent.yMax = CanvasExtent.yMin + fHeight + 2* GRATICULE_SEPARATION;*/ Draw_Graticule(CanvasExtent, Extent); pClassTable = SG_Create_Table(); pClassTable->Add_Field(_TL("Field"), SG_DATATYPE_String ); pClassTable->Add_Field(_TL("Value"), SG_DATATYPE_Double); for (i = 0; i < pTable->Get_Field_Count(); i++){ pRecord = pClassTable->Add_Record(); pRecord->Set_Value(0, pTable->Get_Field_Name(i)); pRecord->Set_Value(1, pTable->Get_Record(iClass)->asDouble(i)); } fY = fPaperHeight - OFFSET_Y - SUMMARY_LAYOUT_HEADER; fX = PDF_PAGE_HEIGHT_A3 - OFFSET_X - MAX_SUMMARY_TABLE_WIDTH; TableExtent.Assign(fX, fY, fX + MAX_SUMMARY_TABLE_WIDTH, OFFSET_Y); Draw_Table(TableExtent, pClassTable, SUMMARY_TABLE_CELL_HEIGHT, 0.0); }//method void CShapes_Summary_PDF::AddSummaryStatisticsPage(CSG_Table* pTable){ int i,j; double fX, fY; double fPaperHeight; CSG_Points Data; CSG_String *pNames; CSG_Rect r; fPaperHeight = Get_Size_Page().Get_YRange(); pNames = new CSG_String [pTable->Get_Record_Count()]; for (i = 0; i < pTable->Get_Record_Count(); i++){ pNames[i] = pTable->Get_Record(i)->asString(0); }//for for (i = 1; i < pTable->Get_Field_Count(); i++){ if ((i-1)%3 == 0){ Add_Page(); }//if Data.Clear(); for (j = 0; j < pTable->Get_Record_Count(); j++){ Data.Add(0.0, pTable->Get_Record(j)->asDouble(i)); }//for fY = OFFSET_Y + ((i-1)%3) * (SUMMARY_STATISTICS_GRAPH_HEIGHT + SUMMARY_STATISTICS_GRAPH_SEPARATION); fY = fPaperHeight - fY; fX = OFFSET_X; Draw_Text(fX, fY + 10, pTable->Get_Field_Name(i), 14); r.Assign(fX, fY - 25 - SUMMARY_STATISTICS_GRAPH_HEIGHT, fX + SUMMARY_STATISTICS_GRAPH_WIDTH, fY - 25 ); AddBarGraphStatistics(Data, pNames, r); }//for*/ }//method void CShapes_Summary_PDF::AddBarGraphStatistics(CSG_Points &Data, CSG_String *pNames, const CSG_Rect &r){ int i; int iMag; int iNumLines; double fMinLine = 0; double fWidth; double fMax, fMin; double fStep; double fX, fY; double fPaperHeight; double fAngle; CSG_String sValue; CSG_Points Points; fPaperHeight = Get_Size_Page().Get_YRange(); fMin = fMax = Data[0].y; for (i = 0; i < Data.Get_Count(); i++){ if (Data[i].y > fMax){ fMax = Data[i].y; } if (Data[i].y < fMin){ fMin = Data[i].y; } fMin = M_GET_MIN(0, fMin); } if (fMin != fMax){ iMag = (int) (log(fMax - fMin) / log(10.0)); fStep = (pow(10.0, (double) iMag)); if (fStep == 0){ fStep = 1.; } fMinLine= (long)(((long)(fMin/fStep)) *fStep); iNumLines = (int) ((fMax - fMin) / fStep); while (iNumLines < 8){ fStep = fStep / 2.0; iNumLines = (int) ((fMax - fMin) / fStep); } iNumLines = (int) ((fMax - fMinLine) / fStep); } else{ fStep = fMin = 0; iNumLines = 1; fMinLine = fMax; } for (i = 0; i < iNumLines; i++) { fY = r.Get_YMin() + ((fMinLine + fStep * i - fMin) / (fMax - fMin)) * r.Get_YRange(); if (fY <= r.Get_YMax() && fY >= r.Get_YMin()) { Draw_Line(r.Get_XMin(), fY, r.Get_XMax(), fY); } } fWidth = (double) r.Get_XRange() / (double) (Data.Get_Count()); for (i = 0; i < Data.Get_Count(); i++) { fX = r.Get_XMin() + i * fWidth; fY = r.Get_YMin(); //fY = fPaperHeight - fY; Draw_Rectangle(fX, fY, fX + fWidth, fY + r.Get_YRange() * ((Data[i].y - fMin) / (fMax - fMin)), PDF_STYLE_POLYGON_FILLSTROKE, 0xaa0000); } fAngle = 3.14159/ 180 * 60; for (i = 0; i < Data.Get_Count(); i++) { fX = r.Get_XMin() + i * fWidth + fWidth / 2.; Draw_Text(fX - 5, fY - 5, pNames[i], 9, PDF_STYLE_TEXT_ALIGN_V_TOP|PDF_STYLE_TEXT_ALIGN_H_RIGHT, fAngle); Draw_Line(fX, fY, fX, fY - 5, 1); } Draw_Line(r.Get_XMin(), r.Get_YMin(), r.Get_XMin(), r.Get_YMax(), 4); Draw_Line(r.Get_XMin(), r.Get_YMin(), r.Get_XMax(), r.Get_YMin(), 4); }//method /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Summary::CShapes_Summary(void){ CSG_Parameter *pNode; CSG_String sName; Parameters.Set_Name(_TL("Shapes Summary Report")); Parameters.Set_Description(_TW("(c) 2004 by Victor Olaya. summary.")); pNode = Parameters.Add_Shapes(NULL, "SHAPES", _TL("Shapes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Table_Field(pNode, "FIELD", _TL("Field"), _TL("")); Parameters.Add_Table(NULL, "TABLE", _TL("Summary Table"), _TL(""), PARAMETER_OUTPUT); pNode = Parameters.Add_Node(NULL, "PDFNODE", _TL("PDF Docs"), _TL("")); Parameters.Add_Value(pNode, "PDF", _TL("Create PDF Docs"), _TL("Create PDF Docs"), PARAMETER_TYPE_Bool, true); Parameters.Add_FilePath(pNode, "OUTPUTPATH", _TL("Folder"), _TL("Folder"), _TL(""), _TL(""), true, true); m_pExtraParameters = Add_Parameters("EXTRA", _TL("Field for Summary"), _TL("")); }//constructor CShapes_Summary::~CShapes_Summary(void) {} bool CShapes_Summary::On_Execute(void){ int i,j; CSG_Table *pShapesTable; CSG_Parameter **pExtraParameter; CSG_String sName, sFilePath; m_iField = Parameters("FIELD")->asInt(); m_pShapes = Parameters("SHAPES")->asShapes(); m_pTable = Parameters("TABLE")->asTable(); pShapesTable = m_pShapes; m_bIncludeParam = new bool [pShapesTable->Get_Field_Count() * 5]; pExtraParameter = new CSG_Parameter* [pShapesTable->Get_Field_Count() * 5]; for (i = 0; i < pShapesTable->Get_Field_Count(); i++){ for (j = 0; j < 5; j++){ if( SG_Data_Type_is_Numeric(pShapesTable->Get_Field_Type(i)) ) { //is numeric field sName = pShapesTable->Get_Field_Name(i); sName.Append(sParam[j]); 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); m_bIncludeParam[i * 5 + j] = true; }//if else{ m_bIncludeParam[i * 5 + j] = false; }//else }//for }//for if(Dlg_Parameters("EXTRA")){ for (i = 0; i < pShapesTable->Get_Field_Count() * 5; i++){ sName = SG_Get_String(i,0); if (m_bIncludeParam[i]){ m_bIncludeParam[i] = Get_Parameters("EXTRA")->Get_Parameter(sName.c_str())->asBool(); }//if }//for Summarize(); if (Parameters("PDF")->asBool()){ if (Parameters("OUTPUTPATH")->asString()){ sName = _TL("Summary_"); sName.Append(m_pShapes->Get_Name()); m_DocEngine.Open(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE, sName); CreatePDFDocs(); sFilePath = SG_File_Make_Path(Parameters("OUTPUTPATH")->asString(), sName, SG_T("pdf")); if (m_DocEngine.Save(sFilePath)){ if (!m_DocEngine.Close()){ Message_Add(_TL("\n\n ** Error : Could not close PDF engine ** \n\n")); } }//if else{ Message_Add(_TL("\n\n ** Error : Could not save PDF file ** \n\n")); }//else }//if }//if m_pExtraParameters->Destroy(); delete [] m_bIncludeParam; return true; }//if m_pExtraParameters->Destroy(); delete [] m_bIncludeParam; return false; }//method void CShapes_Summary::CreatePDFDocs(){ CSG_Shapes *pShapes; CSG_Shape *pShape; CSG_Table *pShapesTable; int i,j; m_DocEngine.Add_Page_Title (_TL("Summary"), PDF_TITLE_01, PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE); pShapesTable = m_pShapes; pShapes = new CSG_Shapes(); for (i = 0; i < (int)m_ClassesID.size(); i++){ Set_Progress(i,(int)m_ClassesID.size()); pShapes->Create(m_pShapes->Get_Type()); for (j = 0; j < m_pShapes->Get_Count(); j++){ if (m_pClasses[j] == i){ pShape = pShapes->Add_Shape(); pShape->Assign(m_pShapes->Get_Shape(j)); }//if }//for m_DocEngine.AddClassSummaryPage(pShapes, m_pTable, i, m_ClassesID[i]); }//for if (m_pTable->Get_Record_Count() > 1){ m_DocEngine.Add_Page_Title (_TL("Statistics"), PDF_TITLE_01, PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_PORTRAIT); m_DocEngine.AddSummaryStatisticsPage(m_pTable); }//if delete pShapes; }//method void CShapes_Summary::Summarize(){ int i,j; CSG_Table *pShapesTable; 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; m_ClassesID.clear(); pShapesTable = m_pShapes; m_pClasses = new int[pShapesTable->Get_Record_Count()]; for (i = 0; i < pShapesTable->Get_Record_Count(); i++){ pRecord = pShapesTable->Get_Record(i); sName = pRecord->asString(m_iField); for (j = 0; j < (int)m_ClassesID.size(); j++){ if (!m_ClassesID[j].CmpNoCase(sName)){ m_pClasses[i] = j; break; }//if }//for if (j == m_ClassesID.size()){ m_pClasses[i] = j; m_ClassesID.push_back(sName); }//if }//for m_pTable->Create((CSG_Table*)NULL); m_pTable->Set_Name(_TL("Summary Table")); m_pTable->Add_Field(_TL("Class"), SG_DATATYPE_String); m_pTable->Add_Field(_TL("Count"), SG_DATATYPE_Int); m_pCount = new int[m_ClassesID.size()]; pSum = new float[m_ClassesID.size()]; pMax = new float[m_ClassesID.size()]; pMin = new float[m_ClassesID.size()]; pVar = new float[m_ClassesID.size()]; for (i = 0; i < (int)m_ClassesID.size(); i++){ m_pCount[i] = 0; }//for for (i = 0; i < pShapesTable->Get_Record_Count(); i++){ m_pCount[m_pClasses[i]]++; }//for for (i = 0; i < (int)m_ClassesID.size(); i++){ pRecord = m_pTable->Add_Record(); sName = m_ClassesID[i]; pRecord->Set_Value(0,sName.c_str()); pRecord->Set_Value(1,m_pCount[i]); }//for for (i = 0; i < pShapesTable->Get_Field_Count() * 5; i++){ if (m_bIncludeParam[i]){ iField = (int) (i / 5); iParam = i % 5; sName = pShapesTable->Get_Field_Name(iField); sName.Append(sParam[iParam]); m_pTable->Add_Field(sName.c_str(), SG_DATATYPE_Double); if (iField != iLastField){ for (j = 0; j < (int)m_ClassesID.size(); j++){ pSum[j] = 0; pMax[j] = -(float)VERY_LARGE_NUMBER; pMin[j] = (float)VERY_LARGE_NUMBER; pVar[j] = 0; }//for for (j = 0; j < pShapesTable->Get_Record_Count(); j++){ pRecord = pShapesTable->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 }//for }//if iField = m_pTable->Get_Field_Count() - 1; for (j = 0; j < (int)m_ClassesID.size(); j++){ pRecord = m_pTable->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 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/docs/docs_pdf/Shapes_Summary.h0000664000175000017500000000552412565125412023661 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Summary.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Summarize.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_pdf.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Summary_PDF : public CSG_Doc_PDF { public: CShapes_Summary_PDF(); virtual ~CShapes_Summary_PDF(); void AddClassSummaryPage(CSG_Shapes*, CSG_Table*, int, CSG_String); void AddSummaryStatisticsPage(CSG_Table* pTable); private: void AddBarGraphStatistics(CSG_Points &, CSG_String*, const CSG_Rect &); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Summary : public CSG_Module { public: CShapes_Summary(void); virtual ~CShapes_Summary(void); protected: virtual bool On_Execute(void); private: int m_iField; CSG_Shapes *m_pShapes; CSG_Table *m_pTable; bool *m_bIncludeParam; std::vector m_ClassesID; int *m_pClasses; int *m_pCount; CSG_Parameters *m_pExtraParameters; CShapes_Summary_PDF m_DocEngine; void Summarize(); void CreatePDFDocs(); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/docs/docs_pdf/doc_pdf.h0000664000175000017500000003217512565125412022321 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_pdf.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_pdf // // // //-------------------------------------------------------// // // // doc_pdf.h // // // // Copyright (C) 2005 by // // Victor Olaya, 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__doc_pdf_H #define HEADER_INCLUDED__doc_pdf_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PDF_TABLE_CELL_HEIGHT_DEFAULT 20.0 #define PDF_TABLE_HEADER_HEIGHT 40.0 //--------------------------------------------------------- #define PDF_PAGE_ORIENTATION_PREVIOUS -1 #define PDF_PAGE_ORIENTATION_PORTRAIT 0 #define PDF_PAGE_ORIENTATION_LANDSCAPE 1 //--------------------------------------------------------- #define PDF_STYLE_POINT_CIRCLE 0x00000001 #define PDF_STYLE_POINT_SQUARE 0x00000002 #define PDF_STYLE_LINE_END_BUTT 0x00000004 #define PDF_STYLE_LINE_END_ROUND 0x00000008 #define PDF_STYLE_LINE_END_SQUARE 0x00000010 #define PDF_STYLE_LINE_JOIN_MITER 0x00000020 #define PDF_STYLE_LINE_JOIN_ROUND 0x00000040 #define PDF_STYLE_LINE_JOIN_BEVEL 0x00000080 #define PDF_STYLE_POLYGON_STROKE 0x00000100 #define PDF_STYLE_POLYGON_FILL 0x00000200 #define PDF_STYLE_POLYGON_FILLSTROKE (PDF_STYLE_POLYGON_STROKE|PDF_STYLE_POLYGON_FILL) //--------------------------------------------------------- #define PDF_STYLE_TEXT_ALIGN_H_LEFT 0x00000001 #define PDF_STYLE_TEXT_ALIGN_H_CENTER 0x00000002 #define PDF_STYLE_TEXT_ALIGN_H_RIGHT 0x00000004 #define PDF_STYLE_TEXT_ALIGN_V_TOP 0x00000008 #define PDF_STYLE_TEXT_ALIGN_V_CENTER 0x00000010 #define PDF_STYLE_TEXT_ALIGN_V_BOTTOM 0x00000020 #define PDF_STYLE_TEXT_UNDERLINE 0x00000040 #define PDF_STYLE_TEXT_STROKE 0x00000080 //---------------------------------------------------------- #define PDF_GRAPH_TYPE_BARS 1 #define PDF_GRAPH_TYPE_LINES 2 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- typedef enum ESG_PDF_Font_Type { PDF_FONT_DEFAULT = 0, PDF_FONT_Helvetica = 0, PDF_FONT_Helvetica_Bold, PDF_FONT_Helvetica_Oblique, PDF_FONT_Helvetica_BoldOblique, PDF_FONT_Times_Roman, PDF_FONT_Times_Bold, PDF_FONT_Times_Italic, PDF_FONT_Times_BoldItalic, PDF_FONT_Courier, PDF_FONT_Courier_Bold, PDF_FONT_Courier_Oblique, PDF_FONT_Courier_BoldOblique, PDF_FONT_Symbol, PDF_FONT_ZapfDingbats } TSG_PDF_Font_Type; //--------------------------------------------------------- typedef enum ESG_PDF_Page_Size { PDF_PAGE_SIZE_A4 = 1, PDF_PAGE_SIZE_A3, PDF_PAGE_SIZE_PREVIOUS } TSG_PDF_Page_Size; //--------------------------------------------------------- typedef enum ESG_PDF_Title_Level { PDF_TITLE = 0, PDF_TITLE_01, PDF_TITLE_02, PDF_TITLE_NONE } TSG_PDF_Title_Level; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class docs_pdf_EXPORT CSG_Doc_PDF { public: CSG_Doc_PDF(void); CSG_Doc_PDF(TSG_PDF_Page_Size Size, int Orientation = PDF_PAGE_ORIENTATION_PORTRAIT, const SG_Char *Title = NULL); virtual ~CSG_Doc_PDF(void); static const SG_Char * Get_Version (void); bool Open (TSG_PDF_Page_Size Size = PDF_PAGE_SIZE_A4, int Orientation = PDF_PAGE_ORIENTATION_PORTRAIT, const SG_Char *Title = NULL); bool Open (const SG_Char *Title); bool Close (void); bool Save (const SG_Char *FileName); bool Is_Open (void) { return( m_pPDF != NULL ); } bool Is_Ready_To_Draw (void) { return( m_pPDF != NULL ); } static double Get_Page_To_Meter (void); bool Add_Page (void); bool Add_Page (TSG_PDF_Page_Size Size, int Orientation = PDF_PAGE_ORIENTATION_PORTRAIT); bool Add_Page (double Width, double Height); bool Add_Page_Title (const SG_Char *Title, TSG_PDF_Title_Level Level = PDF_TITLE, TSG_PDF_Page_Size Size = PDF_PAGE_SIZE_PREVIOUS, int Orientation = PDF_PAGE_ORIENTATION_PREVIOUS); bool Add_Outline_Item (const SG_Char *Title); bool Set_Size_Page (TSG_PDF_Page_Size Size, int Orientation = PDF_PAGE_ORIENTATION_PORTRAIT); bool Set_Size_Page (double Width, double Height); const CSG_Rect & Get_Size_Page (void) { return( m_Size_Paper ); } const CSG_Rect & Get_Margins (void) { return( m_Size_Margins ); } void Layout_Set_Box_Space (double Space, bool bPercent); bool Layout_Add_Box (double xMin_Percent, double yMin_Percent, double xMax_Percent, double yMax_Percent, const CSG_String &ID = ""); bool Layout_Add_Box (const CSG_Rect &Box_Percent, const CSG_String &ID = ""); const CSG_Rect & Layout_Get_Box (int iBox) { return( iBox >= 0 && iBox < m_Boxes.Get_Count() ? m_Boxes[iBox] : m_Size_Margins ); } const CSG_Rect & Layout_Get_Box (const CSG_String &ID = ""); bool Draw_Point (double x, double y, double Width, int Style = PDF_STYLE_POINT_SQUARE|PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_WHITE, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0); bool Draw_Line (double xa, double ya, double xb, double yb , int Width = 0, int Color = SG_COLOR_BLACK, int Style = 0); bool Draw_Line (CSG_Points &Points , int Width = 0, int Color = SG_COLOR_BLACK, int Style = 0); bool Draw_Rectangle (double xa, double ya, double xb, double yb , int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_WHITE, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0); bool Draw_Rectangle (const CSG_Rect &r , int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_WHITE, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0); bool Draw_Polygon (CSG_Points &Points , int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0); bool Draw_Text (double x, double y, const SG_Char *Text, int Size, int Style = PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP, double Angle = 0.0, int Color = SG_COLOR_BLACK, TSG_PDF_Font_Type Font = PDF_FONT_DEFAULT); bool Draw_Text (double x, double y, CSG_Strings &Text, int Size, int Style = PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP, double Angle = 0.0, int Color = SG_COLOR_BLACK, TSG_PDF_Font_Type Font = PDF_FONT_DEFAULT); bool Draw_Image (double x, double y, double dx, double dy , const SG_Char *FileName); bool Draw_Image (const CSG_Rect &r , const SG_Char *FileName); bool Draw_Graticule (const CSG_Rect &r, const CSG_Rect &rWorld, int Size = 10); void Draw_Curve (CSG_Points &Data, const CSG_Rect &r, int iGraphType); bool Draw_Table (const CSG_Rect &r, CSG_Table *pTable , double CellHeight = 0.0, double HeaderHeightRel = 1.5); bool Draw_Table (const CSG_Rect &r, CSG_Table *pTable, int nColumns , double CellHeight = 0.0, double HeaderHeightRel = 1.5); bool Draw_Shape (const CSG_Rect &r, CSG_Shape *pShape , int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0, CSG_Rect *prWorld = NULL); bool Draw_Shapes (const CSG_Rect &r, CSG_Shapes *pShapes, int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0, CSG_Rect *prWorld = NULL); bool Draw_Grid (const CSG_Rect &r, CSG_Grid *pGrid, const CSG_Colors &Colors, double zMin = 0.0, double zMax = 0.0, int Style = 0, CSG_Rect *prWorld = NULL); protected: bool _Fit_Rectangle (double &x, double &y, double &dx, double &dy, double XToY_Ratio, bool bShrink); bool _Fit_Rectangle (CSG_Rect &r, double XToY_Ratio, bool bShrink); bool _Add_Outline_Item (const SG_Char *Title, struct _HPDF_Dict_Rec *pPage, TSG_PDF_Title_Level Level = PDF_TITLE); bool _Draw_Ruler (const CSG_Rect &r, double zMin, double zMax, bool bHorizontal, bool bAscendent, bool bTickAtTop); bool _Draw_Text (double x, double y, const SG_Char *Text, int Size, int Style, double Angle, int Color, TSG_PDF_Font_Type Font); bool _Draw_Table (CSG_Rect r, CSG_Table *pTable, int iRecord, int nRecords, double CellHeight, double HeaderHeightRel); bool _Draw_Shape (CSG_Rect r, CSG_Shape *pShape, double xMin, double yMin, double World2PDF, int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0, int Point_Width = 5); TSG_PDF_Title_Level _Get_Lowest_Outline_Level (void); private: bool m_Boxes_Space_bPercent; int m_nPages; double m_Boxes_Space; CSG_Rect m_Size_Paper, m_Size_Margins; CSG_Rects m_Boxes_Percent, m_Boxes; CSG_Strings m_Boxes_ID; struct _HPDF_Doc_Rec *m_pPDF; struct _HPDF_Dict_Rec *m_pPage; struct _HPDF_Dict_Rec *m_pOutline_Last_Level_0, *m_pOutline_Last_Level_1, *m_pOutline_Last_Level_2; struct _HPDF_Dict_Rec * _Get_Font (TSG_PDF_Font_Type Font); void _Layout_Set_Boxes (void); void _Layout_Set_Box (int iBox); bool _Set_Style_FillStroke (int Style, int Fill_Color, int Line_Color, int Line_Width); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__doc_pdf_H saga-2.2.3/src/modules/docs/docs_pdf/Profile_Cross_Sections.cpp0000664000175000017500000012736512565125412025704 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Profile_Cross_Sections.cpp 1230 2011-11-22 11:12:10Z oconrad $ *********************************************************/ /******************************************************************************* CrossSections.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Profile_Cross_Sections.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define OFFSET_X 100 #define OFFSET_Y 50 #define TABLE_WIDTH 450 #define TABLE_LANDSCAPE_WIDTH 680 #define TABLE_OFFSET_X 70 #define TABLE_CELLPAD 10 #define SECTIONS_PER_PAGE 3 #define CROSS_SECTION_HEIGHT 200 #define CROSS_SECTION_WIDTH 400 #define PROFILE_HEIGHT 320 #define PROFILE_WIDTH 1000 #define GUITAR_LEYEND_WIDTH 50 #define GUITAR_LEYEND_HEIGHT 230 #define GUITAR_WIDTH PROFILE_WIDTH #define GUITAR_HEIGHT GUITAR_LEYEND_HEIGHT #define SEPARATION 35 #define VOLUMES_TABLE_COLUMNS 7 #define VOLUMES_TABLE_COLUMN_WIDTH ((596 - 2 * OFFSET_X) / VOLUMES_TABLE_COLUMNS) #define VOLUMES_TABLE_ROW_HEIGHT 20 #define VOLUMES_TABLE_HEADER_SEPARATION 35 #define VOLUMES_TABLE_MAX_ROWS 30 #define SLOPE_RATIO (1. / 3.) #define LONG_SEGMENT 5000. /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //Compute the dot product AB ? BC double dot(double *A, double *B, double *C){ double AB[2],BC[2]; AB[0] = B[0]-A[0]; AB[1] = B[1]-A[1]; BC[0] = C[0]-B[0]; BC[1] = C[1]-B[1]; double dot = AB[0] * BC[0] + AB[1] * BC[1]; return dot; } //--------------------------------------------------------- //Compute the cross product AB x AC double cross(double *A, double *B, double *C){ double AB[2],AC[2]; AB[0] = B[0]-A[0]; AB[1] = B[1]-A[1]; AC[0] = C[0]-A[0]; AC[1] = C[1]-A[1]; double cross = AB[0] * AC[1] - AB[1] * AC[0]; return cross; } //--------------------------------------------------------- //Compute the distance from A to B double distance(double *A, double *B){ double d1 = A[0] - B[0]; double d2 = A[1] - B[1]; return sqrt(d1*d1+d2*d2); } //--------------------------------------------------------- //Compute the distance from AB to C double linePointDist(double *A, double *B, double *C){ double dist = cross(A,B,C) / distance(A,B); return fabs(dist); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SLOPE_TRANSITION 1 #define DITCH_WIDTH 1 CProfile_Cross_Sections_PDF::CProfile_Cross_Sections_PDF(){} CProfile_Cross_Sections_PDF::~CProfile_Cross_Sections_PDF(){} void CProfile_Cross_Sections_PDF::AddCrossSections(TSG_Point ** pCrossSections, double *pHeight, TSG_Point * pRoadSection, int iSections, int iCrossSectionPoints, int iRoadPoints){ int i,j; std::vector ModifiedRoadSection; std::vector ModifiedCrossSection; TSG_Point *pModifiedRoadSection; TSG_Point *pModifiedCrossSection; int iCrossSectionPointsB; int iRoadPointsB; Add_Page_Title (_TL("Cross Sections"), PDF_TITLE_01, PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_PORTRAIT); for (i = 0; i < iSections; i++){ m_iOffsetY = OFFSET_Y + (int)(CROSS_SECTION_HEIGHT * 1.1 * (i % SECTIONS_PER_PAGE)); if (m_iOffsetY == OFFSET_Y){ Add_Page(); }//if iCrossSectionPointsB = iCrossSectionPoints; iRoadPointsB = iRoadPoints; AdjustSections(pCrossSections[i], pRoadSection, ModifiedCrossSection, ModifiedRoadSection, pHeight[i], iCrossSectionPointsB, iRoadPointsB); pModifiedCrossSection = new TSG_Point [iCrossSectionPointsB]; pModifiedRoadSection = new TSG_Point [iRoadPointsB]; for (j = 0; j < iCrossSectionPointsB; j++){ pModifiedCrossSection[j] = ModifiedCrossSection[j]; }//for for (j = 0; j < iRoadPointsB; j++){ pModifiedRoadSection[j] = ModifiedRoadSection[j]; }//for AddCrossSection(pModifiedCrossSection, pModifiedRoadSection, iCrossSectionPointsB, iRoadPointsB); delete [] pModifiedRoadSection; delete [] pModifiedCrossSection; }//for }//method void CProfile_Cross_Sections_PDF::AddCrossSection(TSG_Point * pCrossSection, TSG_Point * pRoadSection, int iCrossSectionPoints, int iRoadPoints){ int i; int iMag; int iNumLines; int iFirstPoint, iLastPoint; double fMinLine = 0; double fMaxY, fMinY; double fMaxX, fMinX; double fStep; double fX, fY; double fOffsetX; double fDifX, fDifY; double fRatio; double fHeight; CSG_String sValue; CSG_Points Points; iFirstPoint = 0; iLastPoint = iCrossSectionPoints - 1; for (i = 1; i < iCrossSectionPoints; i++) { if (pCrossSection[i].x > pRoadSection[0].x){ iFirstPoint = i - 1; break; }//if }//for for (i = 1; i < iCrossSectionPoints; i++) { if (pCrossSection[i].x > pRoadSection[iRoadPoints - 1].x){ iLastPoint = i; break; }//if }//for fMinX = pCrossSection[iFirstPoint].x; fMaxX = pCrossSection[iLastPoint].x; fDifX = fMaxX - fMinX; fMaxY = pCrossSection[0].y; fMinY = pCrossSection[0].y; for (i = iFirstPoint ; i < iLastPoint + 1; i++) { if (pCrossSection[i].y > fMaxY) { fMaxY = pCrossSection[i].y; }// if if (pCrossSection[i].y < fMinY) { fMinY = pCrossSection[i].y; }// if }//for for (i = 0; i < iRoadPoints; i++) { if (pRoadSection[i].y > fMaxY) { fMaxY = pRoadSection[i].y; }// if if (pRoadSection[i].y < fMinY) { fMinY = pRoadSection[i].y; }// if }//for fDifY = fMaxY - fMinY; fRatio = (fDifX / fDifY) / (CROSS_SECTION_WIDTH / CROSS_SECTION_HEIGHT); if (fRatio > 1){ fMaxY = fMaxY + fDifY / 2. * (fRatio - 1.); fMinY = fMinY - fDifY / 2. * (fRatio - 1.); }//if else{ fMaxX = fMaxX + fDifX / 2. * (1. / fRatio - 1.); fMinX = fMinX - fDifX / 2. * (1. / fRatio - 1.); }//else fMaxX = fMaxX + fDifX * .05; fMinX = fMinX - fDifX * .05; fMaxY = fMaxY + fDifY * .05; fMinY = fMinY - fDifY * .05; iMag = (int) (log(fMaxY - fMinY) / log(10.0)); fStep = (double) ((int) pow(10.0, (double) iMag)); if (fStep == 0){ fStep = 1.; }//if if (fMinY < 0) { iMag = (int) (log(fabs(fMinY)) / log(10.0)); fMinLine = -(int) pow(10.0, (double) iMag); }// if else { fMinLine=(int)(((int)(fMinY/fStep)) *fStep); }//else iNumLines = (int) ((fMaxY - fMinY) / fStep); while (iNumLines < 8) { fStep = fStep / 2.0; iNumLines = (int) ((fMaxY - fMinY) / fStep); }// while iNumLines = (int) ((fMaxY - fMinLine) / fStep); fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); //horizontal lines for (i = 0; i < iNumLines; i++) { fY = m_iOffsetY + CROSS_SECTION_HEIGHT - ((fMinLine + fStep * i - fMinY) / (fMaxY - fMinY)) * CROSS_SECTION_HEIGHT; if (fY <= m_iOffsetY + CROSS_SECTION_HEIGHT && fY >= m_iOffsetY) { fY = fHeight - fY; sValue = SG_Get_String(fMinLine + fStep * (double) i); Draw_Text(OFFSET_X - 10, fY, SG_Get_String(fMinLine + fStep * (double) i).c_str(), 9, PDF_STYLE_TEXT_ALIGN_H_RIGHT); Draw_Line(OFFSET_X, fY, OFFSET_X - 5, fY, 0); }// if }// for iMag = (int) (log(fMaxX - fMinX) / log(10.0)); fStep = (double) pow(10.0, (double) iMag); iNumLines = (int) ((fMaxX-fMinX) / fStep); while (iNumLines < 3) { fStep = fStep / 2.0; iNumLines = (int) ((fMaxX-fMinX) / fStep); }// while fMinLine = (int)(((int)(fMinX/fStep)) * fStep); while (fMinLine= OFFSET_X && fX < OFFSET_X + CROSS_SECTION_WIDTH){ if (fabs(fStep * (double)i+fMinLine) > 100000) { sValue = SG_Get_String(fStep * (double)i+fMinLine); }// if else { sValue = SG_Get_String(fStep * (double)i+fMinLine, 2, true); }// else Draw_Line (fX, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT, fX, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT - 10); Draw_Text(fX, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT - 15, SG_Get_String(fMinLine + fStep * (double) i).c_str(), 9, PDF_STYLE_TEXT_ALIGN_H_CENTER | PDF_STYLE_TEXT_ALIGN_V_TOP ); }//if }// for //axis Draw_Line (OFFSET_X, fHeight - m_iOffsetY, OFFSET_X, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT, 2); Draw_Line (OFFSET_X, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT, OFFSET_X + CROSS_SECTION_WIDTH, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT, 2); //cross sections fY = m_iOffsetY + CROSS_SECTION_HEIGHT - CROSS_SECTION_HEIGHT * ((pCrossSection[iFirstPoint].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_X + CROSS_SECTION_WIDTH * ((pCrossSection[iFirstPoint].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX,fY); for (i = iFirstPoint + 1; i < iLastPoint + 1; i++) { fY = m_iOffsetY + CROSS_SECTION_HEIGHT - CROSS_SECTION_HEIGHT * ((pCrossSection[i].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_X + CROSS_SECTION_WIDTH * ((pCrossSection[i].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX,fY); if (pCrossSection[i].x > fMaxX){ break; }//if }// for Draw_Line(Points, 2, 0x00bb00); fY = m_iOffsetY + CROSS_SECTION_HEIGHT - CROSS_SECTION_HEIGHT * ((pRoadSection[0].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_X + CROSS_SECTION_WIDTH * ((pRoadSection[0].x - fMinX) / (fMaxX - fMinX)); Points.Clear(); Points.Add(fX,fY); for (i = 1; i < iRoadPoints; i++) { fY = m_iOffsetY + CROSS_SECTION_HEIGHT - CROSS_SECTION_HEIGHT * ((pRoadSection[i].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_X + CROSS_SECTION_WIDTH * ((pRoadSection[i].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX,fY); }// for Draw_Line(Points, 0, 0x0000bb); }//method void CProfile_Cross_Sections_PDF::AddVolumesTable(TSG_Point * pProfile, TSG_Point ** pCrossSections, double *pHeight, TSG_Point * pRoadSection, int iSections, int iCrossSectionPoints, int iRoadPoints){ int i,j; int iRow; int iRowsWritten = 0; double fDist; double fX,fY; double fXBox, fYBox; double fIn, fOut; double fInPrev, fOutPrev; double fVolume; double fHeight; CSG_String sHeader[] = {_TL("Section"),_TL("Dist."),_TL("Area +"),_TL("Area -"),_TL("Partial D."),_TL("Vol. +"), _TL("Vol. -")}; Add_Page_Title(_TL("Volumes"), PDF_TITLE_01); fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); for (i = 0; i < iSections; i++){ iRow = iRowsWritten % VOLUMES_TABLE_MAX_ROWS; if (iRow == 0){ Add_Page(); Draw_Rectangle(OFFSET_X, fHeight - OFFSET_Y, OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * VOLUMES_TABLE_COLUMNS, fHeight - OFFSET_Y - VOLUMES_TABLE_ROW_HEIGHT); fY = OFFSET_Y + VOLUMES_TABLE_ROW_HEIGHT * .6; fY = fHeight - fY; for (j = 0; j < VOLUMES_TABLE_COLUMNS; j++){ fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * j + VOLUMES_TABLE_COLUMN_WIDTH / 2.; Draw_Text(fX, fY, sHeader[j].c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * (j + 1); Draw_Line(fX, fHeight - OFFSET_Y, fX, fHeight - (OFFSET_Y + VOLUMES_TABLE_ROW_HEIGHT), 0); }//for if (i){ i--; }//if }//if for (j = 0; j < 4; j++){ fYBox = OFFSET_Y + VOLUMES_TABLE_HEADER_SEPARATION + VOLUMES_TABLE_ROW_HEIGHT * iRow; fYBox = fHeight - fYBox; fXBox = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * j; Draw_Rectangle(fXBox, fYBox, fXBox + VOLUMES_TABLE_COLUMN_WIDTH, fYBox - VOLUMES_TABLE_ROW_HEIGHT); }//for fDist = pProfile[i].x; fY = OFFSET_Y + VOLUMES_TABLE_HEADER_SEPARATION + VOLUMES_TABLE_ROW_HEIGHT * (iRow + .6); fY = fHeight - fY; fX = OFFSET_X + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(i,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fDist,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); CalculateAreas(pCrossSections[i], pRoadSection, pHeight[i], iCrossSectionPoints, iRoadPoints,fIn, fOut); fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * 2 + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fIn,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * 3 + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fOut,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); if (iRow > 0){ for (j = 4; j < 7; j++){ fYBox = OFFSET_Y + VOLUMES_TABLE_HEADER_SEPARATION + VOLUMES_TABLE_ROW_HEIGHT * (iRow - .5); fYBox = fHeight - fYBox; fXBox = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * j; Draw_Rectangle(fXBox, fYBox, fXBox + VOLUMES_TABLE_COLUMN_WIDTH, fYBox - VOLUMES_TABLE_ROW_HEIGHT); }//for fY = OFFSET_Y + VOLUMES_TABLE_HEADER_SEPARATION + VOLUMES_TABLE_ROW_HEIGHT * (iRow + .1) ; fY = fHeight - fY; fDist = (pProfile[i].x - pProfile[i-1].x); fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * 4 + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fDist,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); fVolume = (pProfile[i].x - pProfile[i-1].x) * (fIn + fInPrev) / 2.; fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * 5 + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fVolume,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); fVolume = (pProfile[i].x - pProfile[i-1].x) * (fOut + fOutPrev) / 2.; fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * 6 + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fVolume,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); }//if fInPrev = fIn; fOutPrev = fOut; iRowsWritten++; }//for }//Method void CProfile_Cross_Sections_PDF::AdjustSections(TSG_Point * pCrossSection, TSG_Point * pRoadSection, std::vector &ModifiedCrossSection, std::vector &ModifiedRoadSection, double fHeight, int &iCrossSectionPoints, int &iRoadPoints){ bool bDitchAdded; int i,j; int iSgn; int iRoadPointsToAdd = 0; int iCrossSectionPointsToAdd = 0; double fX, fY; TSG_Point P; ModifiedCrossSection.clear(); ModifiedRoadSection.clear(); //left half for (i = 0 ; i < iCrossSectionPoints - 1; i++){ if (pCrossSection[i].x < pRoadSection[0].x && pCrossSection[i+1].x >= pRoadSection[0].x){ break; }//if }//for if (i == iCrossSectionPoints - 1){ if (pRoadSection[0].y + fHeight < pCrossSection[0].y){ P.x = pRoadSection[0].x - 2* DITCH_WIDTH * SLOPE_TRANSITION - DITCH_WIDTH - fabs(pCrossSection[0].y - pRoadSection[0].y - fHeight) / SLOPE_RATIO; P.y = pCrossSection[0].y - fHeight; ModifiedRoadSection.push_back(P); P.y = pCrossSection[0].y; ModifiedCrossSection.push_back(P); iCrossSectionPointsToAdd++; iRoadPointsToAdd++; P.x = pRoadSection[0].x - 2* DITCH_WIDTH * SLOPE_TRANSITION - DITCH_WIDTH; P.y = pRoadSection[0].y; ModifiedRoadSection.push_back(P); iRoadPointsToAdd++; P.x = pRoadSection[0].x - DITCH_WIDTH * SLOPE_TRANSITION - DITCH_WIDTH; P.y = pRoadSection[0].y - DITCH_WIDTH / SLOPE_TRANSITION; ModifiedRoadSection.push_back(P); iRoadPointsToAdd++; P.x = pRoadSection[0].x - DITCH_WIDTH * SLOPE_TRANSITION; ModifiedRoadSection.push_back(P); iRoadPointsToAdd++; }//if P.x = pRoadSection[0].x - fabs(pCrossSection[0].y - pRoadSection[0].y - fHeight) / SLOPE_RATIO; P.y = pCrossSection[0].y - fHeight; ModifiedRoadSection.push_back(P); P.y = pCrossSection[0].y; ModifiedCrossSection.push_back(P); iCrossSectionPointsToAdd++; iRoadPointsToAdd++; }//if else{ bDitchAdded = false; for (j = 0; j < 4; j++){ //4 dummy points ModifiedRoadSection.push_back(pRoadSection[0]); }//for for (j = i ; j >= 0; j--){ if (ModifiedRoadSection[1].y + fHeight > pCrossSection[j+1].y){ iSgn = -1; }//if else{ iSgn = 1; }//else Intersect_Lines(ModifiedRoadSection[1].x, ModifiedRoadSection[1].y + fHeight, ModifiedRoadSection[1].x - LONG_SEGMENT / SLOPE_RATIO, ModifiedRoadSection[1].y + LONG_SEGMENT * iSgn + fHeight, pCrossSection[j].x, pCrossSection[j].y, pCrossSection[j+1].x, pCrossSection[j+1].y, fX,fY); if (pCrossSection[j].x < fX && pCrossSection[j+1].x >= fX){ if (iSgn == 1){ if(!bDitchAdded){ ModifiedRoadSection[1].x = pRoadSection[0].x - 2* DITCH_WIDTH * SLOPE_TRANSITION - DITCH_WIDTH; ModifiedRoadSection[1].y = pRoadSection[0].y; iRoadPointsToAdd++; ModifiedRoadSection[2].x = pRoadSection[0].x - DITCH_WIDTH * SLOPE_TRANSITION - DITCH_WIDTH; ModifiedRoadSection[2].y = pRoadSection[0].y - DITCH_WIDTH / SLOPE_TRANSITION; iRoadPointsToAdd++; ModifiedRoadSection[3].x = pRoadSection[0].x - DITCH_WIDTH * SLOPE_TRANSITION; ModifiedRoadSection[3].y = pRoadSection[0].y - DITCH_WIDTH / SLOPE_TRANSITION; iRoadPointsToAdd++; j = i + 1; bDitchAdded = true; }//if else{ ModifiedRoadSection[0].x = fX; ModifiedRoadSection[0].y = fY - fHeight; iRoadPointsToAdd++; break; }//else }//if else{ ModifiedRoadSection[0].x = fX; ModifiedRoadSection[0].y = fY - fHeight; iRoadPointsToAdd++; break; }//else }//if }//for if (j < 0){ ModifiedRoadSection[0].x = pRoadSection[0].x - fabs(pCrossSection[0].y - pRoadSection[0].y - fHeight) / SLOPE_RATIO; ModifiedRoadSection[0].y = pCrossSection[0].y - fHeight; P.x = ModifiedRoadSection[0].x; P.y = pCrossSection[0].y; ModifiedCrossSection.push_back(P); iCrossSectionPointsToAdd++; iRoadPointsToAdd++; }//if*/ }//else //add the central points for (i = 0; i < iCrossSectionPoints; i++){ ModifiedCrossSection.push_back(pCrossSection[i]); }//for ModifiedRoadSection.resize(iRoadPoints + iRoadPointsToAdd); for (i = 0; i < iRoadPoints; i++){ ModifiedRoadSection[i + iRoadPointsToAdd].x = pRoadSection[i].x; ModifiedRoadSection[i + iRoadPointsToAdd].y = pRoadSection[i].y; }//for for (i = 0; i < iRoadPoints + iRoadPointsToAdd; i++){ ModifiedRoadSection[i].x = ModifiedRoadSection[i].x; ModifiedRoadSection[i].y = ModifiedRoadSection[i].y + fHeight; }//for iRoadPoints += iRoadPointsToAdd; iCrossSectionPoints += iCrossSectionPointsToAdd; // right half for (i = 0 ; i < iCrossSectionPoints - 1; i++){ if (ModifiedCrossSection[i].x < ModifiedRoadSection[iRoadPoints-1].x && ModifiedCrossSection[i+1].x >= ModifiedRoadSection[iRoadPoints-1].x){ break; }//if }//for if (i == iCrossSectionPoints - 1){ if (ModifiedRoadSection[iRoadPoints-1].y + fHeight < ModifiedCrossSection[iCrossSectionPoints-1].y){ P.x = ModifiedRoadSection[iRoadPoints-1].x + DITCH_WIDTH * SLOPE_TRANSITION; P.y = ModifiedRoadSection[iRoadPoints-1].y - DITCH_WIDTH / SLOPE_TRANSITION; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-2].x + DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-3].x + 2* DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; P.y = ModifiedRoadSection[iRoadPoints-3].y; ModifiedRoadSection.push_back(P); iRoadPoints++; }//if P.x = ModifiedRoadSection[iRoadPoints-1].x + fabs(ModifiedCrossSection[iCrossSectionPoints-1].y - ModifiedRoadSection[iRoadPoints-1].y) / SLOPE_RATIO; P.y = ModifiedCrossSection[iCrossSectionPoints-1].y ; ModifiedRoadSection.push_back(P); ModifiedCrossSection.push_back(P); iCrossSectionPoints++; iRoadPoints++; }//if else{ bDitchAdded = false; for (j = i ; j < iCrossSectionPoints - 1; j++){ if (ModifiedRoadSection[iRoadPoints-1].y > ModifiedCrossSection[j].y){ iSgn = -1; }//if else{ iSgn = 1; }//else if (iSgn == 1 && !bDitchAdded){ P.x = ModifiedRoadSection[iRoadPoints-1].x + DITCH_WIDTH * SLOPE_TRANSITION; P.y = ModifiedRoadSection[iRoadPoints-1].y - DITCH_WIDTH / SLOPE_TRANSITION; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-2].x + DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-3].x + 2* DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; P.y = ModifiedRoadSection[iRoadPoints-3].y; ModifiedRoadSection.push_back(P); iRoadPoints++; if (ModifiedRoadSection[iRoadPoints-1].y > ModifiedCrossSection[j].y){ iSgn = -1; }//if else{ iSgn = 1; }//else bDitchAdded = true; }//if Intersect_Lines(ModifiedRoadSection[iRoadPoints-1].x, ModifiedRoadSection[iRoadPoints-1].y, ModifiedRoadSection[iRoadPoints-1].x + LONG_SEGMENT / SLOPE_RATIO, ModifiedRoadSection[iRoadPoints-1].y + LONG_SEGMENT * iSgn, ModifiedCrossSection[j].x, ModifiedCrossSection[j].y, ModifiedCrossSection[j+1].x, ModifiedCrossSection[j+1].y, fX,fY); if (ModifiedCrossSection[j].x < fX && ModifiedCrossSection[j+1].x >= fX){ P.x = fX; P.y = fY; ModifiedRoadSection.push_back(P); iRoadPoints++; break; }//if }//for if (j == iCrossSectionPoints - 1){ if (ModifiedRoadSection[iRoadPoints-1].y + fHeight < ModifiedCrossSection[iCrossSectionPoints-1].y && !bDitchAdded){ P.x = ModifiedRoadSection[iRoadPoints-1].x + DITCH_WIDTH * SLOPE_TRANSITION; P.y = ModifiedRoadSection[iRoadPoints-1].y - DITCH_WIDTH / SLOPE_TRANSITION; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-2].x + DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-3].x + 2* DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; P.y = ModifiedRoadSection[iRoadPoints-3].y; ModifiedRoadSection.push_back(P); iRoadPoints++; }//if P.x = ModifiedRoadSection[iRoadPoints-1].x + fabs(ModifiedCrossSection[iCrossSectionPoints-1].y - ModifiedRoadSection[iRoadPoints-1].y) / SLOPE_RATIO; P.y = ModifiedCrossSection[iCrossSectionPoints-1].y ; ModifiedRoadSection.push_back(P); ModifiedCrossSection.push_back(P); iCrossSectionPoints++; iRoadPoints++; }//if*/ }//else }//method void CProfile_Cross_Sections_PDF::Intersect_Lines(double x0,double y0,double x1,double y1, double x2,double y2,double x3,double y3, double &xi,double &yi){ double a1,b1,c1, a2,b2,c2, det_inv, m1,m2; if ((x1-x0)!=0) m1 = (y1-y0)/(x1-x0); else m1 = (double)1e+10; if ((x3-x2)!=0) m2 = (y3-y2)/(x3-x2); else m2 = (double)1e+10; a1 = m1; a2 = m2; b1 = -1; b2 = -1; c1 = (y0-m1*x0); c2 = (y2-m2*x2); det_inv = 1/(a1*b2 - a2*b1); xi=((b1*c2 - b2*c1)*det_inv); yi=((a2*c1 - a1*c2)*det_inv); } //method void CProfile_Cross_Sections_PDF::CalculateAreas(TSG_Point * pCrossSection, TSG_Point * pRoadSection, double fHeight, int iCrossSectionPoints, int iRoadPoints, double &fPositiveArea, double &fNegativeArea){ int i; CSG_Shapes *pRoadShapes, *pCrossSectionShapes, *pResultShapes; CSG_Shape *pRoadShape, *pCrossSectionShape, *pResultShape; pResultShapes = new CSG_Shapes; pResultShapes->Create(SHAPE_TYPE_Polygon); pResultShape = pResultShapes->Add_Shape(); pRoadShapes = new CSG_Shapes; pRoadShapes->Create(SHAPE_TYPE_Polygon); pRoadShape = pRoadShapes->Add_Shape(); pCrossSectionShapes = new CSG_Shapes; pCrossSectionShapes->Create(SHAPE_TYPE_Polygon); pCrossSectionShape = pCrossSectionShapes->Add_Shape(); for (i = 0; i < iRoadPoints; i++){ pRoadShape->Add_Point(pRoadSection[i].x, pRoadSection[i].y + fHeight); }//for pRoadShape->Add_Point(pRoadSection[iRoadPoints-1].x + LONG_SEGMENT / SLOPE_RATIO, pRoadSection[iRoadPoints-1].y + fHeight + LONG_SEGMENT); pRoadShape->Add_Point(pRoadSection[0].x - LONG_SEGMENT / SLOPE_RATIO, pRoadSection[0].y + fHeight + LONG_SEGMENT); for (i = 0; i < iCrossSectionPoints; i++){ pCrossSectionShape->Add_Point(pCrossSection[i].x, pCrossSection[i].y); }//for pCrossSectionShape->Add_Point(pCrossSection[iCrossSectionPoints-1].x + LONG_SEGMENT / SLOPE_RATIO, pCrossSection[iCrossSectionPoints-1].y - LONG_SEGMENT); pCrossSectionShape->Add_Point(pCrossSection[0].x - LONG_SEGMENT / SLOPE_RATIO, pCrossSection[0].y - LONG_SEGMENT); if (SG_Polygon_Intersection(pCrossSectionShape, pRoadShape, pResultShape)){ fNegativeArea = ((CSG_Shape_Polygon*)pResultShape)->Get_Area(); }//if else{ fNegativeArea = 0; }//else pCrossSectionShape->Del_Parts(); pRoadShape->Del_Parts(); pResultShape->Del_Parts(); for (i = 0; i < iRoadPoints; i++){ pRoadShape->Add_Point(pRoadSection[i].x, pRoadSection[i].y + fHeight); }//for pRoadShape->Add_Point(pRoadSection[iRoadPoints-1].x + LONG_SEGMENT / SLOPE_RATIO, pRoadSection[iRoadPoints-1].y + fHeight - LONG_SEGMENT); pRoadShape->Add_Point(pRoadSection[0].x - LONG_SEGMENT / SLOPE_RATIO, pRoadSection[0].y + fHeight - LONG_SEGMENT); for (i = 0; i < iCrossSectionPoints; i++){ pCrossSectionShape->Add_Point(pCrossSection[i].x, pCrossSection[i].y); }//for pCrossSectionShape->Add_Point(pCrossSection[iCrossSectionPoints-1].x + LONG_SEGMENT / SLOPE_RATIO, pCrossSection[iCrossSectionPoints-1].y + LONG_SEGMENT); pCrossSectionShape->Add_Point(pCrossSection[0].x - LONG_SEGMENT / SLOPE_RATIO, pCrossSection[0].y + LONG_SEGMENT); if (SG_Polygon_Intersection(pCrossSectionShape, pRoadShape, pResultShape)){ fPositiveArea = ((CSG_Shape_Polygon*)pResultShape)->Get_Area(); }//if else{ fPositiveArea = 0; }//else delete pRoadShapes; delete pCrossSectionShapes; delete pResultShapes; }//method void CProfile_Cross_Sections_PDF::AddLongitudinalProfile(TSG_Point * pProfile, double *pHeight, int iNumPoints){ int i; int iMag; int iNumLines; double fMinLine = 0; double fMaxY, fMinY; double fMaxX, fMinX; double fStep; double fX, fY; double fOffsetX; CSG_String sValue; CSG_Points Points; double fHeight; Add_Page_Title(_TL("Longitudinal Profile"), PDF_TITLE_01); Add_Page(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE); fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); m_iOffsetY = 50; fMaxY = pProfile[0].y; fMinY = pProfile[0].y; for (i = 0; i < iNumPoints; i++) { if (pProfile[i].y > fMaxY) { fMaxY = pProfile[i].y; }// if if (pProfile[i].y < fMinY) { fMinY = pProfile[i].y; }// if if (pHeight[i] > fMaxY) { fMaxY = pHeight[i]; }// if if (pHeight[i] < fMinY) { fMinY = pHeight[i]; }// if }//for iMag = (int) (log(fMaxY - fMinY) / log(10.0)); fStep = (double) ((int) pow(10.0, (double) iMag)); if (fStep == 0){ fStep = 1.; }//if if (fMinY < 0) { iMag = (int) (log(fabs(fMinY)) / log(10.0)); fMinLine = -(int) pow(10.0, (double) iMag); }// if else { fMinLine=(int)(((int)(fMinY/fStep)) *fStep); }//else iNumLines = (int) ((fMaxY - fMinY) / fStep); while (iNumLines < 8) { fStep = fStep / 2.0; iNumLines = (int) ((fMaxY - fMinY) / fStep); }// while iNumLines = (int) ((fMaxY - fMinLine) / fStep); fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); for (i = 0; i < iNumLines; i++) { fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION; fY = m_iOffsetY + PROFILE_HEIGHT - ((fMinLine + fStep * i - fMinY) / (fMaxY - fMinY)) * PROFILE_HEIGHT; if (fY <= m_iOffsetY + PROFILE_HEIGHT && fY >= m_iOffsetY) { fY = fHeight - fY; sValue = SG_Get_String(fMinLine + fStep * (double) i); Draw_Text(fX - 10, fY, SG_Get_String(fMinLine + fStep * (double) i).c_str(), 9, PDF_STYLE_TEXT_ALIGN_H_RIGHT); Draw_Line(fX, fY, fX - 5, fY, 0); }// if }// for fMinX = pProfile[0].x; fMaxX = pProfile[iNumPoints - 1].x; iMag = (int) (log(fMaxX - fMinX) / log(10.0)); fStep = (double) pow(10.0, (double) iMag); iNumLines = (int) ((fMaxX-fMinX) / fStep); while (iNumLines < 3) { fStep = fStep / 2.0; iNumLines = (int) ((fMaxX-fMinX) / fStep); }// while fMinLine = (int)(((int)(fMinX/fStep)) * fStep); while (fMinLine=OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION && fX < OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH){ if (fabs(fStep * (double)i+fMinLine) > 100000) { sValue = SG_Get_String(fStep * (double)i+fMinLine); }// if else { sValue = SG_Get_String(fStep * (double)i+fMinLine, 2, true); }// else Draw_Text(fX, fHeight - m_iOffsetY - PROFILE_HEIGHT - 15, SG_Get_String(fMinLine + fStep * (double) i).c_str(), 9, PDF_STYLE_TEXT_ALIGN_H_CENTER | PDF_STYLE_TEXT_ALIGN_V_TOP); Draw_Line(fX, fHeight - m_iOffsetY - PROFILE_HEIGHT, fX, fHeight - m_iOffsetY - PROFILE_HEIGHT - 10, 0); }//if }// for Draw_Line(OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION, fHeight - m_iOffsetY, OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION, fHeight - m_iOffsetY - PROFILE_HEIGHT, 2); Draw_Line(OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION, fHeight - m_iOffsetY - PROFILE_HEIGHT, OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH, fHeight - m_iOffsetY - PROFILE_HEIGHT, 2); fY = m_iOffsetY + PROFILE_HEIGHT - PROFILE_HEIGHT * ((pProfile[0].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH * ((pProfile[0].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX, fY); for (i = 1; i < iNumPoints; i++) { fY = m_iOffsetY + PROFILE_HEIGHT - PROFILE_HEIGHT * ((pProfile[i].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH * ((pProfile[i].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX, fY); }// for Draw_Line(Points, 2, 0x00bb00); Points.Clear(); fY = m_iOffsetY + PROFILE_HEIGHT - PROFILE_HEIGHT * ((pHeight[0] - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH * ((pProfile[0].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX,fY); for (i = 1; i < iNumPoints; i++) { fY = m_iOffsetY + PROFILE_HEIGHT - PROFILE_HEIGHT * ((pHeight[i] - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH * ((pProfile[i].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX, fY); }// for Draw_Line(Points, 2, 0x0000bb); DrawGuitar(pProfile, pHeight, iNumPoints); }//method void CProfile_Cross_Sections_PDF::DrawGuitar(TSG_Point *pProfile, double *pHeight, int iNumPoints){ int i; double fY; double fMinX, fMaxX; double fDif; CSG_String sValue; CSG_String sField [] = {"Distancia","Dist. Parcial.", "Elevacion del terreno", "Elevación de la calzada", " ", " "}; double fHeight; fMinX = pProfile[0].x; fMaxX = pProfile[iNumPoints - 1].x; fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); for (i = 0; i < 7; i++){ fY = m_iOffsetY + PROFILE_HEIGHT + SEPARATION + GUITAR_LEYEND_HEIGHT / 6 * i; fY = fHeight - fY; Draw_Line(OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION, fY, OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + GUITAR_WIDTH, fY, 0, 0x880000); if (i){ Draw_Text(OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION - 10, fY + GUITAR_LEYEND_HEIGHT / 13, sField[i-1].c_str(), 9, PDF_STYLE_TEXT_ALIGN_V_CENTER | PDF_STYLE_TEXT_ALIGN_H_RIGHT); }//if }//for AddGuitarValue(0, 0, fMinX, fMaxX, 1); for (i = 0; i < iNumPoints; i++) { AddGuitarValue(pProfile[i].x, pProfile[i].x / 1000, fMinX, fMaxX, 0); if (i){ AddGuitarValue(pProfile[i].x, pProfile[i].x / 1000 - pProfile[i-1].x / 1000, fMinX, fMaxX, 1); }//if fDif = pProfile[i].y - pHeight[i]; AddGuitarValue(pProfile[i].x, pProfile[i].y, fMinX, fMaxX, 2); AddGuitarValue(pProfile[i].x, pHeight[i], fMinX, fMaxX, 3); if (fDif > 0){ AddGuitarValue(pProfile[i].x, fDif, fMinX, fMaxX, 4); }//if else{ AddGuitarValue(pProfile[i].x, fDif, fMinX, fMaxX, 5); }//else }// for }//method void CProfile_Cross_Sections_PDF::AddGuitarValue(double fXValue, double fValue, double fMinX, double fMaxX, int iLine){ double fX,fY; double fHeight; fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH * ((fXValue - fMinX) / (fMaxX - fMinX)); fY = m_iOffsetY + PROFILE_HEIGHT + SEPARATION + GUITAR_LEYEND_HEIGHT / 6 * (iLine + 1); fY = fHeight - fY; Draw_Line(fX, fY, fX, fY + 3, 0, 0x880000); fY += 3; fX += 3; Draw_Text(fX, fY, SG_Get_String(fValue, 2).c_str(), 8, 0, 3.14159/2.); fY = m_iOffsetY + PROFILE_HEIGHT + SEPARATION + GUITAR_LEYEND_HEIGHT / 6 * iLine; fY = fHeight - fY; fX -= 3; Draw_Line(fX, fY, fX, fY - 3, 0, 0x880000); }//method /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CProfile_Cross_Sections::CProfile_Cross_Sections(void){ CSG_Parameter *pNode; Parameters.Set_Name(_TL("Terrain Path Cross Sections")); Parameters.Set_Description(_TW("(c) 2004 Victor Olaya. Cross Sections")); Parameters.Add_Grid(NULL, "DEM", _TL("DEM"), _TL("Digital Terrain Model"), PARAMETER_INPUT); Parameters.Add_Shapes(NULL, "LINES", _TL("Path"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line); Parameters.Add_Shapes(NULL, "SECTIONS", _TL("Cross Sections"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "NUMPOINTS", _TL("Number of points"), _TL("Number of points on each side of the section"), PARAMETER_TYPE_Int, 10, 1, true); Parameters.Add_Value(NULL, "INTERVAL", _TL("Interval"), _TL("Interval between points (in grid units)."), PARAMETER_TYPE_Double, 10); Parameters.Add_Value(NULL, "STEP", _TL("n"), _TL("Draw a section each n points"), PARAMETER_TYPE_Int, 2); pNode = Parameters.Add_Node(NULL, "PDFNODE", _TL("PDF Documents"), _TL("")); Parameters.Add_Value(pNode, "PDF", _TL("Create PDF Documents"), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_FilePath(pNode, "OUTPUTPATH", _TL("Folder for PDF Files"), _TL(""), _TL(""), _TL(""), true, true); Parameters.Add_Value(pNode, "WIDTH", _TL("Road Width"), _TL(""), PARAMETER_TYPE_Double, 5.); Parameters.Add_Value(pNode, "SLOPE", _TL("Side Slope"), _TL(""), PARAMETER_TYPE_Double, .5); Parameters.Add_Value(pNode, "THRESHOLD", _TL("Height Threshold"), _TL("Height threshold for optimal profile calculation"), PARAMETER_TYPE_Double, .5); }//constructor CProfile_Cross_Sections::~CProfile_Cross_Sections(void){} bool CProfile_Cross_Sections::On_Execute(void){ CSG_Shapes *pLines; CSG_Shape *pShape, *pSection; CSG_Grid *pDEM; TSG_Point Point, Point2; double fInterval; double fStepX, fStepY; int iNumPoints; int i,j,k; int iPoint; int iField = 0; int iStep; double dX, dY; double dX2, dY2; double dDistance; double dHeight; bool bCopy; m_pSections = Parameters("SECTIONS")->asShapes(); pLines = Parameters("LINES")->asShapes(); pDEM = Parameters("DEM")->asGrid(); fInterval = (double) Parameters("INTERVAL")->asDouble(); iNumPoints = Parameters("NUMPOINTS")->asInt(); iStep = Parameters("STEP")->asInt(); if(pLines == m_pSections){ bCopy = true; m_pSections = SG_Create_Shapes(); }//if else{ bCopy = false; }//else m_pSections->Create(SHAPE_TYPE_Line, _TL("Cross Sections")); for (i = iNumPoints; i > 0; i--){ m_pSections->Add_Field(CSG_String::Format(SG_T("-%s"), SG_Get_String(fInterval * i, 2).c_str()), SG_DATATYPE_Double); }//for m_pSections->Add_Field("0", SG_DATATYPE_Double); for (i = 1; i < iNumPoints +1; i++){ m_pSections->Add_Field(SG_Get_String(fInterval * i).c_str(), SG_DATATYPE_Double); }//for for(i=0; iGet_Count() && Set_Progress(i, pLines->Get_Count()); i++){ pShape = pLines->Get_Shape(i); for(j=0; jGet_Part_Count(); j++){ for(k=0; kGet_Point_Count(j)-1; k+=iStep){ Point = pShape->Get_Point(k,j); Point2 = pShape->Get_Point(k+1,j); dDistance = sqrt(pow(Point2.x - Point.x,2) + pow(Point2.y - Point.y,2)); dX = (Point.x + Point2.x) / 2.; dY = (Point.y + Point2.y) / 2.; fStepX = (Point2.y - Point.y) / dDistance * fInterval; fStepY = -(Point2.x - Point.x) / dDistance * fInterval; pSection = m_pSections->Add_Shape(); pSection->Add_Point(dX + iNumPoints * fStepX, dY + iNumPoints * fStepY); pSection->Add_Point(dX - iNumPoints * fStepX, dY - iNumPoints * fStepY); iField = 0; for (iPoint = iNumPoints; iPoint > 0; iPoint--){ dX2 = dX - iPoint * fStepX; dY2 = dY - iPoint * fStepY; dHeight = pDEM->Get_Value(dX2, dY2); pSection->Set_Value(iField, dHeight); iField++; }//for dHeight = pDEM->Get_Value(dX, dY); pSection->Set_Value(iField, dHeight); iField++; for (iPoint = 1; iPoint < iNumPoints +1; iPoint++){ dX2 = dX + iPoint * fStepX; dY2 = dY + iPoint * fStepY; dHeight = pDEM->Get_Value(dX2, dY2); pSection->Set_Value(iField, dHeight); iField++; }//for*/ }//for }//for }//for if (Parameters("PDF")->asBool()){ CreatePDFDocs(); }//if if(bCopy){ pLines->Assign(m_pSections); delete(m_pSections); }//if return true; }// method void CProfile_Cross_Sections::CreatePDFDocs(){ CSG_String sFilePath; if (Parameters("OUTPUTPATH")->asString()){ m_DocEngine.Open(_TL("SECTIONS")); sFilePath = SG_File_Make_Path(Parameters("OUTPUTPATH")->asString(), _TL("Sections"), _TL("pdf")); }//if else{ Message_Add(_TL("\n** Error : Invalid parameters **\n")); return; }//else AddLongitudinalProfiles(); AddCrossSections(); if (m_DocEngine.Save(sFilePath)){ if (!m_DocEngine.Close()){ Message_Add(_TL("\n\n ** Error : Could not close PDF engine ** \n\n")); } }//if else{ Message_Add(_TL("\n\n ** Error : Could not save PDF file ** \n\n")); }//else }//method void CProfile_Cross_Sections::AddLongitudinalProfiles(){ int i,j,k; int iIndex = 0; int iNumPoints = Parameters("NUMPOINTS")->asInt(); int iStep = Parameters("STEP")->asInt(); int iFirstPoint = 0; int iLastPoint; int iSections; double fX1, fY1, fX2, fY2; double fDistance, fDistanceSum = 0; double fDist; double fThreshold = (double)Parameters("THRESHOLD")->asDouble(); bool bValid; CSG_Shape *pShape; CSG_Table *pTable; TSG_Point Point, Point2; CSG_Shapes* pLines = Parameters("LINES")->asShapes(); pTable = m_pSections; iSections = pTable->Get_Record_Count(); m_pProfile = new TSG_Point[iSections]; for(i=0; iGet_Count() && Set_Progress(i, pLines->Get_Count()); i++){ pShape = pLines->Get_Shape(i); for(j=0; jGet_Part_Count(); j++){ Point = pShape->Get_Point(0,j); for(k=0; kGet_Point_Count(j)-1; k+=iStep){ Point2 = pShape->Get_Point(k,j); fDistance = sqrt(pow(Point2.x - Point.x,2) + pow(Point2.y - Point.y,2)); m_pProfile[iIndex].x = fDistanceSum + fDistance / 2.; m_pProfile[iIndex].y = pTable->Get_Record(iIndex)->asFloat(iNumPoints); fDistanceSum += fDistance; iIndex++; Point.x = Point2.x; Point.y = Point2.y; }//for }//for }//for*/ m_pHeight = new double[iSections]; for (i = 0; i < iSections; i++){ m_pHeight[i] = 1500; } iLastPoint = iSections - 1; while(iFirstPoint != iSections - 1){ fX1 = m_pProfile[iFirstPoint].x; fY1 = m_pProfile[iFirstPoint].y; fX2 = m_pProfile[iLastPoint].x; fY2 = m_pProfile[iLastPoint].y; bValid = true; for (i = iFirstPoint; i < iLastPoint; i++){ fDist = CalculatePointLineDist(fX1,fY1,fX2,fY2, m_pProfile[i].x, m_pProfile[i].y); if (fDist > fThreshold){ iLastPoint--; bValid = false; break; }//if }//for if (bValid){ for (j = iFirstPoint; j < iLastPoint + 1; j++){ m_pHeight[j] = m_pProfile[iFirstPoint].y + (m_pProfile[j].x - m_pProfile[iFirstPoint].x) / (m_pProfile[iLastPoint].x - m_pProfile[iFirstPoint].x) * (m_pProfile[iLastPoint].y - m_pProfile[iFirstPoint].y); }//for iFirstPoint = iLastPoint; iLastPoint = iSections - 1; }//if }//while m_DocEngine.AddLongitudinalProfile(m_pProfile, m_pHeight, iSections); }//method double CProfile_Cross_Sections::CalculatePointLineDist(double fX1, double fY1, double fX2, double fY2, double fPX, double fPY){ double *pA, *pB, *pC; pA = new double[2]; pA[0] = fX1; pA[1] = fY1; pB = new double[2]; pB[0] = fX2; pB[1] = fY2; pC = new double[2]; pC[0] = fPX; pC[1] = fPY; return linePointDist(pA, pB, pC); }//method void CProfile_Cross_Sections::AddCrossSections(){ int i,j; int iRoadPoints; int iNumPoints = Parameters("NUMPOINTS")->asInt(); double fInterval = (double) Parameters("INTERVAL")->asDouble(); CSG_Table *pTable; TSG_Point *pRoadSection; TSG_Point **pCrossSections; double dWidth = Parameters("WIDTH")->asDouble(); pRoadSection = new TSG_Point [2]; pRoadSection[0].x = -dWidth / 2.; pRoadSection[0].y = 0; pRoadSection[1].x = dWidth / 2.; pRoadSection[1].y = 0; pTable = m_pSections; pCrossSections = new TSG_Point *[pTable->Get_Record_Count()]; for (i = 0; i < pTable->Get_Record_Count(); i++){ pCrossSections[i] = new TSG_Point [pTable->Get_Field_Count()]; for (j = 0; j < pTable->Get_Field_Count(); j++){ pCrossSections[i][j].x = -fInterval * iNumPoints + fInterval * j; pCrossSections[i][j].y = pTable->Get_Record(i)->asFloat(j); }//for }//for iRoadPoints = 2; m_DocEngine.AddCrossSections(pCrossSections, m_pHeight, pRoadSection, pTable->Get_Record_Count(), pTable->Get_Field_Count(), iRoadPoints); m_DocEngine.AddVolumesTable(m_pProfile, pCrossSections, m_pHeight, pRoadSection, pTable->Get_Record_Count(), pTable->Get_Field_Count(), iRoadPoints); }//method /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/docs/docs_pdf/Shapes_Report.cpp0000664000175000017500000005225512565125412024035 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Report.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Report.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad, 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_pdf.h" #include "Shapes_Report.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Report::CShapes_Report(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Shapes Report")); Set_Author (SG_T("(c) 2005 by O.Conrad, V.Olaya")); Set_Description (_TW( "" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "SUBTITLE" , _TL("Subtitle"), _TL("") ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("PDF File"), _TL(""), _TL("PDF Files (*.pdf)|*.pdf|All Files|*.*"), _TL(""), true, false ); Parameters.Add_Choice( NULL , "PAPER_SIZE" , _TL("Paper Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("A4 Portrait"), _TL("A4 Landscape"), _TL("A3 Portrait"), _TL("A3 Landscape") ) ); Parameters.Add_Value( pNode , "COLOR_LINE" , _TL("Line Color"), _TL(""), PARAMETER_TYPE_Color, SG_COLOR_BLACK ); Parameters.Add_Value( pNode , "COLOR_FILL" , _TL("Fill Color"), _TL(""), PARAMETER_TYPE_Color, SG_COLOR_GREEN ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_LAYOUT" , _TL("Layout"), _TL("")); Parameters.Add_Choice( pNode , "LAYOUT_MODE" , _TL("Layout"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("horizontal"), _TL("vertical") ), 1 ); Parameters.Add_Value( pNode , "LAYOUT_BREAK", _TL("Map/Table Size Ratio [%]"), _TL(""), PARAMETER_TYPE_Double, 50.0, 0.0, true, 100.0, true ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_TABLE" , _TL("Attribute Table"), _TL("")); Parameters.Add_Value( pNode , "COLUMNS" , _TL("Columns"), _TL("Number of atttribute table columns."), PARAMETER_TYPE_Int, 2, 1, true ); Parameters.Add_Choice( pNode , "CELL_MODE" , _TL("Cell Sizes"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("fit to page"), _TL("fixed cell height") ) ); Parameters.Add_Value( pNode , "CELL_HEIGHT" , _TL("Cell Height"), _TL(""), PARAMETER_TYPE_Int, 8, 1, true ); } //--------------------------------------------------------- CShapes_Report::~CShapes_Report(void) { } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Report::On_Execute(void) { int Page_Orientation; TSG_PDF_Page_Size Page_Size; CSG_String FileName(Parameters("FILENAME") ->asString()); CSG_Doc_PDF PDF; //----------------------------------------------------- m_pShapes = Parameters("SHAPES") ->asShapes(); m_iSubtitle = Parameters("SUBTITLE") ->asInt(); m_Color_Line = Parameters("COLOR_LINE") ->asColor(); m_Color_Fill = Parameters("COLOR_FILL") ->asColor(); m_nColumns = Parameters("COLUMNS") ->asInt(); switch( Parameters("CELL_MODE")->asInt() ) { default: case 0: m_Cell_Height = 0; break; case 1: m_Cell_Height = Parameters("CELL_HEIGHT")->asDouble(); break; } switch( Parameters("PAPER_SIZE")->asInt() ) { default: case 0: Page_Size = PDF_PAGE_SIZE_A4; Page_Orientation = PDF_PAGE_ORIENTATION_PORTRAIT; break; // A4 Portrait case 1: Page_Size = PDF_PAGE_SIZE_A4; Page_Orientation = PDF_PAGE_ORIENTATION_LANDSCAPE; break; // A4 Landscape case 2: Page_Size = PDF_PAGE_SIZE_A3; Page_Orientation = PDF_PAGE_ORIENTATION_PORTRAIT; break; // A3 Portrait case 3: Page_Size = PDF_PAGE_SIZE_A3; Page_Orientation = PDF_PAGE_ORIENTATION_LANDSCAPE; break; // A3 Landscape } //----------------------------------------------------- if( FileName.Length() > 0 && PDF.Open(Page_Size, Page_Orientation, CSG_String::Format(SG_T("%s: %s"), _TL("Summary"), m_pShapes->Get_Name())) ) { double d = Parameters("LAYOUT_BREAK")->asDouble(); switch( Parameters("LAYOUT_MODE")->asInt() ) { default: case 0: // horizontal PDF.Layout_Add_Box( 0, 0, 100, 5, "TITLE"); PDF.Layout_Add_Box( 0, 5, d, 100, "SHAPE"); PDF.Layout_Add_Box( d, 5, 100, 100, "TABLE"); break; case 1: // vertical PDF.Layout_Add_Box( 0, 0, 100, 5, "TITLE"); PDF.Layout_Add_Box( 0, 5, 100, d, "SHAPE"); PDF.Layout_Add_Box( 0, d, 100, 100, "TABLE"); break; } m_pPDF = &PDF; m_rTitle = PDF.Layout_Get_Box("TITLE"); m_rShape = PDF.Layout_Get_Box("SHAPE"); m_rTable = PDF.Layout_Get_Box("TABLE"); return( Add_Shapes() && PDF.Save(FileName) ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Report::Add_Shapes(void) { if( m_pShapes && m_pShapes->is_Valid() && m_pPDF && m_pPDF->Add_Page() ) { bool bAddAll; CSG_Rect r(m_rShape), rWorld(m_pShapes->Get_Extent()); CSG_String Title; CSG_Strings sLeft, sRight; //------------------------------------------------- m_pPDF->Draw_Text(m_rTitle.Get_XCenter(), m_rTitle.Get_YCenter(), _TL("Overview"), (int)(0.7 * m_rTitle.Get_YRange()), PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_CENTER|PDF_STYLE_TEXT_UNDERLINE); //------------------------------------------------- r.Deflate(10, false); rWorld.Inflate(5, true); m_pPDF->Draw_Shapes (r, m_pShapes, PDF_STYLE_POLYGON_FILLSTROKE, m_Color_Fill, m_Color_Line, 0, &rWorld); m_pPDF->Draw_Graticule(r, rWorld, 10); //------------------------------------------------- sLeft .Add(CSG_String::Format(SG_T("%s:") , _TL("Name"))); sRight .Add(CSG_String::Format(SG_T("%s") , m_pShapes->Get_Name())); sLeft .Add(CSG_String::Format(SG_T("%s:") , _TL("Count"))); sRight .Add(CSG_String::Format(SG_T("%d") , m_pShapes->Get_Count())); m_pPDF->Draw_Text(m_rTable.Get_XMin() , m_rTable.Get_YMax(), sLeft , 8, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP); m_pPDF->Draw_Text(m_rTable.Get_XCenter(), m_rTable.Get_YMax(), sRight, 8, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP); //------------------------------------------------- bAddAll = m_pShapes->Get_Selection_Count() == 0; for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, m_pShapes->Get_Count()); iShape++) { if( bAddAll || m_pShapes->Get_Record(iShape)->is_Selected() ) { Title.Printf(SG_T("%s: %s"), m_pShapes->Get_Field_Name(m_iSubtitle), m_pShapes->Get_Shape(iShape)->asString(m_iSubtitle)); Add_Shape(m_pShapes->Get_Shape(iShape), Title); } } return( true ); } return( false ); } //--------------------------------------------------------- bool CShapes_Report::Add_Shape(CSG_Shape *pShape, const SG_Char *Title) { if( m_pPDF && m_pPDF->Is_Ready_To_Draw() && pShape && pShape->is_Valid() && m_pPDF->Add_Page() ) { CSG_Rect r(m_rShape), rWorld(pShape->Get_Extent()); //------------------------------------------------- m_pPDF->Add_Outline_Item(Title); m_pPDF->Draw_Text(m_rTitle.Get_XCenter(), m_rTitle.Get_YCenter(), Title, (int)(0.7 * m_rTitle.Get_YRange()), PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_CENTER|PDF_STYLE_TEXT_UNDERLINE); r.Deflate(10, false); rWorld.Inflate(5, true); m_pPDF->Draw_Shape (r, pShape, PDF_STYLE_POLYGON_FILLSTROKE, m_Color_Fill, m_Color_Line, 0, &rWorld); m_pPDF->Draw_Graticule (r, rWorld, 10); //------------------------------------------------- if( pShape->Get_Table()->Get_Field_Count() > 0 ) { CSG_Table_Record *pRecord; CSG_Table Table; Table.Set_Name(_TL("Attributes")); Table.Add_Field(_TL("Attribute"), SG_DATATYPE_String); Table.Add_Field(_TL("Value") , SG_DATATYPE_String); for(int iField=0; iFieldGet_Table()->Get_Field_Count(); iField++) { pRecord = Table.Add_Record(); pRecord->Set_Value(0, pShape->Get_Table()->Get_Field_Name(iField)); pRecord->Set_Value(1, pShape->asString(iField)); } m_pPDF->Draw_Table(m_rTable, &Table, m_nColumns, m_Cell_Height, 0.0); } return( true ); } return( 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(""), CSG_String::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(CSG_String::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; iGet_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, CSG_String::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(CSG_String::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(CSG_String::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(CSG_String::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(CSG_String::Format(wxT("%s: %f%s\n"), LNG("Perimeter") , d / e, s.c_str())); Description.Append(CSG_String::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(CSG_String::Format(wxT("%s: %s\n"), pShapes->Get_Field_Name(iField), pShapes->Get_Shape(Image_ID)->asString(iField))); } } Description.Append(CSG_String::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); } }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/docs/docs_pdf/doc_pdf.cpp0000664000175000017500000014420512565125412022652 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_pdf.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_pdf // // // //-------------------------------------------------------// // // // doc_pdf.cpp // // // // Copyright (C) 2005 by // // Victor Olaya, 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef _SAGA_DONOTUSE_HARU /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "doc_pdf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PDF_PAGE_WIDTH_A4 595.276 #define PDF_PAGE_HEIGHT_A4 841.89 #define PDF_PAGE_HEIGHT_A4_M 0.297 #define PDF_PAGE_WIDTH_A3 PDF_PAGE_HEIGHT_A4 #define PDF_PAGE_HEIGHT_A3 (PDF_PAGE_HEIGHT_A4 * sqrt(2.0)) #define PDF_METER_TO_POINT (PDF_PAGE_HEIGHT_A4 / PDF_PAGE_HEIGHT_A4_M) #define PDF_POINT_TO_METER (PDF_PAGE_HEIGHT_A4_M / PDF_PAGE_HEIGHT_A4) //--------------------------------------------------------- #define PDF_GET_R(c) (float)(SG_GET_R(c) / 255.0) #define PDF_GET_G(c) (float)(SG_GET_G(c) / 255.0) #define PDF_GET_B(c) (float)(SG_GET_B(c) / 255.0) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Doc_PDF::CSG_Doc_PDF(void) { m_pPDF = NULL; Layout_Set_Box_Space(5, false); Open(); } //--------------------------------------------------------- CSG_Doc_PDF::CSG_Doc_PDF(TSG_PDF_Page_Size Size, int Orientation, const SG_Char *Title) { m_pPDF = NULL; Layout_Set_Box_Space(5, false); Open(Size, Orientation, Title); } //--------------------------------------------------------- CSG_Doc_PDF::~CSG_Doc_PDF(void) { Close(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const SG_Char * CSG_Doc_PDF::Get_Version(void) { static CSG_String s = CSG_String::Format(SG_T("Haru Free PDF Library, Version %s"), HPDF_VERSION_TEXT); return( s ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Open(const SG_Char *Title) { return( Open(PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_PORTRAIT, Title) ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Open(TSG_PDF_Page_Size Size, int Orientation, const SG_Char *Title) { if( Close() ) { m_pPDF = HPDF_New(NULL, NULL); m_pOutline_Last_Level_0 = NULL; m_pOutline_Last_Level_1 = NULL; m_pOutline_Last_Level_2 = NULL; Set_Size_Page(Size, Orientation); if( Title && *Title ) { Add_Page_Title(Title); } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Close(void) { if( m_pPDF ) { try { HPDF_Free(m_pPDF); } catch(...) { return( false ); } } m_pPDF = NULL; m_pPage = NULL; m_nPages = 0; return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Save(const SG_Char *FileName) { if( m_pPDF && m_nPages > 0 && SG_Dir_Create(SG_File_Get_Path(FileName)) ) { try { return( HPDF_SaveToFile(m_pPDF, CSG_String(FileName)) == HPDF_OK ); } catch(...) {} } SG_UI_Msg_Add_Error(_TL("[ERR] Could not save PDF file.")); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CSG_Doc_PDF::Get_Page_To_Meter(void) { return( PDF_POINT_TO_METER ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- struct _HPDF_Dict_Rec * CSG_Doc_PDF::_Get_Font(TSG_PDF_Font_Type Font) { switch( Font ) { default: case PDF_FONT_Helvetica: return( HPDF_GetFont(m_pPDF, "Helvetica" , NULL) ); case PDF_FONT_Helvetica_Bold: return( HPDF_GetFont(m_pPDF, "Helvetica-Bold" , NULL) ); case PDF_FONT_Helvetica_Oblique: return( HPDF_GetFont(m_pPDF, "Helvetica-Oblique" , NULL) ); case PDF_FONT_Helvetica_BoldOblique: return( HPDF_GetFont(m_pPDF, "Helvetica-BoldOblique", NULL) ); case PDF_FONT_Times_Roman: return( HPDF_GetFont(m_pPDF, "Times-Roman" , NULL) ); case PDF_FONT_Times_Bold: return( HPDF_GetFont(m_pPDF, "Times-Bold" , NULL) ); case PDF_FONT_Times_Italic: return( HPDF_GetFont(m_pPDF, "Times-Italic" , NULL) ); case PDF_FONT_Times_BoldItalic: return( HPDF_GetFont(m_pPDF, "Times-BoldItalic" , NULL) ); case PDF_FONT_Courier: return( HPDF_GetFont(m_pPDF, "Courier" , NULL) ); case PDF_FONT_Courier_Bold: return( HPDF_GetFont(m_pPDF, "Courier-Bold" , NULL) ); case PDF_FONT_Courier_Oblique: return( HPDF_GetFont(m_pPDF, "Courier-Oblique" , NULL) ); case PDF_FONT_Courier_BoldOblique: return( HPDF_GetFont(m_pPDF, "Courier-BoldOblique" , NULL) ); case PDF_FONT_Symbol: return( HPDF_GetFont(m_pPDF, "Symbol" , NULL) ); case PDF_FONT_ZapfDingbats: return( HPDF_GetFont(m_pPDF, "ZapfDingbats" , NULL) ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Layout_Add_Box(double xMin_Percent, double yMin_Percent, double xMax_Percent, double yMax_Percent, const CSG_String &ID) { if( m_Boxes_Percent.Add(xMin_Percent, yMin_Percent, xMax_Percent, yMax_Percent) ) { m_Boxes.Add(); m_Boxes_ID.Add(ID); _Layout_Set_Box(m_Boxes.Get_Count() - 1); return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Layout_Add_Box(const CSG_Rect &Box_Percent, const CSG_String &ID) { return( Layout_Add_Box(Box_Percent.Get_XMin(), Box_Percent.Get_YMin(), Box_Percent.Get_XMax(), Box_Percent.Get_YMax(), ID) ); } //--------------------------------------------------------- const CSG_Rect & CSG_Doc_PDF::Layout_Get_Box(const CSG_String &ID) { for(int i=0; i= 0 && iBox < m_Boxes.Get_Count() && iBox < m_Boxes_Percent.Get_Count() ) { m_Boxes[iBox].Assign( m_Size_Margins.Get_XMin() + 0.01 * m_Boxes_Percent[iBox].Get_XMin() * m_Size_Margins.Get_XRange(), m_Size_Margins.Get_YMax() - 0.01 * m_Boxes_Percent[iBox].Get_YMax() * m_Size_Margins.Get_YRange(), m_Size_Margins.Get_XMin() + 0.01 * m_Boxes_Percent[iBox].Get_XMax() * m_Size_Margins.Get_XRange(), m_Size_Margins.Get_YMax() - 0.01 * m_Boxes_Percent[iBox].Get_YMin() * m_Size_Margins.Get_YRange() ); m_Boxes[iBox].Deflate(m_Boxes_Space, m_Boxes_Space_bPercent); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::_Fit_Rectangle(double &x, double &y, double &dx, double &dy, double XToY_Ratio, bool bShrink) { if( XToY_Ratio != 0.0 && dx != 0.0 && dy != 0.0 ) { if( XToY_Ratio > dx / dy ) { if( bShrink ) { XToY_Ratio = dx / XToY_Ratio; y += (dy - XToY_Ratio) / 2.0; dy = XToY_Ratio; } else { XToY_Ratio = dy * XToY_Ratio; x -= (dx - XToY_Ratio) / 2.0; dx = XToY_Ratio; } } else { if( bShrink ) { XToY_Ratio = dy * XToY_Ratio; x += (dx - XToY_Ratio) / 2.0; dx = XToY_Ratio; } else { XToY_Ratio = dx / XToY_Ratio; y -= (dy - XToY_Ratio) / 2.0; dy = XToY_Ratio; } } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::_Fit_Rectangle(CSG_Rect &r, double XToY_Ratio, bool bShrink) { double x, y, dx, dy; x = r.Get_XMin(); y = r.Get_YMin(); dx = r.Get_XRange(); dy = r.Get_YRange(); if( _Fit_Rectangle(x, y, dx, dy, XToY_Ratio, bShrink) ) { r.Assign(x, y, x + dx, y + dy); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::_Add_Outline_Item(const SG_Char *Title, struct _HPDF_Dict_Rec *pPage, TSG_PDF_Title_Level Level) { if( m_pPDF && pPage ) { HPDF_Outline pOutlineItem = NULL; switch( Level ) { case PDF_TITLE: pOutlineItem = m_pOutline_Last_Level_0 = HPDF_CreateOutline(m_pPDF, NULL, CSG_String(Title), NULL); break; case PDF_TITLE_01: if( m_pOutline_Last_Level_0 ) { pOutlineItem = m_pOutline_Last_Level_1 = HPDF_CreateOutline(m_pPDF, m_pOutline_Last_Level_0, CSG_String(Title), NULL); } break; case PDF_TITLE_02: if( m_pOutline_Last_Level_1 ) { pOutlineItem = m_pOutline_Last_Level_2 = HPDF_CreateOutline(m_pPDF, m_pOutline_Last_Level_1, CSG_String(Title), NULL); } break; case PDF_TITLE_NONE: if( m_pOutline_Last_Level_2 ) { pOutlineItem = HPDF_CreateOutline(m_pPDF, m_pOutline_Last_Level_2, CSG_String(Title), NULL); } break; } if( pOutlineItem ) { if( pPage ) { struct _HPDF_Array_Rec *pDestination = HPDF_Page_CreateDestination(pPage); HPDF_Destination_SetFit (pDestination); HPDF_Outline_SetDestination (pOutlineItem, pDestination); } return( true ); } } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Add_Outline_Item(const SG_Char *Title) { return( _Add_Outline_Item(Title, m_pPage, _Get_Lowest_Outline_Level()) ); } //--------------------------------------------------------- TSG_PDF_Title_Level CSG_Doc_PDF::_Get_Lowest_Outline_Level(void) { if( m_pOutline_Last_Level_2 ) { return( PDF_TITLE_NONE ); } else if( m_pOutline_Last_Level_1 ) { return( PDF_TITLE_02 ); } else if( m_pOutline_Last_Level_0 ) { return( PDF_TITLE_01 ); } return( PDF_TITLE ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Add_Page(void) { return( Add_Page(m_Size_Paper.Get_XRange(), m_Size_Paper.Get_YRange()) ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Add_Page(TSG_PDF_Page_Size Size, int Orientation) { if( Add_Page() ) { return( Set_Size_Page(Size, Orientation) ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Add_Page(double Width, double Height) { if( m_pPDF ) { m_nPages++; m_pPage = HPDF_AddPage(m_pPDF); Set_Size_Page(Width, Height); HPDF_Page_SetRGBStroke (m_pPage, 0.0, 0.0, 0.0); HPDF_Page_SetRGBFill (m_pPage, 1.0, 1.0, 1.0); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Set_Size_Page(TSG_PDF_Page_Size Size, int Orientation) { double Width, Height; switch( Size ) { case PDF_PAGE_SIZE_A4: default: Width = PDF_PAGE_WIDTH_A4; Height = PDF_PAGE_HEIGHT_A4; break; case PDF_PAGE_SIZE_A3: Width = PDF_PAGE_WIDTH_A3; Height = PDF_PAGE_HEIGHT_A3; break; } //----------------------------------------------------- if( Orientation == PDF_PAGE_ORIENTATION_LANDSCAPE ) { double a; a = Width; Width = Height; Height = a; } return( Set_Size_Page(Width, Height) ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Set_Size_Page(double Width, double Height) { if( Width > 0.0 && Height > 0.0 ) { m_Size_Paper.Assign(0.0, 0.0, Width, Height); m_Size_Margins = m_Size_Paper; m_Size_Margins.Deflate(10.0, false); _Layout_Set_Boxes(); if( m_pPage ) { HPDF_Page_SetWidth (m_pPage, (float)m_Size_Paper.Get_XRange()); HPDF_Page_SetHeight (m_pPage, (float)m_Size_Paper.Get_YRange()); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Add_Page_Title(const SG_Char *Title, TSG_PDF_Title_Level Level, TSG_PDF_Page_Size Size, int Orientation) { bool bLine, bDestination, bPage; int FontSize; //----------------------------------------------------- if( Add_Page() ) { if( m_nPages % 2 - 1 ) { Add_Page(); } if( Size != PDF_PAGE_SIZE_PREVIOUS || Orientation != PDF_PAGE_ORIENTATION_PREVIOUS ) { Set_Size_Page(Size, Orientation); } //------------------------------------------------- switch( Level ) { case PDF_TITLE: FontSize = 26; bLine = true; bDestination = true; bPage = true; break; case PDF_TITLE_01: FontSize = 22; bLine = true; bDestination = false; bPage = true; break; case PDF_TITLE_02: FontSize = 20; bLine = false; bDestination = false; bPage = false; break; } _Add_Outline_Item(Title, m_pPage, Level); //------------------------------------------------- Draw_Text(Get_Margins().Get_XCenter(), Get_Margins().Get_YCenter(), Title, FontSize, PDF_STYLE_TEXT_ALIGN_H_CENTER, 0.0, SG_GET_RGB(0, 0, 0)); //------------------------------------------------- if( bLine ) { double y = Get_Margins().Get_YCenter() - 25.0; Draw_Line(Get_Margins().Get_XMin(), y, Get_Margins().Get_XMax(), y, 5, SG_GET_RGB(0, 0, 0), PDF_STYLE_LINE_END_ROUND); } if( bPage ) { Add_Page(); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::_Set_Style_FillStroke(int Style, int Fill_Color, int Line_Color, int Line_Width) { if( Is_Ready_To_Draw() ) { if( Style & PDF_STYLE_POLYGON_STROKE ) { if( Style & PDF_STYLE_LINE_END_ROUND ) { HPDF_Page_SetLineCap(m_pPage, HPDF_ROUND_END); } else if( Style & PDF_STYLE_LINE_END_SQUARE ) { HPDF_Page_SetLineCap(m_pPage, HPDF_PROJECTING_SCUARE_END); } else // if( Style & PDF_STYLE_LINE_END_BUTT ) { HPDF_Page_SetLineCap(m_pPage, HPDF_BUTT_END); } if( Style & PDF_STYLE_LINE_JOIN_ROUND ) { HPDF_Page_SetLineJoin(m_pPage, HPDF_ROUND_JOIN); } else if( Style & PDF_STYLE_LINE_JOIN_BEVEL ) { HPDF_Page_SetLineJoin(m_pPage, HPDF_BEVEL_JOIN); } else // if( Style & PDF_STYLE_LINE_JOIN_MITER ) { HPDF_Page_SetLineJoin(m_pPage, HPDF_MITER_JOIN); } HPDF_Page_SetRGBStroke (m_pPage, PDF_GET_R(Line_Color), PDF_GET_G(Line_Color), PDF_GET_B(Line_Color)); HPDF_Page_SetLineWidth (m_pPage, (float)Line_Width); } //------------------------------------------------- if( Style & PDF_STYLE_POLYGON_FILL ) { HPDF_Page_SetRGBFill(m_pPage, PDF_GET_R(Fill_Color), PDF_GET_G(Fill_Color), PDF_GET_B(Fill_Color)); } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Point(double x, double y, double Width, int Style, int Fill_Color, int Line_Color, int Line_Width) { if( Is_Ready_To_Draw() ) { Width /= 2.0; //------------------------------------------------- // if( Style & PDF_STYLE_POINT_CIRCLE ) { } // else // if( Style & PDF_STYLE_POINT_SQUARE ) { return( Draw_Rectangle(x - Width, y - Width, x + Width, y + Width, Style, Fill_Color, Line_Color, Line_Width) ); } } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Line(double xa, double ya, double xb, double yb, int Width, int Color, int Style) { CSG_Points Points; Points.Add(xa, ya); Points.Add(xb, yb); return( Draw_Line(Points, Width, Color, Style) ); } bool CSG_Doc_PDF::Draw_Line(CSG_Points &Points, int Width, int Color, int Style) { if( Points.Get_Count() > 1 && _Set_Style_FillStroke(Style|PDF_STYLE_POLYGON_STROKE, 0, Color, Width) ) { HPDF_Page_MoveTo(m_pPage, (float)Points[0].x, (float)Points[0].y); for(int i=1; i 2 && _Set_Style_FillStroke(Style, Fill_Color, Line_Color, Line_Width) ) { HPDF_Page_MoveTo(m_pPage, (float)Points[0].x, (float)Points[0].y); for(int i=1; i 0 ) { for(int i=0; i= 0 ) { Strings.Add(String.Left(n)); String.Remove(0, n + 1); } if( Strings.Get_Count() > 0 ) { if( String.Length() > 0 ) { Strings.Add(String); } return( Draw_Text(x, y, Strings, Size, Style, Angle, Color, Font) ); } return( _Draw_Text(x, y, Text, Size, Style, Angle, Color, Font) ); } //--------------------------------------------------------- bool CSG_Doc_PDF::_Draw_Text(double x, double y, const SG_Char *Text, int Size, int Style, double Angle, int Color, TSG_PDF_Font_Type Font) { float Width, Height; if( m_pPage && Text && *Text != '\0' ) { double ax, ay, bx, by; HPDF_Page_SetFontAndSize(m_pPage, _Get_Font(Font), (float)Size); HPDF_Page_SetTextRenderingMode(m_pPage, HPDF_FILL_THEN_STROKE); HPDF_Page_SetLineWidth (m_pPage, 0); HPDF_Page_SetRGBStroke (m_pPage, PDF_GET_R(Color), PDF_GET_G(Color), PDF_GET_B(Color)); HPDF_Page_SetRGBFill (m_pPage, PDF_GET_R(Color), PDF_GET_G(Color), PDF_GET_B(Color)); Width = HPDF_Page_TextWidth(m_pPage, CSG_String(Text)) * (float)cos(Angle); Height = HPDF_Page_TextWidth(m_pPage, CSG_String(Text)) * (float)sin(Angle) + Size; //------------------------------------------------- if( Style & PDF_STYLE_TEXT_ALIGN_H_CENTER ) { ax = x - HPDF_Page_TextWidth(m_pPage, CSG_String(Text)) / 2.0; } else if( Style & PDF_STYLE_TEXT_ALIGN_H_RIGHT ) { ax = x - HPDF_Page_TextWidth(m_pPage, CSG_String(Text)); } else { ax = x; } bx = ax + HPDF_Page_TextWidth(m_pPage, CSG_String(Text)); if( Style & PDF_STYLE_TEXT_ALIGN_V_CENTER ) { ay = y - Size / 2.0; } else if( Style & PDF_STYLE_TEXT_ALIGN_V_TOP ) { ay = y - Size; } else { ay = y; } by = ay; //------------------------------------------------- HPDF_Page_BeginText(m_pPage); if( Angle != 0.0 ) { double dSin, dCos, dx, dy; dSin = sin(-Angle); dCos = cos(-Angle), dx = ax - x, dy = ay - y; ax = x + dCos * dx + dSin * dy; ay = y - dSin * dx + dCos * dy; dx = bx - x, dy = by - y; bx = x + dCos * dx + dSin * dy; by = y - dSin * dx + dCos * dy; dSin = sin(Angle); dCos = cos(Angle), HPDF_Page_SetTextMatrix(m_pPage, (float)dCos, (float)dSin, -(float)dSin, (float)dCos, (float)ax, (float)ay); } else { HPDF_Page_MoveTextPos(m_pPage, (float)ax, (float)ay); } HPDF_Page_ShowText(m_pPage, CSG_String(Text)); HPDF_Page_EndText(m_pPage); //------------------------------------------------- if( Style & PDF_STYLE_TEXT_UNDERLINE ) { double dx, dy; dy = 0.2 * Size * (ax - bx) / SG_Get_Distance(ax, ay, bx, by); dx = -0.2 * Size * (ay - by) / SG_Get_Distance(ax, ay, bx, by); Draw_Line(ax + dx, ay + dy, bx + dx, by + dy, (int)(0.1 * Size), Color); } if( Style & PDF_STYLE_TEXT_STROKE ) { double dx, dy; dy = -0.4 * Size * (ax - bx) / SG_Get_Distance(ax, ay, bx, by); dx = 0.4 * Size * (ay - by) / SG_Get_Distance(ax, ay, bx, by); Draw_Line(ax + dx, ay + dy, bx + dx, by + dy, (int)(0.1 * Size), Color); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Image(double x, double y, double dx, double dy, const SG_Char *FileName) { bool bKeepRatio = true; double nx, ny; HPDF_Image pImage = NULL; //----------------------------------------------------- if( m_pPage && SG_File_Exists(FileName) && dx > 0.0 && dy > 0.0 ) { if( SG_File_Cmp_Extension(FileName, SG_T("png")) ) { try { pImage = HPDF_LoadPngImageFromFile (m_pPDF, CSG_String(FileName)); } catch(...) {} } else if( SG_File_Cmp_Extension(FileName, SG_T("jpg")) ) { try { pImage = HPDF_LoadJpegImageFromFile(m_pPDF, CSG_String(FileName)); } catch(...) {} } } //----------------------------------------------------- if( pImage && (nx = HPDF_Image_GetWidth(pImage)) > 0 && (ny = HPDF_Image_GetHeight(pImage)) > 0 ) { if( bKeepRatio ) { _Fit_Rectangle(x, y, dx, dy, nx / ny, true); } HPDF_Page_DrawImage(m_pPage, pImage, (float)x, (float)y, (float)dx, (float)dy); return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Image(const CSG_Rect &r, const SG_Char *FileName) { return( Draw_Image(r.Get_XMin(), r.Get_YMin(), r.Get_XRange(), r.Get_YRange(), FileName) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Graticule(const CSG_Rect &r, const CSG_Rect &rWorld, int Size) { if( Is_Ready_To_Draw() ) { CSG_Rect rRuler, rFrame(r); rFrame.Inflate(Size, false); Draw_Rectangle(rFrame, PDF_STYLE_POLYGON_STROKE); Draw_Rectangle(r , PDF_STYLE_POLYGON_STROKE); rRuler.Assign(r.Get_XMin(), r.Get_YMax(), r.Get_XMax(), rFrame.Get_YMax()); _Draw_Ruler(rRuler, rWorld.Get_XMin(), rWorld.Get_XMax() , true , true , false); rRuler.Assign(r.Get_XMin(), r.Get_YMin(), r.Get_XMax(), rFrame.Get_YMin()); _Draw_Ruler(rRuler, 0.0 , rWorld.Get_XRange(), true , true , true); rRuler.Assign(r.Get_XMin(), r.Get_YMin(), rFrame.Get_XMin(), r.Get_YMax()); _Draw_Ruler(rRuler, rWorld.Get_YMin(), rWorld.Get_YMax() , false, false, false); rRuler.Assign(r.Get_XMax(), r.Get_YMin(), rFrame.Get_XMax(), r.Get_YMax()); _Draw_Ruler(rRuler, 0.0 , rWorld.Get_YRange(), false, false, true); return( true ); } return( false ); } //--------------------------------------------------------- #define RULER_TEXT_SPACE 4 //--------------------------------------------------------- bool CSG_Doc_PDF::_Draw_Ruler(const CSG_Rect &r, double zMin, double zMax, bool bHorizontal, bool bAscendent, bool bTickAtTop) { int Decimals, FontSize; double xOff, yOff, Width, Height, Height_Tick, z, dz, zToDC, zDC, zPos, tPos; CSG_String s; //----------------------------------------------------- Width = bHorizontal ? r.Get_XRange() : r.Get_YRange(); Height = bHorizontal ? r.Get_YRange() : r.Get_XRange(); if( Is_Ready_To_Draw() && zMin < zMax && Width > 0 && Height > 0 ) { xOff = r.Get_XMin(); yOff = r.Get_YMax(); FontSize = (int)(0.45 * (double)Height); HPDF_Page_SetFontAndSize(m_pPage, _Get_Font(PDF_FONT_DEFAULT), (float)FontSize); Height_Tick = (int)(0.3 * (double)Height); //------------------------------------------------- zToDC = (double)Width / (zMax - zMin); dz = pow(10.0, floor(log10(zMax - zMin)) - 1.0); Decimals = dz >= 1.0 ? 0 : (int)fabs(log10(dz)); s.Printf(SG_T("%.*f"), Decimals, zMax); zDC = HPDF_Page_TextWidth(m_pPage, CSG_String(s)); while( zToDC * dz < zDC + RULER_TEXT_SPACE ) { dz *= 2; } //------------------------------------------------- z = dz * floor(zMin / dz); if( z < zMin ) z += dz; for(; z<=zMax; z+=dz) { s.Printf(SG_T("%.*f"), Decimals, z); zDC = bAscendent ? zToDC * (z - zMin) : Width - zToDC * (z - zMin); if( bHorizontal ) { zPos = xOff + zDC; if( bTickAtTop ) { tPos = yOff; Draw_Line(zPos, tPos - Height_Tick, zPos, yOff); Draw_Text(zPos, tPos - Height_Tick, s, FontSize, PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_TOP, 0.0); } else { tPos = yOff - Height; Draw_Line(zPos, tPos + Height_Tick, zPos, tPos); Draw_Text(zPos, tPos + Height_Tick, s, FontSize, PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_BOTTOM, 0.0); } } else { zPos = yOff - zDC; if( bTickAtTop ) { tPos = xOff; Draw_Line(tPos + Height_Tick, zPos, tPos, zPos); Draw_Text(tPos + Height_Tick, zPos, s, FontSize, PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_TOP, M_DEG_TO_RAD * 90.0); } else { tPos = xOff + Height; Draw_Line(tPos - Height_Tick, zPos, tPos, zPos); Draw_Text(tPos - Height_Tick, zPos, s, FontSize, PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_BOTTOM, M_DEG_TO_RAD * 90.0); } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::_Draw_Table(CSG_Rect r, CSG_Table *pTable, int iRecord, int nRecords, double CellHeight, double HeaderHeightRel) { int iField, dyFont, dyFont_Hdr; double xPos, yPos, dxPos, dyPos, dyPos_Hdr, xSpace, ySpace, ySpace_Hdr; bool bAddHeader; CSG_Table_Record *pRecord; if( pTable && pTable->is_Valid() && iRecord < pTable->Get_Record_Count() ) { // Draw_Text(r.Get_XMin(), r.Get_YMax(), pTable->Get_Name(), 16); // the table's name should not be drawn here... dxPos = r.Get_XRange() / pTable->Get_Field_Count(); if( HeaderHeightRel < 1.0 ) HeaderHeightRel = 1.0; dyPos = CellHeight > 0.0 ? CellHeight : r.Get_YRange() / (nRecords + HeaderHeightRel); dyPos_Hdr = dyPos * HeaderHeightRel; dyFont = (int)(0.75 * dyPos); dyFont_Hdr = (int)(0.75 * dyPos_Hdr); ySpace = 0.1 * dyPos; ySpace_Hdr = 0.1 * dyPos_Hdr; xSpace = ySpace; nRecords += iRecord; if( nRecords > pTable->Get_Record_Count() ) { nRecords = pTable->Get_Record_Count(); } //------------------------------------------------- for(yPos=r.Get_YMax(), bAddHeader=true; iRecordGet_Field_Count(); iField++, xPos+=dxPos) { Draw_Rectangle(xPos, yPos, xPos + dxPos, yPos - dyPos_Hdr, PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_GREY_LIGHT, SG_COLOR_BLACK, 0); Draw_Text(xPos + xSpace, yPos - ySpace_Hdr, pTable->Get_Field_Name(iField), dyFont_Hdr, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP); } yPos -= dyPos_Hdr; bAddHeader = false; } //--------------------------------------------- pRecord = pTable->Get_Record(iRecord); for(iField=0, xPos=r.Get_XMin(); iFieldGet_Field_Count(); iField++, xPos+=dxPos) { Draw_Rectangle(xPos, yPos, xPos + dxPos, yPos - dyPos, PDF_STYLE_POLYGON_STROKE, SG_COLOR_WHITE, SG_COLOR_BLACK, 0); Draw_Text(xPos + xSpace, yPos - ySpace, pRecord->asString(iField), dyFont, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP); } } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Table(const CSG_Rect &r, CSG_Table *pTable, double CellHeight, double HeaderHeightRel) { if( pTable && pTable->is_Valid() ) { return( _Draw_Table(r, pTable, 0, pTable->Get_Record_Count(), CellHeight, HeaderHeightRel) ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Table(const CSG_Rect &r, CSG_Table *pTable, int nColumns, double CellHeight, double HeaderHeightRel) { if( pTable && pTable->is_Valid() && nColumns > 1 ) { int nRecords; double dx, dxSpace; CSG_Rect rColumn(r), rTable(r); dxSpace = 4; rTable.Inflate(dxSpace, 0.0, false); dx = rTable.Get_XRange() / (double)nColumns; nRecords = pTable->Get_Record_Count() / nColumns; for(int i=0, iRecord=0; iis_Valid() ) { int iPart, iPoint; TSG_Point Point; CSG_Points Points; for(iPart=0; iPartGet_Part_Count(); iPart++) { Points.Clear(); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Point = pShape->Get_Point(iPoint, iPart); Point.x = r.Get_XMin() + World2PDF * (Point.x - xMin); Point.y = r.Get_YMin() + World2PDF * (Point.y - yMin); Points.Add(Point.x, Point.y); } switch( pShape->Get_Type() ) { case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: for(iPoint=0; iPointis_Lake(iPart) ) { Draw_Polygon(Points, PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_WHITE, Line_Color, Line_Width); } else { Draw_Polygon(Points, Style, Fill_Color, Line_Color, Line_Width); } break; } } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Shape(const CSG_Rect &r, CSG_Shape *pShape, int Style, int Fill_Color, int Line_Color, int Line_Width, CSG_Rect *prWorld) { double World2PDF; CSG_Rect rWorld, rFit; if( pShape && pShape->is_Valid() && r.Get_XRange() > 0.0 && r.Get_YRange() > 0.0 ) { rWorld = prWorld ? *prWorld : pShape->Get_Extent(); if( rWorld.Get_XRange() > 0.0 && rWorld.Get_YRange() > 0.0 ) { _Fit_Rectangle(rFit = r, rWorld.Get_XRange() / rWorld.Get_YRange(), true); World2PDF = rFit.Get_XRange() / rWorld.Get_XRange(); _Draw_Shape(rFit, pShape, rWorld.Get_XMin(), rWorld.Get_YMin(), World2PDF, Style, Fill_Color, Line_Color, Line_Width, Line_Width); return( true ); } } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Shapes(const CSG_Rect &r, CSG_Shapes *pShapes, int Style, int Fill_Color, int Line_Color, int Line_Width, CSG_Rect *prWorld) { double World2PDF; CSG_Rect rWorld, rFit; if( pShapes && pShapes->is_Valid() && r.Get_XRange() > 0.0 && r.Get_YRange() > 0.0 ) { rWorld = prWorld ? *prWorld : pShapes->Get_Extent(); if( rWorld.Get_XRange() > 0.0 && rWorld.Get_YRange() > 0.0 ) { _Fit_Rectangle(rFit = r, rWorld.Get_XRange() / rWorld.Get_YRange(), true); World2PDF = rFit.Get_XRange() / rWorld.Get_XRange(); for(int iShape=0; iShapeGet_Count(); iShape++) { _Draw_Shape(rFit, pShapes->Get_Shape(iShape), rWorld.Get_XMin(), rWorld.Get_YMin(), World2PDF, Style, Fill_Color, Line_Color, Line_Width, Line_Width); } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Grid(const CSG_Rect &r, CSG_Grid *pGrid, const CSG_Colors &Colors, double zMin, double zMax, int Style, CSG_Rect *prWorld) { double x, y, z, d, xFit, yFit, dFit; CSG_Rect rWorld, rFit; if( Is_Ready_To_Draw() && pGrid && pGrid->is_Valid() && pGrid->Get_ZRange() > 0.0 ) { rWorld = prWorld ? *prWorld : pGrid->Get_Extent(); if( rWorld.Get_XRange() > 0.0 && rWorld.Get_YRange() > 0.0 ) { _Fit_Rectangle(rFit = r, rWorld.Get_XRange() / rWorld.Get_YRange(), true); dFit = 1.0; d = dFit * (rWorld.Get_XRange() / rFit.Get_XRange()); if( zMin >= zMax ) { zMin = pGrid->Get_ZMin(); zMax = pGrid->Get_ZMax(); } zMax = Colors.Get_Count() / (zMax - zMin); for(y=rWorld.Get_YMin(), yFit=rFit.Get_YMin(); yFitGet_Extent().Get_YMax(); y++, yFit+=dFit, y+=d) { for(x=rWorld.Get_XMin(), xFit=rFit.Get_XMin(); xFitGet_Extent().Get_XMax(); x++, xFit+=dFit, x+=d) { if( pGrid->Get_Value(x, y, z) ) { Draw_Point(xFit, yFit, dFit, PDF_STYLE_POINT_SQUARE|PDF_STYLE_POLYGON_FILL, Colors.Get_Color((int)(zMax * (z - zMin)))); } } } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSG_Doc_PDF::Draw_Curve(CSG_Points &Data, const CSG_Rect &r, int iGraphType) { /* int i; int iMag; int iNumLines; int iNumData; float fMinLine = 0; float fWidth; float fMax, fMin; float fStep; float fX, fY; float fMaxX, fMinX; float fOffsetX; CSG_String sValue; CSG_Points Points; fMin = fMax = Data[0].y; for (i = 0; i < Data.Get_Count(); i++) { if (Data[i].y > fMax) { fMax = Data[i].y; } if (Data[i].y < fMin) { fMin = Data[i].y; } if (iGraphType == PDF_GRAPH_TYPE_BARS){ fMin = M_GET_MIN(0, fMin); } } if (fMin != fMax){ iMag = (int) (log(fMax - fMin) / log(10.0)); fStep = (float) ((int) pow(10.0, (double) iMag)); if (fStep == 0) { fStep = 1.; } if (fMin < 0) { iMag = (int) (log(fabs(fMin)) / log(10.0)); fMinLine = -(int) pow(10.0, (double) iMag); } else { fMinLine=(int)(((int)(fMin/fStep)) *fStep); } iNumLines = (int) ((fMax - fMin) / fStep); while (iNumLines < 8) { fStep = fStep / 2.0; iNumLines = (int) ((fMax - fMin) / fStep); } iNumLines = (int) ((fMax - fMinLine) / fStep); } else{ if (fMin > 0) { fStep = fMin = 0; iNumLines = 1; fMinLine = fMax; } else if (fMin < 0) { fStep = 0; fMin = fMin - 1; fMinLine = fMax; } else { return; } } for (i = 0; i < iNumLines; i++) { fY = r.Get_YMax() - ((fMinLine + fStep * i - fMin) / (fMax - fMin)) * r.Get_YRange(); if (fY <= r.Get_YMax() && fY >= r.Get_YMin()) { fY = HPDF_Page_Height() - fY; } } if (iGraphType == PDF_GRAPH_TYPE_BARS) { fWidth = (float) r.Get_XRange() / (float) (Data.Get_Count()); for (i = 0; i < Data.Get_Count(); i++) { fX = r.Get_XMin() + i * fWidth; fY = r.Get_YMax(); fY = HPDF_Page_Height() - fY; Draw_Rectangle(fX, fY, fX + fWidth, fY - r.Get_YRange() * ((Data[i].y - fMin) / (fMax - fMin)), PDF_STYLE_POLYGON_FILLSTROKE, 0x660000); } } else { fWidth = (float) r.Get_XRange() / (float) (Data.Get_Count() - 1); fY = r.Get_YMin() + r.Get_YRange() - r.Get_YRange() * ((Data[0].y - fMin) / (fMax - fMin)); fY = HPDF_Page_Height() - fY; Points.Add(r.Get_XMin(), fY); for (i = 1; i < Data.Get_Count(); i++) { fY = r.Get_YMin() + r.Get_YRange() - r.Get_YRange() * ((Data[i].y - fMin) / (fMax - fMin)); fY = HPDF_Page_Height() - fY; Points.Add(r.Get_XMin() + i * fWidth, fY); } Draw_Line(Points, 3, 0x660000); } fMaxX = Data[Data.Get_Count() - 1].x; fMinX = Data[0].x; if (fMaxX != fMinX) { iMag = (int) (log(fMaxX - fMinX) / log(10.0)); fStep = (float) pow(10.0, (double) iMag); iNumData = (int) ((fMaxX-fMinX) / fStep); while (iNumData < 3) { fStep = fStep / 2.0; iNumData = (int) ((fMaxX-fMinX) / fStep); } fMinLine = (int)(((int)(fMinX/fStep)) * fStep); while (fMinLine= r.Get_XMin() && fX < r.Get_XMin() + r.Get_XRange()){ if (fabs(fStep * (float)i +fMinLine) > 100000) { sValue = SG_Get_String(fStep * (float)i +fMinLine); } else { sValue = SG_Get_String(fStep * (float)i + fMinLine, 2, true); } Draw_Text(fX, fY, sValue, 9, PDF_STYLE_TEXT_ALIGN_H_RIGHT); Draw_Line(fX, fY, fX, fY - 10, 1); } } } Draw_Line(r.Get_XMin(), HPDF_Page_Height() - r.Get_YMin(), r.Get_XMin(), HPDF_Page_Height() - r.Get_YMax(), 4); Draw_Line(r.Get_XMin(), HPDF_Page_Height() - r.Get_YMax(), r.Get_XMax(), HPDF_Page_Height() - r.Get_YMax(), 4); */ } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #else // #ifndef _SAGA_DONOTUSE_HARU #include "doc_pdf.h" //--------------------------------------------------------- const SG_Char * CSG_Doc_PDF::Get_Version(void) { return( NULL ); } CSG_Doc_PDF::CSG_Doc_PDF(void) { m_pPDF = NULL; } CSG_Doc_PDF::CSG_Doc_PDF(TSG_PDF_Page_Size Size, int Orientation, const SG_Char *Title) { m_pPDF = NULL; } CSG_Doc_PDF::~CSG_Doc_PDF(void) {} void CSG_Doc_PDF::Layout_Set_Box_Space(double Space, bool bPercent) {} void CSG_Doc_PDF::_Layout_Set_Boxes(void) {} void CSG_Doc_PDF::_Layout_Set_Box(int iBox) {} double CSG_Doc_PDF::Get_Page_To_Meter(void) { return( 1.0 ); } struct _HPDF_Dict_Rec * CSG_Doc_PDF::_Get_Font(TSG_PDF_Font_Type Font) { return( NULL ); } const CSG_Rect & CSG_Doc_PDF::Layout_Get_Box(const SG_Char *ID) { return( m_Size_Margins ); } TSG_PDF_Title_Level CSG_Doc_PDF::_Get_Lowest_Outline_Level(void) { return( PDF_TITLE_NONE ); } bool CSG_Doc_PDF::Open(const SG_Char *Title) { return( false ); } bool CSG_Doc_PDF::Open(TSG_PDF_Page_Size Size, int Orientation, const SG_Char *Title) { return( false ); } bool CSG_Doc_PDF::Close(void) { return( false ); } bool CSG_Doc_PDF::Save(const SG_Char *FileName) { return( false ); } bool CSG_Doc_PDF::Layout_Add_Box(double xMin_Percent, double yMin_Percent, double xMax_Percent, double yMax_Percent, const SG_Char *ID) { return( false ); } bool CSG_Doc_PDF::Layout_Add_Box(const CSG_Rect &Box_Percent, const SG_Char *ID) { return( false ); } bool CSG_Doc_PDF::_Fit_Rectangle(double &x, double &y, double &dx, double &dy, double XToY_Ratio, bool bShrink) { return( false ); } bool CSG_Doc_PDF::_Fit_Rectangle(CSG_Rect &r, double XToY_Ratio, bool bShrink) { return( false ); } bool CSG_Doc_PDF::_Add_Outline_Item(const SG_Char *Title, struct _HPDF_Dict_Rec *pPage, TSG_PDF_Title_Level Level) { return( false ); } bool CSG_Doc_PDF::Add_Outline_Item(const SG_Char *Title) { return( false ); } bool CSG_Doc_PDF::Add_Page(void) { return( false ); } bool CSG_Doc_PDF::Add_Page(TSG_PDF_Page_Size Size, int Orientation) { return( false ); } bool CSG_Doc_PDF::Add_Page(double Width, double Height) { return( false ); } bool CSG_Doc_PDF::Set_Size_Page(TSG_PDF_Page_Size Size, int Orientation) { return( false ); } bool CSG_Doc_PDF::Set_Size_Page(double Width, double Height) { return( false ); } bool CSG_Doc_PDF::Add_Page_Title(const SG_Char *Title, TSG_PDF_Title_Level Level, TSG_PDF_Page_Size Size, int Orientation) { return( false ); } bool CSG_Doc_PDF::_Set_Style_FillStroke(int Style, int Fill_Color, int Line_Color, int Line_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Point(double x, double y, double Width, int Style, int Fill_Color, int Line_Color, int Line_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Line(double xa, double ya, double xb, double yb, int Width, int Color, int Style) { return( false ); } bool CSG_Doc_PDF::Draw_Line(CSG_Points &Points, int Width, int Color, int Style) { return( false ); } bool CSG_Doc_PDF::Draw_Rectangle(double xa, double ya, double xb, double yb, int Style, int Fill_Color, int Line_Color, int Line_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Rectangle(const CSG_Rect &r, int Style, int Fill_Color, int Line_Color, int Line_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Polygon(CSG_Points &Points, int Style, int Fill_Color, int Line_Color, int Line_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Text(double x, double y, CSG_Strings &Text, int Size, int Style, double Angle, int Color, TSG_PDF_Font_Type Font) { return( false ); } bool CSG_Doc_PDF::Draw_Text(double x, double y, const SG_Char *Text, int Size, int Style, double Angle, int Color, TSG_PDF_Font_Type Font) { return( false ); } bool CSG_Doc_PDF::_Draw_Text(double x, double y, const SG_Char *Text, int Size, int Style, double Angle, int Color, TSG_PDF_Font_Type Font) { return( false ); } bool CSG_Doc_PDF::Draw_Image(double x, double y, double dx, double dy, const SG_Char *FileName) { return( false ); } bool CSG_Doc_PDF::Draw_Image(const CSG_Rect &r, const SG_Char *FileName) { return( false ); } bool CSG_Doc_PDF::Draw_Graticule(const CSG_Rect &r, const CSG_Rect &rWorld, int Size) { return( false ); } bool CSG_Doc_PDF::_Draw_Ruler(const CSG_Rect &r, double zMin, double zMax, bool bHorizontal, bool bAscendent, bool bTickAtTop) { return( false ); } bool CSG_Doc_PDF::_Draw_Table(CSG_Rect r, CSG_Table *pTable, int iRecord, int nRecords, double CellHeight, double HeaderHeightRel) { return( false ); } bool CSG_Doc_PDF::Draw_Table(const CSG_Rect &r, CSG_Table *pTable, double CellHeight, double HeaderHeightRel) { return( false ); } bool CSG_Doc_PDF::Draw_Table(const CSG_Rect &r, CSG_Table *pTable, int nColumns, double CellHeight, double HeaderHeightRel) { return( false ); } bool CSG_Doc_PDF::_Draw_Shape(CSG_Rect r, CSG_Shape *pShape, double xMin, double yMin, double World2PDF, int Style, int Fill_Color, int Line_Color, int Line_Width, int Point_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Shape(const CSG_Rect &r, CSG_Shape *pShape, int Style, int Fill_Color, int Line_Color, int Line_Width, CSG_Rect *prWorld) { return( false ); } bool CSG_Doc_PDF::Draw_Shapes(const CSG_Rect &r, CSG_Shapes *pShapes, int Style, int Fill_Color, int Line_Color, int Line_Width, CSG_Rect *prWorld) { return( false ); } bool CSG_Doc_PDF::Draw_Grid(const CSG_Rect &r, CSG_Grid *pGrid, const CSG_Colors &Colors, double zMin, double zMax, int Style, CSG_Rect *prWorld) { return( false ); } void CSG_Doc_PDF::Draw_Curve(CSG_Points &Data, const CSG_Rect &r, int iGraphType) {} #endif // #else // #ifndef _SAGA_DONOTUSE_HARU /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/docs/docs_pdf/MLB_Interface.cpp0000664000175000017500000001076712565125412023653 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_pdf // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("PDF") ); case MLB_INFO_Category: return( _TL("Reports") ); case MLB_INFO_Author: return( SG_T("SAGA User Group (c) 2010") ); case MLB_INFO_Description: return( _TW( "Reports in Portable Document Format (PDF). PDF export is based on " "libharu." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Reports") ); } } //--------------------------------------------------------- #include "Shapes_Report.h" #include "Shapes_Summary.h" #include "Profile_Cross_Sections.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CShapes_Report ); case 1: return( new CShapes_Summary ); case 2: return( new CProfile_Cross_Sections ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/docs/docs_pdf/Makefile.am0000664000175000017500000000141012565125412022572 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif if SAGA_UNICODE UC_DEFS = -D_SAGA_UNICODE endif if HAVE_HARU 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) $(DISABLELIBHARU) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(HARU_LIB) pkglib_LTLIBRARIES = libdocs_pdf.la libdocs_pdf_la_SOURCES =\ doc_pdf.cpp\ MLB_Interface.cpp\ Profile_Cross_Sections.cpp\ Shapes_Report.cpp\ Shapes_Summary.cpp\ doc_pdf.h\ MLB_Interface.h\ Profile_Cross_Sections.h\ Shapes_Report.h\ Shapes_Summary.h libdocs_pdf_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la endif saga-2.2.3/src/modules/docs/docs_pdf/MLB_Interface.h0000664000175000017500000000756012565125412023315 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_pdf // // // //-------------------------------------------------------// // // // MLB_Interface.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__docs_pdf__mlb_interface_H #define HEADER_INCLUDED__docs_pdf__mlb_interface_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef docs_pdf_EXPORTS #define docs_pdf_EXPORT _SAGA_DLL_EXPORT #else #define docs_pdf_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__docs_pdf__mlb_interface_H saga-2.2.3/src/modules/docs/docs_html/0000775000175000017500000000000012634325736020745 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/docs/docs_html/svg_interactive_map.h0000664000175000017500000001267612565125412025153 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: svg_interactive_map.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // SVG_Interactive_map.cpp // // // // Copyright (C) 2005 by 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Victor Olaya // // // // e-mail: volaya@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef _HEADER_INCLUDED__SAGA_GUI__svg_interactive_map_H #define _HEADER_INCLUDED__SAGA_GUI__svg_interactive_map_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_svg.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSVG_Interactive_Map : public CSG_Doc_SVG, public CSG_Module { public: CSVG_Interactive_Map(void); virtual ~CSVG_Interactive_Map(void); protected: virtual bool On_Execute(void); private: CSG_String m_Directory; double m_dWidth; bool Create_From_Map (CSG_Parameter_Shapes_List *pList, CSG_Shapes *pIndexLayer, const SG_Char *Filename); void _Write_Code (const CSG_String &FileName, const CSG_String &Code); void _Add_Opening (CSG_Rect r); void _Add_CheckBoxes (CSG_Parameter_Shapes_List *pList); void _Add_Shapes (CSG_Shapes *pLayer); bool _Add_Shape (CSG_Shape *pShape, int Fill_Color, int Line_Color, double Line_Width, double Point_Width); void _Add_Grid (CSG_Grid *pLayer); void _Add_ReferenceMap (CSG_Shapes *pIndexLayer, CSG_Rect r); void _Add_Label (const SG_Char* Label, CSG_Shape *pShape, double dSize, const SG_Char* Unit); const char * _Get_Opening_Code_1 (void); const char * _Get_Opening_Code_2 (void); const char * _Get_Code_1 (void); const char * _Get_Code_2 (void); const char * _Get_Code_3 (void); const char * _Get_Code_4 (void); const char * _Get_Code_5 (void); const char * _Get_Code_Closing_1 (void); const char * _Get_Code_CheckBox (void); const char * _Get_Code_MapApp (void); const char * _Get_Code_Timer (void); const char * _Get_Code_Slider (void); const char * _Get_Code_Helper (void); const char * _Get_Code_Buttons (void); const char * _Get_Code_Navigation_1 (void); const char * _Get_Code_Navigation_2 (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef _HEADER_INCLUDED__SAGA_GUI__svg_interactive_map_H saga-2.2.3/src/modules/docs/docs_html/doc_html.h0000664000175000017500000001425012565125412022701 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_html.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // doc_html.h // // // // Copyright (C) 2005 by // // Victor Olaya // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__docs_html__doc_html_H #define HEADER_INCLUDED__docs_html__doc_html_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_svg.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define HTML_GRAPH_TYPE_BARS 1 #define HTML_GRAPH_TYPE_LINES 2 #define HTML_COLOR_RANDOM -2 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class docs_html_EXPORT CSG_Doc_HTML { public: CSG_Doc_HTML(void); virtual ~CSG_Doc_HTML(void); void Open (const SG_Char *Title); bool Save (const SG_Char *FileName); void AddCurve (const SG_Char *Filename, CSG_Points &Points, const SG_Char *Description, int iGraphType, bool bIncludeTableData); void AddTable (const SG_Char ***Table, int iRows, int iCols, const SG_Char *Description); void AddTable (CSG_Table *pTable); void AddParagraph (const SG_Char *Text); void AddLineBreak (); void AddHeader (const SG_Char *Text, int iOrder); void AddHyperlink (const SG_Char *Text, const SG_Char *URL); CSG_String GetHyperlinkCode (const SG_Char *Text, const SG_Char *URL); void AddImage (const SG_Char *Filename); void AddThumbnail (const SG_Char *Filename, int iWidth, bool bIsPercent); void AddThumbnails (const SG_Char **Text, int iImages, int iThumbnailsPerRow); void StartUnorderedList (void); void StartOrderedList (void); void CloseUnorderedList (void); void CloseOrderedList (void); void AddListElement (const SG_Char *Text); void AddOrderedList (const SG_Char **Text, int iElement); void AddUnorderedList (const SG_Char **Text, int iElement); bool Draw_Shapes (CSG_Shapes *pShapes, const SG_Char *Filename, int Fill_Color, int Line_Color, int Line_Width); private: CSG_String m_sHTMLCode; bool _Draw_Shape (CSG_Doc_SVG &SVG, CSG_Shape *pShape, CSG_Rect GlobalRect, int Fill_Color, int Line_Color, int Line_Width, int Point_Width); void _AddBicolumTable (CSG_Points *pData); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__docs_html__doc_html_H saga-2.2.3/src/modules/docs/docs_html/doc_svg.cpp0000664000175000017500000002726012565125412023074 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_svg.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // // // //-------------------------------------------------------// // // // doc_svg.cpp // // // // Copyright (C) 2005 by // // Victor Olaya // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_svg.h" #include //--------------------------------------------------------- #define SVG_CODE_OPENING_1 SG_T("\n")\ SG_T("\n")\ SG_T("\n") #define SVG_CODE_CLOSING SG_T("") //--------------------------------------------------------- const SG_Char *g_Unit = SG_T(""); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Doc_SVG::CSG_Doc_SVG(){} CSG_Doc_SVG::~CSG_Doc_SVG(){} void CSG_Doc_SVG::Open(int iWidth, int iHeight) { m_sSVGCode.Append(SVG_CODE_OPENING_1); m_sSVGCode.Append(SG_Get_String(iWidth,0)); m_sSVGCode.Append(SG_T("\" height=\"")); m_sSVGCode.Append(SG_Get_String(iHeight,0)); m_sSVGCode.Append(SVG_CODE_OPENING_2); m_iWidth = iWidth; m_iHeight = iHeight; } bool CSG_Doc_SVG::Save(const SG_Char *Filename) { m_sSVGCode.Append(SVG_CODE_CLOSING); CSG_File Stream(Filename, SG_FILE_W, false); if( Stream.is_Open() ) { Stream.Printf(SG_T("%s"), m_sSVGCode.c_str()); return true; } return false; } void CSG_Doc_SVG::_AddAttribute(const SG_Char *Attribute, const SG_Char *Value) { m_sSVGCode.Append(Attribute); m_sSVGCode.Append(SG_T("=\"")); m_sSVGCode.Append(Value); m_sSVGCode.Append(SG_T("\" ")); } void CSG_Doc_SVG::_AddAttribute(const SG_Char *Attribute, int iValue) { _AddAttribute(Attribute, SG_Get_String(iValue, 0)); } void CSG_Doc_SVG::_AddAttribute(const SG_Char *Attribute, double dValue) { _AddAttribute(Attribute, SG_Get_String(dValue, 2)); } void CSG_Doc_SVG::Draw_Circle(double x, double y, double Radius, int Fill_Color, int Line_Color, double Line_Width) { CSG_String sWidth; m_sSVGCode.Append(SG_T("\n")); } void CSG_Doc_SVG::Draw_LinkedCircle(double x, double y, double Radius, const SG_Char *Link, int Fill_Color, int Line_Color, double Line_Width) { CSG_String sWidth; CSG_String sLink; m_sSVGCode.Append(SG_T("\n")); } void CSG_Doc_SVG::Draw_Line(double xa, double ya, double xb, double yb, double Width, int Color) { CSG_String sWidth; m_sSVGCode.Append(SG_T("\n")); } void CSG_Doc_SVG::Draw_Line(CSG_Points &Points, double Width, int Color) { int i; CSG_String sPoints; CSG_String sWidth; for (i = 0; i < Points.Get_Count(); i++) { sPoints.Append(SG_Get_String(Points.Get_X(i),2)); sPoints.Append(SG_T(",")); sPoints.Append(SG_Get_String(Points.Get_Y(i),2)); sPoints.Append(SG_T(" ")); } m_sSVGCode.Append(SG_T("\n")); } void CSG_Doc_SVG::Draw_Rectangle(double xa, double ya, double xb, double yb, int Fill_Color, int Line_Color, double Line_Width) { CSG_Points Points; Points.Add(xa, ya); Points.Add(xb, ya); Points.Add(xb, yb); Points.Add(xa, yb); Draw_Polygon(Points, Fill_Color, Line_Color, Line_Width); } void CSG_Doc_SVG::Draw_Rectangle(const CSG_Rect &r, int Fill_Color, int Line_Color, double Line_Width) { Draw_Rectangle(r.Get_XMin(), r.Get_YMin(), r.Get_XMax(), r.Get_YMax(), Fill_Color, Line_Color, Line_Width) ; } void CSG_Doc_SVG::Draw_Polygon(CSG_Points &Points, int Fill_Color, int Line_Color, double Line_Width) { if( Points.Get_Count() > 2 ) { int i; CSG_String sPoints; CSG_String sWidth; for (i = 0; i < Points.Get_Count(); i++) { sPoints.Append(SG_Get_String(Points.Get_X(i),2)); sPoints.Append(SG_T(",")); sPoints.Append(SG_Get_String(Points.Get_Y(i),2)); sPoints.Append(SG_T(" ")); } m_sSVGCode.Append(SG_T("\n")); } } void CSG_Doc_SVG::Draw_LinkedPolygon(CSG_Points &Points, const SG_Char* Link, int Fill_Color, int Line_Color, double Line_Width) { if( Points.Get_Count() > 2 ) { int i; CSG_String sPoints; CSG_String sWidth; CSG_String sLink; for (i = 0; i < Points.Get_Count(); i++) { sPoints.Append(SG_Get_String(Points.Get_X(i),2)); sPoints.Append(SG_T(",")); sPoints.Append(SG_Get_String(Points.Get_Y(i),2)); sPoints.Append(SG_T(" ")); } m_sSVGCode.Append(SG_T("\n")); } } void CSG_Doc_SVG::Draw_Text(double x, double y, const SG_Char *Text, int Color, const SG_Char* Font, double dSize, TSG_SVG_Alignment iAlignment) { CSG_String sAlignments[] = {SG_T(""), SG_T("middle"), SG_T("end")}; CSG_String sSize; sSize.Append(SG_Get_String(dSize,2)); sSize.Append(g_Unit); m_sSVGCode.Append(SG_T("\n")); m_sSVGCode.Append(Text); m_sSVGCode.Append(SG_T("")); } CSG_String CSG_Doc_SVG::_Get_SVGColor(int iColor) { CSG_String s; if (iColor == SG_COLOR_NONE) { return SG_T("none"); } else if (iColor == SG_COLOR_RANDOM) { s.Append(SG_T("rgb(")); s.Append(SG_Get_String((int)(255.0 * (double)rand() / (double)RAND_MAX),0)); s.Append(SG_T(",")); s.Append(SG_Get_String((int)(255.0 * (double)rand() / (double)RAND_MAX),0)); s.Append(SG_T(",")); s.Append(SG_Get_String((int)(255.0 * (double)rand() / (double)RAND_MAX),0)); s.Append(SG_T(")")); return s; } else { s.Append(SG_T("rgb(")); s.Append(SG_Get_String(SG_GET_R(iColor),0)); s.Append(SG_T(",")); s.Append(SG_Get_String(SG_GET_G(iColor),0)); s.Append(SG_T(",")); s.Append(SG_Get_String(SG_GET_B(iColor),0)); s.Append(SG_T(")")); return s; } } saga-2.2.3/src/modules/docs/docs_html/Makefile.in0000664000175000017500000005476312622651160023017 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/docs/docs_html DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libdocs_html_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libdocs_html_la_OBJECTS = CreateWebContent.lo doc_html.lo \ doc_svg.lo MLB_Interface.lo svg_interactive_map.lo libdocs_html_la_OBJECTS = $(am_libdocs_html_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdocs_html_la_SOURCES) DIST_SOURCES = $(libdocs_html_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libdocs_html.la libdocs_html_la_SOURCES = \ CreateWebContent.cpp\ doc_html.cpp\ doc_svg.cpp\ MLB_Interface.cpp\ svg_interactive_map.cpp\ CreateWebContent.h\ doc_html.h\ doc_svg.h\ MLB_Interface.h\ svg_interactive_map.h libdocs_html_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) --foreign src/modules/docs/docs_html/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/docs/docs_html/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libdocs_html.la: $(libdocs_html_la_OBJECTS) $(libdocs_html_la_DEPENDENCIES) $(EXTRA_libdocs_html_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libdocs_html_la_OBJECTS) $(libdocs_html_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CreateWebContent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/doc_html.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/doc_svg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/svg_interactive_map.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/docs/docs_html/CreateWebContent.h0000664000175000017500000000355312565125412024310 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CreateWebContent.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Photolinks.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #ifndef HEADER_INCLUDED__CreateWebContent_H #define HEADER_INCLUDED__CreateWebContent_H #include "doc_html.h" #include class CCreateWebContent : public CSG_Module_Interactive { public: CCreateWebContent(void); virtual ~CCreateWebContent(void); protected: virtual bool On_Execute(void); virtual bool On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); virtual bool On_Execute_Finish(void); private: bool m_bDown; CSG_Point m_ptDown; CSG_Shapes *m_pShapes; int m_iField, m_iNameField; CSG_String m_sOutputPath; std::vector *m_Pictures; std::vector *m_Links; std::vector *m_LinksDescription; }; #endif // #ifndef HEADER_INCLUDED__CreateWebContent_H saga-2.2.3/src/modules/docs/docs_html/doc_svg.h0000664000175000017500000001402712565125412022536 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_svg.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // doc_svg.h // // // // Copyright (C) 2005 by // // Victor Olaya // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__docs_html__doc_svg_H #define HEADER_INCLUDED__docs_html__doc_svg_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- typedef enum ESG_SVG_Alignment { SVG_ALIGNMENT_Left = 0, SVG_ALIGNMENT_Center, SVG_ALIGNMENT_Right } TSG_SVG_Alignment; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class docs_html_EXPORT CSG_Doc_SVG { public: CSG_Doc_SVG(void); virtual ~CSG_Doc_SVG(void); void Open (int iWidth, int iHeight); bool Save (const SG_Char *FileName); void Draw_Line (double xa, double ya, double xb, double yb , double Width = 1., int Color = SG_COLOR_BLACK); void Draw_Line (CSG_Points &Points , double Width = 1., int Color = SG_COLOR_BLACK); void Draw_Rectangle (double xa, double ya, double xb, double yb , int Fill_Color = SG_COLOR_WHITE, int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_Rectangle (const CSG_Rect &r , int Fill_Color = SG_COLOR_WHITE, int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_Polygon (CSG_Points &Points , int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_LinkedPolygon (CSG_Points &Points, const SG_Char *Link , int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_Circle (double x, double y, double Radius , int Fill_Color = SG_COLOR_RED , int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_LinkedCircle (double x, double y, double Radius, const SG_Char *Link, int Fill_Color = SG_COLOR_RED , int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_Text (double x, double y, const SG_Char *Text, int iColor, const SG_Char* Font, double dSize, TSG_SVG_Alignment Alignment = SVG_ALIGNMENT_Center); protected: CSG_String m_sSVGCode; void _AddAttribute (const SG_Char *Attribute, const SG_Char *Value); void _AddAttribute (const SG_Char *Attribute, int Value); void _AddAttribute (const SG_Char *Attribute, double Value); CSG_String _Get_SVGColor (int iColor); private: int m_iWidth, m_iHeight; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif //#ifndef HEADER_INCLUDED__docs_html__doc_svg_H saga-2.2.3/src/modules/docs/docs_html/CreateWebContent.cpp0000664000175000017500000001244412565125412024642 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CreateWebContent.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* PhotoLinks.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "CreateWebContent.h" CCreateWebContent::CCreateWebContent(void) { CSG_Parameter *pNode; //----------------------------------------------------- Parameters.Set_Name(_TL("Create Web Content")); Parameters.Set_Description(_TL("")); pNode = Parameters.Add_Shapes(NULL, "SHAPES", _TL("Shapes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Table_Field(pNode, "NAME", _TL("Name Field"), _TL("")); Parameters.Add_FilePath(NULL, "OUTPUTPATH", _TL("Path for HTML Files"), _TL(""), _TL(""), _TL(""), true, true); } CCreateWebContent::~CCreateWebContent(void) {} bool CCreateWebContent::On_Execute(void) { m_bDown = false; m_pShapes = Parameters("SHAPES")->asShapes(); m_iNameField = Parameters("NAME")->asInt(); m_sOutputPath = Parameters("OUTPUTPATH")->asString(); m_pShapes->Add_Field("HTML", SG_DATATYPE_String); m_iField = m_pShapes->Get_Field_Count() - 1; m_Pictures = new std::vector [m_pShapes->Get_Count()]; m_Links = new std::vector [m_pShapes->Get_Count()]; m_LinksDescription = new std::vector [m_pShapes->Get_Count()]; return true ; } bool CCreateWebContent::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { int i; int iIndex, iShape; CSG_Rect r; switch( Mode ){ case MODULE_INTERACTIVE_LDOWN: if( m_bDown == false ){ m_bDown = true; m_ptDown = ptWorld; }//if return true ; case MODULE_INTERACTIVE_LUP: if( m_bDown == true ){ m_bDown = false; r.Assign(m_ptDown.Get_X(), m_ptDown.Get_Y(), ptWorld.Get_X(), ptWorld.Get_Y()); if( r.Get_XRange() == 0.0 && r.Get_YRange() == 0.0 ){ m_pShapes->Select(m_pShapes->Get_Shape(m_ptDown), is_Shift()); }//if else{ m_pShapes->Select(r, is_Shift()); }//else DataObject_Update(m_pShapes, true); }//if return true; case MODULE_INTERACTIVE_RDOWN: CSG_String sFileName; CSG_Strings files; CSG_Parameters dlg_files; dlg_files.Add_FilePath(NULL, "FILES", _TL("Files"), _TL(""), _TL("Images|*.bmp;*.jpg;*.png;*.tif|HTML Files|*.htm|All Files|*.*"), NULL, false, false, true); if( Dlg_Parameters(&dlg_files, _TL("Add Link to Files")) && dlg_files("FILES")->asFilePath()->Get_FilePaths(files) ) { for (iShape = 0; iShape < m_pShapes->Get_Selection_Count(); iShape++){ iIndex = m_pShapes->Get_Selection(iShape)->Get_Index(); for (i = 0; i < files.Get_Count(); i++) { sFileName = "file://"; sFileName.Append((CSG_String)files[i]); if (SG_File_Cmp_Extension (files[i],SG_T("htm"))){ m_LinksDescription[iIndex].push_back(SG_File_Get_Name(files[i], true)); m_Links[iIndex].push_back(sFileName); }//if else if ( SG_File_Cmp_Extension (files[i],SG_T("bmp")) || SG_File_Cmp_Extension (files[i],SG_T("jpg")) || SG_File_Cmp_Extension (files[i],SG_T("png")) || SG_File_Cmp_Extension (files[i],SG_T("tif"))){ m_Pictures[iIndex].push_back(sFileName); }//else } sFileName = SG_File_Make_Path(m_sOutputPath.c_str(), m_pShapes->Get_Shape(iIndex)->asString(m_iNameField), SG_T("htm")); m_pShapes->Get_Shape(iIndex)->Set_Value(m_iField, sFileName); } } break; }//switch return false ; }//method bool CCreateWebContent::On_Execute_Finish(void){ int i,j; CSG_String sFileName; CSG_Doc_HTML HTMLDoc; for (i = 0; i < m_pShapes->Get_Count(); i++){ Set_Progress(i, m_pShapes->Get_Count()); const SG_Char **Pictures; if (m_Pictures[i].size() || m_Links[i].size()){ HTMLDoc.Open(m_pShapes->Get_Shape(i)->asString(m_iNameField)); Pictures = new const SG_Char *[m_Pictures[i].size()]; for (j = 0; j < m_Pictures[i].size(); j++){ Pictures[j] = m_Pictures[i].at(j).c_str(); }//for*/ HTMLDoc.AddThumbnails(Pictures, (int)m_Pictures[i].size(), 4); HTMLDoc.AddLineBreak(); for (j = 0; j < m_Links[i].size(); j++){ HTMLDoc.AddHyperlink(m_LinksDescription[i].at(j).c_str(), m_Links[i].at(j).c_str()); HTMLDoc.AddLineBreak(); }//for sFileName = SG_File_Make_Path(m_sOutputPath.c_str(), m_pShapes->Get_Shape(i)->asString(m_iNameField), SG_T("htm")); HTMLDoc.Save(sFileName); }//if }//for return true; }//method saga-2.2.3/src/modules/docs/docs_html/svg_interactive_map.cpp0000664000175000017500000036371112565125412025505 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: svg_interactive_map.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // SVG_Interactive_map.cpp // // // // Copyright (C) 2005 by 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "svg_interactive_map.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define MAP_WINDOW_WIDTH 550. #define MAP_WINDOW_HEIGHT 700. /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSVG_Interactive_Map::CSVG_Interactive_Map(void) { Set_Name (_TL("SVG Interactive Map")); Set_Author (SG_T("V.Olaya")); Set_Description (_TW( "" )); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("[FLD] SVG File"), _TL(""), CSG_String::Format(SG_T("%s|*.svg|%s|*.*"), _TL("SVG - Scalable Vector Graphics Files (*.svg)"), _TL("All Files") ), NULL, true, false ); Parameters.Add_Shapes_List( NULL , "LIST" , _TL("Shapes Layers"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("[FLD] Index Layer"), _TL(""), PARAMETER_INPUT_OPTIONAL ); } //--------------------------------------------------------- CSVG_Interactive_Map::~CSVG_Interactive_Map(void) {} //--------------------------------------------------------- bool CSVG_Interactive_Map::On_Execute(void) { CSG_String FileName; CSG_Shapes *pIndexLayer; CSVG_Interactive_Map SVG; Process_Set_Text(CSG_String::Format(SG_T("%s..."), _TL("[MSG] Save as Interactive SVG"))); pIndexLayer = Parameters("SHAPES") ->asShapes(); FileName = Parameters("FILENAME") ->asString(); return( SVG.Create_From_Map(Parameters("LIST")->asShapesList(), pIndexLayer, FileName) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSVG_Interactive_Map::Create_From_Map(CSG_Parameter_Shapes_List *pList, CSG_Shapes *pIndexLayer, const SG_Char *Filename) { int i; if( pList->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- m_Directory = SG_File_Get_Path(Filename); CSG_Rect r(pList->asShapes(0)->Get_Extent()); for(i=1; iGet_Count(); i++) { r.Union(pList->asShapes(i)->Get_Extent()); } _Add_Opening(r); //----------------------------------------------------- m_sSVGCode.Append(SG_T("\n")); for(i=pList->Get_Count()-1; i>=0; i--) { _Add_Shapes (pList->asShapes(i)); } m_sSVGCode.Append(SG_T("\n\n")); //----------------------------------------------------- _Add_CheckBoxes(pList); _Add_ReferenceMap(pIndexLayer, r); m_sSVGCode.Append(_Get_Code_Closing_1()); if( !Save(Filename) ) { return( false ); } //----------------------------------------------------- _Write_Code(SG_File_Make_Path(m_Directory, SG_T("checkbox") , SG_T("js")), _Get_Code_CheckBox()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("mapApp") , SG_T("js")), _Get_Code_MapApp ()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("timer") , SG_T("js")), _Get_Code_Timer ()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("slider") , SG_T("js")), _Get_Code_Slider ()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("helper_functions") , SG_T("js")), _Get_Code_Helper ()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("button") , SG_T("js")), _Get_Code_Buttons ()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("navigation") , SG_T("js")), CSG_String::Format(SG_T("%s%s"), _Get_Code_Navigation_1(), _Get_Code_Navigation_2())); return( true ); } //--------------------------------------------------------- void CSVG_Interactive_Map::_Write_Code(const CSG_String &FileName, const CSG_String &Code) { CSG_File Stream; if( Stream.Open(FileName, SG_FILE_W, false) ) { Stream.Write(Code); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_Opening(CSG_Rect r) { CSG_String sViewBox; double Width, Height; double OffsetX, OffsetY; m_sSVGCode.Append(_Get_Opening_Code_1()); m_sSVGCode.Append(SG_Get_String(r.Get_XRange(),2)); m_sSVGCode.Append(SG_T("),")); m_sSVGCode.Append(SG_Get_String(r.Get_XRange() / 400.,2)); m_sSVGCode.Append(_Get_Opening_Code_2()); if (r.Get_XRange() / r.Get_YRange() > MAP_WINDOW_WIDTH / MAP_WINDOW_HEIGHT) { Width = r.Get_XRange(); Height = r.Get_XRange() * MAP_WINDOW_HEIGHT / MAP_WINDOW_WIDTH; } else { Height = r.Get_YRange(); Width = r.Get_YRange() / MAP_WINDOW_HEIGHT * MAP_WINDOW_WIDTH; } OffsetX = (Width - r.Get_XRange()) / 2.; OffsetY = (Height - r.Get_YRange()) / 2.; sViewBox.Append(SG_Get_String(r.Get_XMin() - OffsetX,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(-r.Get_YMax() - OffsetY,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(Width,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(Height,2)); _AddAttribute(SG_T("viewBox"), sViewBox); m_sSVGCode.Append(SG_T(">\n")); m_dWidth = Width; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_ReferenceMap(CSG_Shapes *pIndexLayer, CSG_Rect r) { int i; CSG_String sViewBox; double Line_Width, Point_Width; double Width, Height; double OffsetX, OffsetY; CSG_Shape *pShape; if (r.Get_XRange() / r.Get_YRange() > MAP_WINDOW_WIDTH / MAP_WINDOW_HEIGHT) { Width = r.Get_XRange(); Height = r.Get_XRange() * MAP_WINDOW_HEIGHT / MAP_WINDOW_WIDTH; } else { Height = r.Get_YRange(); Width = r.Get_YRange() / MAP_WINDOW_HEIGHT * MAP_WINDOW_WIDTH; } OffsetX = (Width - r.Get_XRange()) / 2.; OffsetY = (Height - r.Get_YRange()) / 2.; sViewBox.Append(SG_Get_String(r.Get_XMin() - OffsetX,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(- r.Get_YMax() - OffsetY,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(Width,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(Height,2)); _AddAttribute(SG_T("viewBox"), sViewBox); m_sSVGCode.Append(_Get_Code_3()); if (pIndexLayer) { m_sSVGCode.Append(SG_T("\n")); for (i = 0; i < pIndexLayer->Get_Count(); i++) { pShape = pIndexLayer->Get_Shape(i); Line_Width = Point_Width = m_dWidth / MAP_WINDOW_WIDTH; Point_Width *= 5; _Add_Shape(pShape, 0, 0, Line_Width, Point_Width); } m_sSVGCode.Append(SG_T("\n")); } m_sSVGCode.Append(_Get_Code_4()); _AddAttribute(SG_T("x"), r.Get_XMin() - OffsetX); _AddAttribute(SG_T("y"), - r.Get_YMax() - OffsetY); _AddAttribute(SG_T("width"), Width); _AddAttribute(SG_T("height"), Height); m_sSVGCode.Append(_Get_Code_5()); } //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_Grid(CSG_Grid *pLayer) { /* CSG_String Filename; wxBitmap BMP; if( pLayer->Get_Image_Grid(BMP) ) { Filename = SG_File_Make_Path(m_Directory.c_str(), pLayer->Get_Name(), SG_T("jpg")); BMP.SaveFile(Filename, wxBITMAP_TYPE_JPEG); m_sSVGCode.Append(SG_T("Get_Name()); _AddAttribute(SG_T("x") , ((CSG_Grid *)pLayer->Get_Object())->Get_XMin()); _AddAttribute(SG_T("y") ,-((CSG_Grid *)pLayer->Get_Object())->Get_YMax()); _AddAttribute(SG_T("width") , ((CSG_Grid *)pLayer->Get_Object())->Get_XRange()); _AddAttribute(SG_T("height") , ((CSG_Grid *)pLayer->Get_Object())->Get_YRange()); _AddAttribute(SG_T("xlink:href") , SG_File_Get_Name(Filename, true)); m_sSVGCode.Append(SG_T("/>")); } /**/ } //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_Shapes(CSG_Shapes *pLayer) { int i; int Line_Color, Fill_Color; double Line_Width, Point_Width; CSG_Shape *pShape; CSG_String sLabel; m_sSVGCode.Append(SG_T("Get_Name()); m_sSVGCode.Append(SG_T("\" >\n")); // int iColorField = pLayer->Get_Color_Field(); m_sSVGCode.Append(SG_T("\n")); for (i = 0; i < pLayer->Get_Count(); i++) { pShape = pLayer->Get_Shape(i); // Line_Color = Fill_Color = pLayer->Get_Classifier()->Get_Class_Color_byValue(pShape->asDouble(iColorField)); Line_Color = SG_COLOR_BLACK; Fill_Color = SG_COLOR_GREEN; Line_Width = Point_Width = m_dWidth / MAP_WINDOW_WIDTH; Point_Width *= 5; _Add_Shape(pShape, Fill_Color, Line_Color, Line_Width, Point_Width); } // if (pLayer->Get_Label_Field() >= 0) { /* m_sSVGCode.Append(SG_T("")); for (i = 0; i < pLayer->Get_Count(); i++) { double dSize; pShape = pLayer->Get_Shape(i); Line_Width = Point_Width = m_dWidth / MAP_WINDOW_WIDTH; sLabel = pShape->asString(pLayer->Get_Label_Field()); switch( pLayer->Get_Parameters()->Get_Parameter(SG_T("LABEL_ATTRIB_SIZE_TYPE"))->asInt() ) { case 0: default: dSize = Line_Width * pLayer->Get_Parameters()->Get_Parameter(SG_T("LABEL_ATTRIB_FONT"))->asFont()->GetPointSize(); _Add_Label(sLabel, pShape, dSize, SG_T("%")); break; case 1: dSize = pLayer->Get_Parameters()->Get_Parameter(SG_T("LABEL_ATTRIB_SIZE"))->asDouble(); _Add_Label(sLabel, pShape, dSize, SG_T("")); break; } } m_sSVGCode.Append(SG_T("\n")); /**/ } m_sSVGCode.Append(SG_T("\n\n")); } //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_Label(const SG_Char* Label, CSG_Shape *pShape, double dSize, const SG_Char* Unit) { int iPoint, iPart; TSG_Point Point; switch( pShape->Get_Type() ) { case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: for(iPoint=0; iPoint < pShape->Get_Point_Count(0); iPoint++) { Point = pShape->Get_Point(iPoint); Draw_Text(100 * Point.x, -100 * Point.y, Label, 0, SG_T("Verdana"), 100 * dSize); } break; case SHAPE_TYPE_Line: ///************/// break; case SHAPE_TYPE_Polygon: for (iPart = 0; iPart < pShape->Get_Part_Count(); iPart++) { if(! ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) ) { Point = ((CSG_Shape_Polygon *)pShape)->Get_Centroid(iPart); Draw_Text(100 * Point.x, -100 * Point.y, Label, 0, SG_T("Verdana"), 100 * dSize); } } break; } } //--------------------------------------------------------- bool CSVG_Interactive_Map::_Add_Shape(CSG_Shape *pShape, int Fill_Color, int Line_Color, double Line_Width, double Point_Width) { if( pShape && pShape->is_Valid() ) { int iPart, iPoint; TSG_Point Point; CSG_Points Points; for(iPart=0; iPartGet_Part_Count(); iPart++) { Points.Clear(); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Point = pShape->Get_Point(iPoint, iPart); Points.Add(Point.x, Point.y); } switch( pShape->Get_Type() ) { case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: for(iPoint=0; iPointis_Lake(iPart) ) { Draw_Polygon(Points, -1, 0, 0.01); } else { Draw_Polygon(Points, Fill_Color, 0, 0.01); } break; } } return( true ); } return( false ); } //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_CheckBoxes(CSG_Parameter_Shapes_List *pList) { int i; CSG_String s; int x,y; int iRow = 1; m_sSVGCode.Append(_Get_Code_1()); // 2* open m_sSVGCode.Append(_TL("Layers")); m_sSVGCode.Append(SG_T("\n")); for (i = 0; i < pList->Get_Count(); i++) { y = iRow * 30; if (i % 2) { x = 200; iRow++; } else { x = 0; } m_sSVGCode.Append(SG_T("\n")); m_sSVGCode.Append(SG_T("asShapes(i)->Get_Name()); _AddAttribute(SG_T("id"), s); _AddAttribute(SG_T("xlink:href"), SG_T("#checkBoxRect")); s = SG_T("checkBoxScript(evt,'"); s.Append(pList->asShapes(i)->Get_Name()); s.Append(SG_T("');")); _AddAttribute(SG_T("onclick"), s); m_sSVGCode.Append(SG_T("/>\n")); m_sSVGCode.Append(SG_T("asShapes(i)->Get_Name()); _AddAttribute(SG_T("id"), s); _AddAttribute(SG_T("xlink:href"), SG_T("#checkBoxCross")); _AddAttribute(SG_T("visibility"), SG_T("visible")); m_sSVGCode.Append(SG_T("/>\n")); m_sSVGCode.Append(SG_T("\n")); } m_sSVGCode.Append(SG_T("\n")); iRow = 1; for (i = 0; i < pList->Get_Count(); i++) { y = iRow * 30 + 6; if (i % 2) { x = 212; iRow++; } else { x = 12; } m_sSVGCode.Append(SG_T("")); m_sSVGCode.Append(pList->asShapes(i)->Get_Name()); m_sSVGCode.Append(SG_T("\n")); } m_sSVGCode.Append(SG_T("\n")); m_sSVGCode.Append(_Get_Code_2()); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Opening_Code_1(void) { return( "\n" "\n" "\n" "\n" "\n" "]>\n" "\n" "\n" " \n" "\n" " " ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_4(void) { return( " \n" " \n " " \n" " \n" ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_Closing_1(void) { return( " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_CheckBox(void) { return( "function checkBoxScript(evt,myLayer) { //checkBox for toggling layers an contextMenue\n" " var myLayerObj = document.getElementById(myLayer);\n" " var myCheckCrossObj = document.getElementById(\"checkCross\"+myLayer);\n" " var myCheckCrossVisibility = myCheckCrossObj.getAttributeNS(null,\"visibility\"));\n" " if (evt.type == \"click\" && evt.detail == 1) {\n" " if (myCheckCrossVisibility == \"visible\")) {\n" " myLayerObj.setAttributeNS(null,\"visibility\"),\"hidden\"));\n" " myCheckCrossObj.setAttributeNS(null,\"visibility\"),\"hidden\"));\n" " //you can do if/else or switch statements to set different actions on activating a checkbox here\n" " //myLayer holds the currentLayer name\n" " }\n" " else {\n" " myLayerObj.setAttributeNS(null,\"visibility\"),\"visible\"));\n" " myCheckCrossObj.setAttributeNS(null,\"visibility\"),\"visible\"));\n" " }\n" " }\n" "}\n" "\n" ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_MapApp(void) { return( "//holds data on window size\n" "function mapApp() {\n" " if (!document.documentElement.getScreenCTM) {\n" " this.resetFactors();\n" " //add resize event to document element\n" " document.documentElement.addEventListener(\"SVGResize\"),this,false);\n" " }\n" "}\n" "\n" "mapApp.prototype.handleEvent = function(evt) {\n" " if (evt.type == \"SVGResize\")) {\n" " this.resetFactors();\n" " }\n" "}\n" "\n" "mapApp.prototype.resetFactors = function() {\n" " if (!document.documentElement.getScreenCTM) {\n" " //case for viewers that don't support .getScreenCTM, such as ASV3\n" " //calculate ratio and offset values of app window\n" " var viewBoxArray = document.documentElement.getAttributeNS(null,\"viewBox\")).split(\" \"));\n" " var myRatio = viewBoxArray[2]/viewBoxArray[3];\n" " if ((window.innerWidth/window.innerHeight) > myRatio) { //case window is more wide than myRatio\n" " this.scaleFactor = viewBoxArray[3] / window.innerHeight;\n" " }\n" " else { //case window is more tall than myRatio\n" " this.scaleFactor = viewBoxArray[2] / window.innerWidth;\n" " }\n" " this.offsetX = (window.innerWidth - viewBoxArray[2] * 1 / this.scaleFactor) / 2;\n" " this.offsetY = (window.innerHeight - viewBoxArray[3] * 1 / this.scaleFactor) / 2;\n" " }\n" "}\n" "\n" "mapApp.prototype.calcCoord = function(evt,ctmNode) {\n" " var svgPoint = document.documentElement.createSVGPoint();\n" " svgPoint.x = evt.clientX;\n" " svgPoint.y = evt.clientY;\n" " if (!document.documentElement.getScreenCTM) {\n" " //case ASV3 a. Corel\n" " svgPoint.x = (svgPoint.x - this.offsetX) * this.scaleFactor;\n" " svgPoint.y = (svgPoint.y - this.offsetY) * this.scaleFactor;\n" " //undo the effect of transformations\n" " if (ctmNode) {\n" " var ctm = getTransformToRootElement(ctmNode).inverse();\n" " }\n" " else {\n" " var ctm = getTransformToRootElement(evt.target).inverse();\n" " }\n" " svgPoint = svgPoint.matrixTransform(ctm);\n" "\n" " }\n" " else {\n" " if (ctmNode) {\n" " var matrix = ctmNode.getScreenCTM();\n" " }\n" " else {\n" " var matrix = evt.target.getScreenCTM();\n" " }\n" " svgPoint = svgPoint.matrixTransform(matrix.inverse());\n" " }\n" " return svgPoint;\n" "}\n" "\n" ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_Timer(void) { return( "// source/credits: \"Algorithm\": http://www.codingforums.com/showthread.php?s=&threadid=10531\n" "// The constructor should be called with\n" "// the parent object (optional, defaults to window).\n" "\n" "function Timer(){\n" " this.obj = (arguments.length)?arguments[0]:window;\n" " return this;\n" "}\n" "\n" "// The set functions should be called with:\n" "// - The name of the object method (as a string) (required)\n" "// - The millisecond delay (required)\n" "// - Any number of extra arguments, which will all be\n" "// passed to the method when it is evaluated.\n" "\n" "Timer.prototype.setInterval = function(func, msec){\n" " var i = Timer.getNew();\n" " var t = Timer.buildCall(this.obj, i, arguments);\n" " Timer.set[i].timer = window.setInterval(t,msec);\n" " return i;\n" "}\n" "Timer.prototype.setTimeout = function(func, msec){\n" " var i = Timer.getNew();\n" " Timer.buildCall(this.obj, i, arguments);\n" " Timer.set[i].timer = window.setTimeout(\"Timer.callOnce(\"+i+\"));\"),msec);\n" " return i;\n" "}\n" "\n" "// The clear functions should be called with\n" "// the return value from the equivalent set function.\n" "\n" "Timer.prototype.clearInterval = function(i){\n" " if(!Timer.set[i]) return;\n" " window.clearInterval(Timer.set[i].timer);\n" " Timer.set[i] = null;\n" "}\n" "Timer.prototype.clearTimeout = function(i){\n" " if(!Timer.set[i]) return;\n" " window.clearTimeout(Timer.set[i].timer);\n" " Timer.set[i] = null;\n" "}\n" "\n" "// Private data\n" "\n" "Timer.set = new Array();\n" "Timer.buildCall = function(obj, i, args){\n" " var t = \"\");\n" " Timer.set[i] = new Array();\n" " if(obj != window){\n" " Timer.set[i].obj = obj;\n" " t = \"Timer.set[\"+i+\"].obj.\");\n" " }\n" " t += args[0]+\"(\");\n" " if(args.length > 2){\n" " Timer.set[i][0] = args[2];\n" " t += \"Timer.set[\"+i+\"][0]\");\n" " for(var j=1; (j+2) \n" "Version 1.1, 2004-11-18\n" "neumann@karto.baug.ethz.ch\n" "http://www.carto.net/\n" "http://www.carto.net/neumann/\n" "\n" "Credits: numerous people on svgdevelopers@yahoogroups.com\n" "\n" "This ECMA script library is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Lesser General Public\n" "License as published by the Free Software Foundation; either\n" "version 2.1 of the License, or (at your option) any later version.\n" "\n" "This library is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" "Lesser General Public License for more details.\n" "\n" "You should have received a copy of the GNU Lesser General Public\n" "License along with this library (http://www.carto.net/papers/svg/resources/lesser_gpl.txt); if not, write to the Free Software\n" "Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA\n" "\n" "----\n" "\n" "original document site: http://www.carto.net/papers/svg/resources/helper_functions.js\n" "Please contact the author in case you want to use code or ideas commercially.\n" "If you use this code, please include this copyright header, the included full\n" "LGPL 2.1 text and read the terms provided in the LGPL 2.1 license\n" "(http://www.gnu.org/copyleft/lesser.txt)\n" "\n" "-------------------------------\n" "\n" "Please report bugs and send improvements to neumann@karto.baug.ethz.ch\n" "If you use these scripts, please link to the original (http://www.carto.net/papers/svg/navigationTools/)\n" "somewhere in the source-code-comment or the \"about\" of your project and give credits, thanks!\n" "\n" "*/\n" "\n" "//global variables necessary to create elements in these namespaces, do not delete them!!!!\n" "var svgNS = \"http://www.w3.org/2000/svg\");\n" "var xlinkNS = \"http://www.w3.org/1999/xlink\");\n" "var cartoNS = \"http://www.carto.net/attrib\");\n" "var attribNS = \"http://www.carto.net/attrib\");\n" "var batikNS = \"http://xml.apache.org/batik/ext\");\n" "\n" "/* ----------------------- helper functions to calculate stuff ---------------- */\n" "/* ---------------------------------------------------------------------------- */\n" "function toPolarDir(xdiff,ydiff) { // Subroutine for calculating polar Coordinates\n" " direction = (Math.atan2(ydiff,xdiff));\n" " //result is angle in radian\n" " return(direction);\n" "}\n" "\n" "function toPolarDist(xdiff,ydiff) { // Subroutine for calculating polar Coordinates\n" " distance = Math.sqrt(xdiff * xdiff + ydiff * ydiff);\n" " return(distance);\n" "}\n" "\n" "function toRectX(direction,distance) { // Subroutine for calculating cartesic coordinates\n" " x = distance * Math.cos(direction);\n" " y = distance * Math.sin(direction);\n" " return(x);\n" "}\n" "\n" "function toRectY(direction,distance) { // Subroutine for calculating cartesic coordinates\n" " x = distance * Math.cos(direction);\n" " y = distance * Math.sin(direction);\n" " return(y);\n" "}\n" "\n" "//Converts degrees to radians.\n" "function DegToRad(deg) {\n" " return (deg / 180.0 * Math.PI);\n" "}\n" "\n" "//Converts radians to degrees.\n" "function RadToDeg(rad) {\n" " return (rad / Math.PI * 180.0);\n" "}\n" "\n" "//converts decimal degrees to degree/minutes/seconds\n" "function dd2dms(dd) {\n" " var minutes = (dd - Math.floor(dd)) * 60;\n" " var seconds = (minutes - Math.floor(minutes)) * 60;\n" " var minutes = Math.floor(minutes);\n" " var degrees = Math.floor(dd);\n" " return {deg:degrees,min:minutes,sec:seconds};\n" "}\n" "\n" "//converts degree/minutes/seconds to decimal degrees\n" "function dms2dd(deg,min,sec) {\n" " return deg + (min / 60) + (sec / 3600);\n" "}\n" "\n" "//log functions that do not exist in Math object\n" "function log(x,b) {\n" " if(b==null) b=Math.E;\n" " return Math.log(x)/Math.log(b);\n" "}\n" "\n" "//gets 4 z-values (4 corners), a position, delta x and delty and a cellsize as input and returns interpolated z-value\n" "function intBilinear(za,zb,zc,zd,xpos,ypos,ax,ay,cellsize) { //bilinear interpolation function\n" " e = (xpos - ax) / cellsize;\n" " f = (ypos - ay) / cellsize;\n" "\n" " //calculation of weights\n" " wa = (1 - e) * (1 - f);\n" " wb = e * (1 - f);\n" " wc = e * f;\n" " wd = f * (1 - e);\n" "\n" " height_interpol = wa * zc + wb * zd + wc * za + wd * zb;\n" "\n" " return (height_interpol); \n" "}\n" "\n" "//test if point is left of or right of, result is 1 (leftof) or 0 (rightof)\n" "function leftOfTest(pointx,pointy,linex1,liney1,linex2,liney2) {\n" " result = (liney1 - pointy) * (linex2 - linex1) - (linex1 - pointx) * (liney2 - liney1);\n" " if (result < 0) {\n" " leftof = 1; //case left of\n" " }\n" " else {\n" " leftof = 0; //case left of \n" " }\n" " return(leftof);\n" "}\n" "\n" "//input is point coordinate, and 2 line coordinates\n" "function distFromLine(xpoint,ypoint,linex1,liney1,linex2,liney2) {\n" " dx = linex2 - linex1;\n" " dy = liney2 - liney1;\n" " distance = (dy * (xpoint - linex1) - dx * (ypoint - liney1)) / Math.sqrt(Math.pow(dx,2) + Math.pow(dy,2));\n" " return(distance);\n" "}\n" "\n" "//converts radian value to degrees\n" "function radian2deg(radian) {\n" " deg = radian / Math.PI * 180;\n" " return(deg);\n" "}\n" "\n" "//input is two vectors (a1,a2 is vector a, b1,b2 is vector b), output is angle in radian\n" "//Formula: Acos from Scalaproduct of the two vectors divided by ( norm (deutsch Betrag) vector 1 by norm vector 2\n" "//see http://www.mathe-online.at/mathint/vect2/i.html#Winkel\n" "function angleBetwTwoLines(a1,a2,b1,b2) {\n" " angle = Math.acos((a1 * b1 + a2 * b2) / (Math.sqrt(Math.pow(a1,2) + Math.pow(a2,2)) * Math.sqrt(Math.pow(b1,2) + Math.pow(b2,2))));\n" " return(angle);\n" "}\n" "\n" "//input is two vectors (a1,a2 is vector a, b1,b2 is vector b), output is new vector c2 returned as array\n" "//Formula: Vektor a divided by Norm Vector a (Betrag) plus Vektor b divided by Norm Vector b (Betrag)\n" "//see http://www.mathe-online.at/mathint/vect1/i.html#Winkelsymmetrale\n" "function calcBisectorVector(a1,a2,b1,b2) {\n" " betraga = Math.sqrt(Math.pow(a1,2) + Math.pow(a2,2));\n" " betragb = Math.sqrt(Math.pow(b1,2) + Math.pow(b2,2));\n" " c = new Array();\n" " c[0] = a1 / betraga + b1 / betragb;\n" " c[1] = a2 / betraga + b2 / betragb;\n" " return(c);\n" "}\n" "\n" "//input is two vectors (a1,a2 is vector a, b1,b2 is vector b), output is angle in radian\n" "//Formula: Vektor a divided by Norm Vector a (Betrag) plus Vektor b divided by Norm Vector b (Betrag)\n" "//see http://www.mathe-online.at/mathint/vect1/i.html#Winkelsymmetrale\n" "function calcBisectorAngle(a1,a2,b1,b2) {\n" " betraga = Math.sqrt(Math.pow(a1,2) + Math.pow(a2,2));\n" " betragb = Math.sqrt(Math.pow(b1,2) + Math.pow(b2,2));\n" " c1 = a1 / betraga + b1 / betragb;\n" " c2 = a2 / betraga + b2 / betragb;\n" " angle = toPolarDir(c1,c2);\n" " return(angle);\n" "}\n" "\n" "function intersect2lines(line1x1,line1y1,line1x2,line1y2,line2x1,line2y1,line2x2,line2y2) {\n" " //formula see http://astronomy.swin.edu.au/~pbourke/geometry/lineline2d/\n" " var result = new Array();\n" " var denominator = (line2y2 - line2y1)*(line1x2 - line1x1) - (line2x2 - line2x1)*(line1y2 - line1y1);\n" " if (denominator == 0) {\n" " alert(\"lines are parallel\"));\n" " }\n" " else {\n" " ua = ((line2x2 - line2x1)*(line1y1 - line2y1) - (line2y2 - line2y1)*(line1x1 - line2x1)) / denominator;\n" " ub = ((line1x2 - line1x1)*(line1y1 - line2y1) - (line1y2 - line1y1)*(line1x1 - line2x1)) / denominator;\n" " }\n" " result[\"x\"] = line1x1 + ua * (line1x2 - line1x1);\n" " result[\"y\"] = line1y1 + ua * (line1y2 - line1y1);\n" " return(result);\n" "}\n" "\n" "/* ----------------------- helper function to sort arrays ---------------- */\n" "/* ----------------------------------------------------------------------- */\n" "//my own sort function, uses only first part of string (population value)\n" "function mySort(a,b) {\n" " var myResulta = a.split(\"+\"));\n" " var myResultb = b.split(\"+\"));\n" " if (parseFloat(myResulta[0]) < parseFloat(myResultb[0])) {\n" " return 1;\n" " }\n" " else {\n" " return -1;\n" " }\n" "}\n" "\n" "/* ----------------------- helper function format number strings -------------- */\n" "/* ---------------------------------------------------------------------------- */\n" "//formatting number strings\n" "//this function add's \"'\" to a number every third digit\n" "function formatNumberString(myString) {\n" " //check if of type string, if number, convert it to string\n" " if (typeof(myString) == \"number\")) {\n" " myTempString = myString.toString();\n" " }\n" " else {\n" " myTempString = myString;\n" " }\n" " var myNewString=\"\");\n" " //if it contains a comma, it will be split\n" " var splitResults = myTempString.split(\".\"));\n" " var myCounter= splitResults[0].length;\n" " if (myCounter > 3) {\n" " while(myCounter > 0) {\n" " if (myCounter > 3) {\n" " myNewString = \"),\" + splitResults[0].substr(myCounter - 3,3) + myNewString;\n" " }\n" " else {\n" " myNewString = splitResults[0].substr(0,myCounter) + myNewString;\n" " }\n" " myCounter -= 3;\n" " }\n" " }\n" " else {\n" " myNewString = splitResults[0];\n" " }\n" " //concatenate if it contains a comma\n" " if (splitResults[1]) {\n" " myNewString = myNewString + \".\" + splitResults[1];\n" " }\n" " return myNewString;\n" "}\n" "\n" "//function for status Bar\n" "function statusChange(statusText) {\n" " document.getElementById(\"statusText\")).firstChild.nodeValue = \"Statusbar: \" + statusText;\n" "}\n" "\n" "//scale an object\n" "function scaleObject(evt,factor) {\n" "//reference to the currently selected object\n" " var element = evt.currentTarget;\n" " var myX = element.getAttributeNS(null,\"x\"));\n" " var myY = element.getAttributeNS(null,\"y\"));\n" " var newtransform = \"scale(\" + factor + \")) translate(\" + (myX * 1 / factor - myX) + \" \" + (myY * 1 / factor - myY) +\"))\");\n" " element.setAttributeNS(null,'transform', newtransform);\n" "}\n" "\n" "//this code is copied from Kevin Lindsey\n" "//http://www.kevlindev.com/tutorials/basics/transformations/toUserSpace/index.htm\n" "function getTransformToRootElement(node) {\n" " try {\n" " //this part is for fully conformant players\n" " var CTM = node.getTransformToElement(document.documentElement);\n" " }\n" " catch (ex) {\n" " //this part is for ASV3 or other non-conformant players\n" " // Initialize our CTM the node's Current Transformation Matrix\n" " var CTM = node.getCTM();\n" " // Work our way through the ancestor nodes stopping at the SVG Document\n" " while ( ( node = node.parentNode ) != document ) {\n" " // Multiply the new CTM to the one with what we have accumulated so far\n" " CTM = node.getCTM().multiply(CTM);\n" " }\n" " }\n" " return CTM;\n" "}\n" "\n" "//calculate HSV 2 RGB: HSV (h 0 to 360, sat and val are between 0 and 1), RGB between 0 and 255\n" "function hsv2rgb(hue,sat,val) {\n" " //alert(\"Hue:\"+hue);\n" " var rgbArr = new Array();\n" " if ( sat == 0) {\n" " rgbArr[\"red\"] = Math.round(val * 255);\n" " rgbArr[\"green\"] = Math.round(val * 255);\n" " rgbArr[\"blue\"] = Math.round(val * 255);\n" " }\n" " else {\n" " var h = hue / 60;\n" " var i = Math.floor(h);\n" " var f = h - i;\n" " if (i % 2 == 0) {\n" " f = 1 - f;\n" " }\n" " var m = val * (1 - sat); \n" " var n = val * (1 - sat * f);\n" " switch(i) {\n" " case 0:\n" " rgbArr[\"red\"] = val;\n" " rgbArr[\"green\"] = n;\n" " rgbArr[\"blue\"] = m;\n" " break;\n" " case 1:\n" " rgbArr[\"red\"] = n;\n" " rgbArr[\"green\"] = val;\n" " rgbArr[\"blue\"] = m;\n" " break;\n" " case 2:\n" " rgbArr[\"red\"] = m;\n" " rgbArr[\"green\"] = val;\n" " rgbArr[\"blue\"] = n;\n" " break;\n" " case 3:\n" " rgbArr[\"red\"] = m;\n" " rgbArr[\"green\"] = n;\n" " rgbArr[\"blue\"] = val;\n" " break;\n" " case 4:\n" " rgbArr[\"red\"] = n;\n" " rgbArr[\"green\"] = m;\n" " rgbArr[\"blue\"] = val;\n" " break;\n" " case 5:\n" " rgbArr[\"red\"] = val;\n" " rgbArr[\"green\"] = m;\n" " rgbArr[\"blue\"] = n;\n" " break;\n" " case 6:\n" " rgbArr[\"red\"] = val;\n" " rgbArr[\"green\"] = n;\n" " rgbArr[\"blue\"] = m;\n" " break;\n" " }\n" " rgbArr[\"red\"] = Math.round(rgbArr[\"red\"] * 255);\n" " rgbArr[\"green\"] = Math.round(rgbArr[\"green\"] * 255);\n" " rgbArr[\"blue\"] = Math.round(rgbArr[\"blue\"] * 255);\n" " }\n" " return rgbArr;\n" "}\n" "\n" "//calculate rgb to hsv values\n" "function rgb2hsv (red,green,blue) {\n" " //input between 0 and 255 --> normalize to 0 to 1\n" " //result = \n" " var hsvArr = new Array();\n" " red = red / 255;\n" " green = green / 255;\n" " blue = blue / 255;\n" " myMax = Math.max(red, Math.max(green,blue));\n" " myMin = Math.min(red, Math.min(green,blue));\n" " v = myMax;\n" " if (myMax > 0) {\n" " s = (myMax - myMin) / myMax;\n" " }\n" " else {\n" " s = 0;\n" " }\n" " if (s > 0) {\n" " myDiff = myMax - myMin;\n" " rc = (myMax - red) / myDiff;\n" " gc = (myMax - green) / myDiff;\n" " bc = (myMax - blue) / myDiff;\n" " if (red == myMax) {\n" " h = (bc - gc) / 6;\n" " }\n" " if (green == myMax) {\n" " h = (2 + rc - bc) / 6;\n" " }\n" " if (blue == myMax) {\n" " h = (4 + gc - rc) / 6;\n" " }\n" " }\n" " else {\n" " h = 0;\n" " }\n" " if (h < 0) {\n" " h += 1;\n" " }\n" " hsvArr[\"hue\"] = Math.round(h * 360);\n" " hsvArr[\"sat\"] = s;\n" " hsvArr[\"val\"] = v;\n" " return hsvArr;\n" "}\n" "\n" "//populate an array that can be addressed by both a key or an index nr\n" "function assArrayPopulate(arrayKeys,arrayValues) {\n" " var returnArray = new Array();\n" " if (arrayKeys.length != arrayValues.length) {\n" " alert(\"error: arrays do not have same length!\"));\n" " }\n" " else {\n" " for (i=0;i 0) {\n" " this.init(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset);\n" " }\n" "}\n" "\n" "button.prototype.init = function(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset) {\n" " this.groupId = groupId; //the group id where all new content is appended to\n" " this.functionToCall = functionToCall; //function to be called if button was pressed\n" " this.buttonType = buttonType; //button type: currently either \"rect\" or \"ellipse\"\n" " this.buttonText = buttonText; //default value to be filled in when textbox is created\n" " this.buttonSymbolId = buttonSymbolId; //id to a symbol to be used as a button graphics\n" " this.x = x; //left of button rectangle\n" " this.y = y; //top of button rectangle\n" " this.width = width; //button rectangle width\n" " this.height = height; //button rectangle height\n" " this.fontSize = fontSize; //font size in user units/pixels\n" " this.fontFamily = fontFamily; //font family for text element, can be an empty string for image buttons\n" " this.textFill = textFill; //the fill color of the text for text buttons, can be an empty string for image buttons\n" " this.buttonFill = buttonFill; //the fill color of the button rectangle or ellipse\n" " this.shadeLightFill = shadeLightFill; //light fill color simulating 3d effect\n" " this.shadeDarkFill = shadeDarkFill; //dark fill color simulating 3d effect\n" " this.shadowOffset = shadowOffset; //shadow offset in viewBox units\n" " this.buttonGroup = document.getElementById(this.groupId); //reference to the button group node\n" " this.upperLeftLine = null; //later a reference to the upper left line simulating 3d effect\n" " this.buttonRect = null; //later a reference to the button area (rect)\n" " this.buttonTextElement = null; //later a reference to the button text\n" " this.buttonSymbolInstance = null; //later a reference to the button symbol\n" " this.deActivateRect = null; //later a reference to a rectangle that can be used to deactivate the button\n" " this.activated = true; //a property indicating if button is activated or not\n" " this.lowerRightLine = null; //later a reference to the lower right line simulating 3d effect\n" " this.createButton(); //method to initialize button\n" " this.timer = new Timer(this); //a Timer instance for calling the functionToCall\n" " this.timerMs = 200; //a constant of this object that is used in conjunction with the timer - functionToCall is called after 200 ms\n" "}\n" "\n" "//create button\n" "button.prototype.createButton = function() {\n" " //create upper left button line or ellipse\n" " if (this.buttonType == \"rect\")) {\n" " this.upperLeftShadow = document.createElementNS(svgNS,\"rect\"));\n" " this.upperLeftShadow.setAttributeNS(null,\"x\"),this.x - this.shadowOffset);\n" " this.upperLeftShadow.setAttributeNS(null,\"y\"),this.y - this.shadowOffset);\n" " this.upperLeftShadow.setAttributeNS(null,\"width\"),this.width);\n" " this.upperLeftShadow.setAttributeNS(null,\"height\"),this.height);\n" " this.upperLeftShadow.setAttributeNS(null,\"points\"),this.x+\"),\"+(this.y+this.height)+\" \"+this.x+\"),\"+this.y+\" \"+(this.x+this.width)+\"),\"+this.y);\n" " }\n" " else if (this.buttonType == \"ellipse\")) {\n" " this.upperLeftShadow = document.createElementNS(svgNS,\"ellipse\"));\n" " this.upperLeftShadow.setAttributeNS(null,\"cx\"),this.x + this.width * 0.5 - this.shadowOffset);\n" " this.upperLeftShadow.setAttributeNS(null,\"cy\"),this.y + this.height * 0.5 - this.shadowOffset);\n" " this.upperLeftShadow.setAttributeNS(null,\"rx\"),this.width * 0.5);\n" " this.upperLeftShadow.setAttributeNS(null,\"ry\"),this.height * 0.5);\n" " }\n" " else {\n" " alert(\"buttonType '\"+this.buttonType+\"' not supported. You need to specify 'rect' or 'ellipse'\"));\n" " }\n" " this.upperLeftShadow.setAttributeNS(null,\"fill\"),this.shadeLightFill);\n" " this.buttonGroup.appendChild(this.upperLeftShadow);\n" "\n" " //create lower right button line or ellipse\n" " if (this.buttonType == \"rect\")) {\n" " this.lowerRightShadow = document.createElementNS(svgNS,\"rect\"));\n" " this.lowerRightShadow.setAttributeNS(null,\"x\"),this.x + this.shadowOffset);\n" " this.lowerRightShadow.setAttributeNS(null,\"y\"),this.y + this.shadowOffset);\n" " this.lowerRightShadow.setAttributeNS(null,\"width\"),this.width);\n" " this.lowerRightShadow.setAttributeNS(null,\"height\"),this.height);\n" " this.lowerRightShadow.setAttributeNS(null,\"points\"),this.x+\"),\"+(this.y+this.height)+\" \"+this.x+\"),\"+this.y+\" \"+(this.x+this.width)+\"),\"+this.y);\n" " }\n" " else if (this.buttonType == \"ellipse\")) {\n" " this.lowerRightShadow = document.createElementNS(svgNS,\"ellipse\"));\n" " this.lowerRightShadow.setAttributeNS(null,\"cx\"),this.x + this.width * 0.5 + this.shadowOffset);\n" " this.lowerRightShadow.setAttributeNS(null,\"cy\"),this.y + this.height * 0.5 + this.shadowOffset);\n" " this.lowerRightShadow.setAttributeNS(null,\"rx\"),this.width * 0.5);\n" " this.lowerRightShadow.setAttributeNS(null,\"ry\"),this.height * 0.5);\n" " }\n" " this.lowerRightShadow.setAttributeNS(null,\"fill\"),this.shadeDarkFill);\n" " this.buttonGroup.appendChild(this.lowerRightShadow);\n" "\n" " //create buttonRect\n" " if (this.buttonType == \"rect\")) {\n" " this.buttonRect = document.createElementNS(svgNS,\"rect\"));\n" " this.buttonRect.setAttributeNS(null,\"x\"),this.x);\n" " this.buttonRect.setAttributeNS(null,\"y\"),this.y);\n" " this.buttonRect.setAttributeNS(null,\"width\"),this.width);\n" " this.buttonRect.setAttributeNS(null,\"height\"),this.height);\n" " }\n" " else if (this.buttonType == \"ellipse\")) {\n" " this.buttonRect = document.createElementNS(svgNS,\"ellipse\"));\n" " this.buttonRect.setAttributeNS(null,\"cx\"),this.x + this.width * 0.5);\n" " this.buttonRect.setAttributeNS(null,\"cy\"),this.y + this.height * 0.5);\n" " this.buttonRect.setAttributeNS(null,\"rx\"),this.width * 0.5);\n" " this.buttonRect.setAttributeNS(null,\"ry\"),this.height * 0.5);\n" " }\n" " this.buttonRect.setAttributeNS(null,\"fill\"),this.buttonFill);\n" " this.buttonRect.setAttributeNS(null,\"cursor\"),\"pointer\"));\n" " this.buttonRect.addEventListener(\"mousedown\"),this,false);\n" " this.buttonRect.addEventListener(\"mouseup\"),this,false);\n" " this.buttonRect.addEventListener(\"click\"),this,false);\n" " this.buttonGroup.appendChild(this.buttonRect);\n" " \n" " if (this.buttonText != undefined) {\n" " //create text element and add clipping path attribute\n" " this.buttonTextElement = document.createElementNS(svgNS,\"text\"));\n" " this.buttonTextElement.setAttributeNS(null,\"x\"),(this.x + this.width / 2));\n" " this.buttonTextElement.setAttributeNS(null,\"y\"),(this.y + this.height - ((this.height - this.fontSize) / 1.75)));\n" " this.buttonTextElement.setAttributeNS(null,\"fill\"),this.textFill);\n" " this.buttonTextElement.setAttributeNS(null,\"font-family\"),this.fontFamily);\n" " this.buttonTextElement.setAttributeNS(null,\"font-size\"),this.fontSize+\"px\"));\n" " this.buttonTextElement.setAttributeNS(null,\"pointer-events\"),\"none\"));\n" " this.buttonTextElement.setAttributeNS(null,\"text-anchor\"),\"middle\"));\n" " this.buttonTextElement.setAttributeNS(\"http://www.w3.org/XML/1998/namespace\"),\"space\"),\"preserve\"));\n" " var textboxTextContent = document.createTextNode(this.buttonText);\n" " this.buttonTextElement.appendChild(textboxTextContent);\n" " this.buttonGroup.appendChild(this.buttonTextElement);\n" " }\n" " \n" " if (this.buttonSymbolId != undefined) {\n" " this.buttonSymbolInstance = document.createElementNS(svgNS,\"use\"));\n" " this.buttonSymbolInstance.setAttributeNS(null,\"x\"),(this.x + this.width / 2));\n" " this.buttonSymbolInstance.setAttributeNS(null,\"y\"),(this.y + this.height / 2));\n" " this.buttonSymbolInstance.setAttributeNS(xlinkNS,\"href\"),\"#\"+this.buttonSymbolId);\n" " this.buttonSymbolInstance.setAttributeNS(null,\"pointer-events\"),\"none\"));\n" " this.buttonGroup.appendChild(this.buttonSymbolInstance);\n" " }\n" " \n" " //create rectangle to deactivate the button\n" " if (this.buttonType == \"rect\")) {\n" " this.deActivateRect = document.createElementNS(svgNS,\"rect\"));\n" " this.deActivateRect.setAttributeNS(null,\"x\"),this.x - this.shadowOffset);\n" " this.deActivateRect.setAttributeNS(null,\"y\"),this.y - this.shadowOffset);\n" " this.deActivateRect.setAttributeNS(null,\"width\"),this.width + this.shadowOffset * 2);\n" " this.deActivateRect.setAttributeNS(null,\"height\"),this.height + this.shadowOffset * 2);\n" " }\n" " else if (this.buttonType == \"ellipse\")) {\n" " this.deActivateRect = document.createElementNS(svgNS,\"ellipse\"));\n" " this.deActivateRect.setAttributeNS(null,\"cx\"),this.x + this.width * 0.5);\n" " this.deActivateRect.setAttributeNS(null,\"cy\"),this.y + this.height * 0.5);\n" " this.deActivateRect.setAttributeNS(null,\"rx\"),this.width * 0.5 + this.shadowOffset);\n" " this.deActivateRect.setAttributeNS(null,\"ry\"),this.height * 0.5 + this.shadowOffset);\n" " }\n" " \n" " this.deActivateRect.setAttributeNS(null,\"fill\"),\"white\"));\n" " this.deActivateRect.setAttributeNS(null,\"fill-opacity\"),\"0.5\"));\n" " this.deActivateRect.setAttributeNS(null,\"stroke\"),\"none\"));\n" " this.deActivateRect.setAttributeNS(null,\"display\"),\"none\"));\n" " this.deActivateRect.setAttributeNS(null,\"cursor\"),\"default\"));\n" " this.buttonGroup.appendChild(this.deActivateRect);\n" "}\n" "\n" "//remove all textbox elements\n" "button.prototype.removeButton = function() {\n" " this.buttonGroup.removeChild(this.upperLeftShadow);\n" " this.buttonGroup.removeChild(this.lowerRightShadow);\n" " this.buttonGroup.removeChild(this.buttonRect);\n" " if (this.buttonTextElement) {\n" " this.buttonGroup.removeChild(this.buttonTextElement); \n" " }\n" " if (this.buttonSymbolInstance) {\n" " this.buttonGroup.removeChild(this.buttonSymbolInstance); \n" " }\n" " this.buttonGroup.removeChild(this.deActivateRect);\n" "}\n" "\n" "//click on and write in textbox\n" "button.prototype.handleEvent = function(evt) {\n" " if (evt.type == \"mousedown\")) {\n" " this.togglePressed(\"pressed\"));\n" " document.documentElement.addEventListener(\"mouseup\"),this,false); \n" " }\n" " if (evt.type == \"mouseup\")) {\n" " this.togglePressed(\"released\"));\n" " document.documentElement.removeEventListener(\"mouseup\"),this,false); \n" " }\n" " if (evt.type == \"click\")) {\n" " //for some strange reasons I could not forward the evt object here ;-(, the code below using a literal is a workaround\n" " //attention: only some of the evt properties are forwarded here, you can add more, if you need them\n" " var timerEvt = {x:evt.clientX,y:evt.clientY,type:evt.type,detail:evt.detail,timeStamp:evt.timeStamp}\n" " this.timer.setTimeout(\"fireFunction\"),this.timerMs,timerEvt)\n" " }\n" "}\n" "\n" "button.prototype.togglePressed = function(type) {\n" " if (type == \"pressed\")) {\n" " this.upperLeftShadow.setAttributeNS(null,\"fill\"),this.shadeDarkFill); \n" " this.lowerRightShadow.setAttributeNS(null,\"fill\"),this.shadeLightFill);\n" " }\n" " if (type == \"released\")) {\n" " this.upperLeftShadow.setAttributeNS(null,\"fill\"),this.shadeLightFill); \n" " this.lowerRightShadow.setAttributeNS(null,\"fill\"),this.shadeDarkFill); \n" " }\n" "}\n" "\n" "button.prototype.fireFunction = function(evt) {\n" " if (typeof(this.functionToCall) == \"function\")) {\n" " if (this.buttonTextElement) {\n" " this.functionToCall(this.groupId,evt,this.buttonText);\n" " }\n" " if (this.buttonSymbolInstance) {\n" " this.functionToCall(this.groupId,evt);\n" " }\n" " }\n" " if (typeof(this.functionToCall) == \"object\")) {\n" " if (this.buttonTextElement) {\n" " this.functionToCall.buttonPressed(this.groupId,evt,this.buttonText);\n" " }\n" " if (this.buttonSymbolInstance) {\n" " this.functionToCall.buttonPressed(this.groupId,evt);\n" " }\n" " }\n" " if (typeof(this.functionToCall) == undefined) {\n" " return; \n" " }\n" "}\n" "\n" "button.prototype.getTextValue = function() {\n" " return this.buttonText;\n" "} \n" "\n" "button.prototype.setTextValue = function(value) {\n" " this.buttonText = value;\n" " this.buttonTextElement.firstChild.nodeValue=this.buttonText;\n" "}\n" "\n" "button.prototype.activate = function(value) {\n" " this.deActivateRect.setAttributeNS(null,\"display\"),\"none\"));\n" " this.activated = true;\n" "}\n" "\n" "button.prototype.deactivate = function(value) {\n" " this.deActivateRect.setAttributeNS(null,\"display\"),\"inherit\"));\n" " this.activated = false;\n" "}\n" "\n" "//switchbutton\n" "//initialize inheritance\n" "switchbutton.prototype = new button();\n" "switchbutton.prototype.constructor = switchbutton;\n" "switchbutton.superclass = button.prototype;\n" "\n" "function switchbutton(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset) {\n" " if (arguments.length > 0) {\n" " this.init(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset);\n" " }\n" "}\n" "\n" "switchbutton.prototype.init = function(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset) {\n" " switchbutton.superclass.init.call(this,groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset);\n" " this.on = false;\n" "}\n" "\n" "//overwriting handleEventcode\n" "switchbutton.prototype.handleEvent = function(evt) {\n" " //for some strange reasons I could not forward the evt object here ;-(, the code below using a literal is a workaround\n" " //attention: only some of the evt properties are forwarded here, you can add more, if you need them\n" " var timerEvt = {x:evt.clientX,y:evt.clientY,type:evt.type,detail:evt.detail,timeStamp:evt.timeStamp}\n" " if (evt.type == \"click\")) {\n" " if (this.on) {\n" " this.on = false;\n" " this.togglePressed(\"released\"));\n" " this.timer.setTimeout(\"fireFunction\"),this.timerMs,timerEvt);\n" " }\n" " else {\n" " this.on = true;\n" " this.togglePressed(\"pressed\")); \n" " this.timer.setTimeout(\"fireFunction\"),this.timerMs,timerEvt);\n" " }\n" " }\n" "}\n" "\n" "switchbutton.prototype.getSwitchValue = function() {\n" " return this.on;\n" "}\n" "\n" "switchbutton.prototype.setSwitchValue = function(onOrOff,firefunction) {\n" " this.on = onOrOff;\n" " //artificial timer event - don't use the values!\n" " var timerEvt = {x:0,y:0,type:\"click\"),detail:1,timeStamp:0}\n" " if (this.on) {\n" " this.togglePressed(\"pressed\"));\n" " if (firefunction) {\n" " this.timer.setTimeout(\"fireFunction\"),this.timerMs,timerEvt);\n" " }\n" " }\n" " else {\n" " this.togglePressed(\"released\")); \n" " if (firefunction) {\n" " this.timer.setTimeout(\"fireFunction\"),this.timerMs,timerEvt)\n" " }\n" " }\n" "}\n" "\n" "//overwriting fireFunction code\n" "switchbutton.prototype.fireFunction = function(evt) {\n" " if (typeof(this.functionToCall) == \"function\")) {\n" " if (this.buttonTextElement) {\n" " this.functionToCall(this.groupId,evt,this.on,this.buttonText);\n" " }\n" " if (this.buttonSymbolInstance) {\n" " this.functionToCall(this.groupId,evt,this.on);\n" " }\n" " }\n" " if (typeof(this.functionToCall) == \"object\")) {\n" " if (this.buttonTextElement) {\n" " this.functionToCall.buttonPressed(this.groupId,evt,this.on,this.buttonText);\n" " }\n" " if (this.buttonSymbolInstance) {\n" " this.functionToCall.buttonPressed(this.groupId,evt,this.on);\n" " }\n" " }\n" " if (typeof(this.functionToCall) == undefined) {\n" " return; \n" " }\n" "}\n" "\n" ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_Navigation_1(void) { return( "/*\n" "Scripts for SVG only webmapping application navigation tools\n" "Copyright (C) <2005> \n" "Version 1.1, 2005-10-05\n" "neumann@karto.baug.ethz.ch\n" "http://www.carto.net/\n" "http://www.carto.net/neumann/\n" "\n" "Credits: numerous people on svgdevelopers@yahoogroups.com\n" "\n" "This ECMA script library is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Lesser General Public\n" "License as published by the Free Software Foundation; either\n" "version 2.1 of the License, or (at your option) any later version.\n" "\n" "This library is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" "Lesser General Public License for more details.\n" "\n" "You should have received a copy of the GNU Lesser General Public\n" "License along with this library (http://www.carto.net/papers/svg/navigationTools/lesser_gpl.txt); if not, write to the Free Software\n" "Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA\n" "\n" "----\n" "\n" "current version: 1.1\n" "\n" "version history:\n" "1.0 initial version\n" "1.01 (2005-02-15) added cleanUp() method to map and dragObj objects, some fixes in the documentation\n" "1.02 (2005-02-20) fixed problems with double clicks, the second click of a double click is now ignored, using the evt.detail property\n" "1.03 (2005-02-22) introduced timestamp and nrLayerToLoad array for dynamic loading (getUrl)\n" "1.04 (2005-09-15) introduced a few changes with coordinate calculation to support MozillaSVG, introduced epsg and unitsFactor property based on a suggestion by Bruce Rindahl\n" "1.1 (2005-10-05) introduced button object (see button.js file), introduced zoom and pan \"modes\" for repeated actions in the same mode, introduced history of map extents with the ability to go back and forth in the list of previous map extents, some internal changes in the code (e.g. less global variables), added experimental support for the batik SVG 1.2 \"static\" attribute to improve performance while panning the map, added cursors to give better status feedback\n" "\n" "original document site: http://www.carto.net/papers/svg/navigationTools/\n" "Please contact the author in case you want to use code or ideas commercially.\n" "If you use this code, please include this copyright header, the included full\n" "LGPL 2.1 text and read the terms provided in the LGPL 2.1 license\n" "(http://www.gnu.org/copyleft/lesser.txt)\n" "\n" "-------------------------------\n" "\n" "Please report bugs and send improvements to neumann@karto.baug.ethz.ch\n" "If you use these scripts, please link to the original (http://www.carto.net/papers/svg/navigationTools/)\n" "somewhere in the source-code-comment or the \"about\" of your project and give credits, thanks!\n" "\n" "*/\n" "\n" "//constructor: holds data on map and initializes various references\n" "function map(mapName,maxWidth,minWidth,zoomFact,nrDecimals,epsg,units,unitsFactor,showCoords,coordXId,coordYId,dynamicLayers,digiLayers,activeDigiLayer) {\n" " this.mapName = mapName; //id of svg element containing the map geometry\n" " this.mapSVG = document.getElementById(this.mapName); //reference to nested SVG element holding the map-graphics\n" " this.mainMapGroup = document.getElementById(this.mapName+\"Group\")); //group within mainmap - to be transformed when panning manually\n" " this.dynamicLayers = dynamicLayers; //an associative array holding ids of values that are loaded from the web server dynamically (.getUrl())\n" " this.nrLayerToLoad = 0; //statusVariable to indicate how many layers are still to load\n" " this.maxWidth = maxWidth; //max map width\n" " this.minWidth = minWidth; //min map width, after zooming in\n" " this.zoomFact = zoomFact; //ratio to zoom in or out in relation to previous viewBox\n" " this.digiLayers = digiLayers; //references to digiLayers (for digitizing tools)\n" " this.activeDigiLayer = activeDigiLayer; //active Digi Layer, key is final group id where geometry should be copied to after digitizing\n" " this.pixXOffset = parseFloat(this.mapSVG.getAttributeNS(null,\"x\"))); //offset from left margin of outer viewBox\n" " this.pixYOffset = parseFloat(this.mapSVG.getAttributeNS(null,\"y\"))); //offset from top margin of outer viewBox\n" " var viewBoxArray = this.mapSVG.getAttributeNS(null,\"viewBox\")).split(\" \"));\n" " this.curxOrig = parseFloat(viewBoxArray[0]); //holds the current xOrig\n" " this.curyOrig = parseFloat(viewBoxArray[1]); //holds the current yOrig\n" " this.curWidth = parseFloat(viewBoxArray[2]); //holds the current map width\n" " this.curHeight = parseFloat(viewBoxArray[3]); //holds the current map height\n" " this.pixWidth = parseFloat(this.mapSVG.getAttributeNS(null,\"width\"))); //holds width of the map in pixel coordinates\n" " this.pixHeight = parseFloat(this.mapSVG.getAttributeNS(null,\"height\"))); //holds height of the map in pixel coordinates\n" " this.pixSize = this.curWidth / this.pixWidth; //size of a screen pixel in map units\n" " this.zoomVal = this.maxWidth / this.curWidth * 100; //zoomVal in relation to initial zoom\n" " this.nrDecimals = nrDecimals; //nr of decimal places to be displayed for show coordinates or accuracy when working with digitizing\n" " this.epsg = epsg; //epsg projection code - can be used for building URL strings for loading data from a WMS or spatial database, if you don't need it just input any number\n" " this.navStatus = \"info\"); //to indicate status in navigation, default is \"info\"), no navigation mode active\n" " this.units = units; //holds a string with map units, e.g. \"m\"), alternatively String.fromCharCode(176) for degrees\n" " this.unitsFactor = unitsFactor; //a factor for unit conversion. Can be used f.e. to output feet coordinates when data is meter, If you don't need a conversion, just use a factor of 1\n" " this.showCoords = showCoords;\n" " //initialize array of timestamp/layertoLoad values\n" " this.nrLayerToLoad = new Array();\n" " this.timestamp = null; //holds the timestamp after a zoom or pan occured\n" " //initialize coordinate display if showCoords == true\n" " if (this.showCoords == true) {\n" " //add event listener for coordinate display\n" " this.mapSVG.addEventListener(\"mousemove\"),this,false);\n" " if (typeof(coordXId) == \"string\")) {\n" " this.coordXText = document.getElementById(coordXId).firstChild;\n" " }\n" " else {\n" " alert(\"Error: coordXId needs to be an id of type string\"));\n" " }\n" " if (typeof(coordYId) == \"string\")) {\n" " this.coordYText = document.getElementById(coordYId).firstChild;\n" " }\n" " else {\n" " alert(\"Error: coordYId needs to be an id of type string\"));\n" " }\n" " }\n" " //a new array containing map extents\n" " this.mapExtents = new Array();\n" " this.mapExtents.push({xmin:this.curxOrig,ymin:((this.curyOrig + this.curHeight) * -1),xmax:(this.curxOrig + this.curWidth),ymax:(this.curyOrig * -1)});\n" " this.curMapExtentIndex = 0;\n" " //create background-element to receive events for showing coordinates\n" " //this rect is also used for manual zooming and panning\n" " this.backgroundRect = document.createElementNS(svgNS,\"rect\"));\n" " this.backgroundRect.setAttributeNS(null,\"x\"),this.curxOrig);\n" " this.backgroundRect.setAttributeNS(null,\"y\"),this.curyOrig);\n" " this.backgroundRect.setAttributeNS(null,\"width\"),this.curWidth);\n" " this.backgroundRect.setAttributeNS(null,\"height\"),this.curHeight);\n" " this.backgroundRect.setAttributeNS(null,\"fill\"),\"none\"));\n" " this.backgroundRect.setAttributeNS(null,\"stroke\"),\"none\"));\n" " this.backgroundRect.setAttributeNS(null,\"pointer-events\"),\"fill\"));\n" " this.backgroundRect.setAttributeNS(null,\"id\"),\"mapBackgroundRect\"));\n" " this.backgroundRect.addEventListener(\"mousedown\"),this,false);\n" " this.backgroundRect.addEventListener(\"mousemove\"),this,false);\n" " this.backgroundRect.addEventListener(\"mouseup\"),this,false);\n" " this.backgroundRect.addEventListener(\"mouseout\"),this,false);\n" " this.backgroundRect.addEventListener(\"click\"),this,false);\n" " this.mainMapGroup.insertBefore(this.backgroundRect,this.mainMapGroup.firstChild);\n" " //determine if viewer is capable of getScreenCTM\n" " if (document.documentElement.getScreenCTM) {\n" " this.getScreenCTM = true;\n" " }\n" " else {\n" " this.getScreenCTM = false; \n" " }\n" "}\n" "\n" "//resets viewBox of main map after zooming and panning\n" "map.prototype.newViewBox = function(refRectId,history) {\n" " var myRefRect = document.getElementById(refRectId);\n" " this.curxOrig = parseFloat(myRefRect.getAttributeNS(null,\"x\")));\n" " this.curyOrig = parseFloat(myRefRect.getAttributeNS(null,\"y\")));\n" " this.curWidth = parseFloat(myRefRect.getAttributeNS(null,\"width\")));\n" " this.curHeight = parseFloat(myRefRect.getAttributeNS(null,\"height\")));\n" " var myViewBoxString = this.curxOrig + \" \" + this.curyOrig + \" \" + this.curWidth + \" \" + this.curHeight;\n" " this.pixSize = this.curWidth / this.pixWidth;\n" " this.zoomVal = this.maxWidth / this.curWidth * 100;\n" " this.mapSVG.setAttributeNS(null,\"viewBox\"),myViewBoxString);\n" " myMapApp.zoomSlider.setValue(this.curWidth);\n" " loadProjectSpecific();\n" " if (history) {\n" " this.mapExtents.push({xmin:this.curxOrig,ymin:((this.curyOrig + this.curHeight) * -1),xmax:(this.curxOrig + this.curWidth),ymax:(this.curyOrig * -1)});\n" " this.curMapExtentIndex = (this.mapExtents.length - 1);\n" " }\n" " this.checkButtons();\n" "}\n" "\n" "map.prototype.backwardExtent = function() {\n" " if (this.curMapExtentIndex != 0) {\n" " this.curMapExtentIndex--;\n" " this.setNewViewBox(this.mapExtents[this.curMapExtentIndex].xmin,this.mapExtents[this.curMapExtentIndex].ymin,this.mapExtents[this.curMapExtentIndex].xmax,this.mapExtents[this.curMapExtentIndex].ymax,false);\n" " }\n" "}\n" "\n" "map.prototype.forwardExtent = function() {\n" " if (this.mapExtents.length != (this.curMapExtentIndex + 1)) {\n" " this.curMapExtentIndex++;\n" " this.setNewViewBox(this.mapExtents[this.curMapExtentIndex].xmin,this.mapExtents[this.curMapExtentIndex].ymin,this.mapExtents[this.curMapExtentIndex].xmax,this.mapExtents[this.curMapExtentIndex].ymax,false);\n" " }\n" "}\n" "\n" "map.prototype.checkButtons = function() {\n" " //check extent history\n" " if (this.curMapExtentIndex == 0) {\n" " if (myMapApp.buttons[\"backwardExtent\"].activated) {\n" " myMapApp.buttons[\"backwardExtent\"].deactivate();\n" " }\n" " }\n" " else {\n" " if (!myMapApp.buttons[\"backwardExtent\"].activated) {\n" " myMapApp.buttons[\"backwardExtent\"].activate();\n" " } \n" " }\n" " if (this.mapExtents.length == (this.curMapExtentIndex + 1)) {\n" " if (myMapApp.buttons[\"forwardExtent\"].activated) {\n" " myMapApp.buttons[\"forwardExtent\"].deactivate();\n" " }\n" " }\n" " else {\n" " if (!myMapApp.buttons[\"forwardExtent\"].activated) {\n" " myMapApp.buttons[\"forwardExtent\"].activate();\n" " } \n" " }\n" " \n" " //maximum map width reached, cannot zoom out further\n" " if (this.curWidth >= this.maxWidth) {\n" " if (myMapApp.buttons[\"zoomOut\"].activated) {\n" " myMapApp.buttons[\"zoomOut\"].deactivate();\n" " }\n" " if (myMapApp.buttons[\"zoomFull\"].activated) {\n" " myMapApp.buttons[\"zoomFull\"].deactivate();\n" " }\n" " if (myMapApp.buttons[\"panManual\"].activated) {\n" " myMapApp.buttons[\"panManual\"].deactivate();\n" " }\n" " if (myMapApp.buttons[\"recenterMap\"].activated) {\n" " myMapApp.buttons[\"recenterMap\"].deactivate();\n" " }\n" " if (!myMapApp.buttons[\"zoomIn\"].activated) {\n" " myMapApp.buttons[\"zoomIn\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"zoomManual\"].activated) {\n" " myMapApp.buttons[\"zoomManual\"].activate();\n" " }\n" " }\n" " //minimum map width reached, cannot zoom in further\n" " else if (this.curWidth <= this.minWidth) {\n" " if (myMapApp.buttons[\"zoomIn\"].activated) {\n" " myMapApp.buttons[\"zoomIn\"].deactivate();\n" " }\n" " if (myMapApp.buttons[\"zoomManual\"].activated) {\n" " myMapApp.buttons[\"zoomManual\"].deactivate();\n" " }\n" " if (!myMapApp.buttons[\"zoomOut\"].activated) {\n" " myMapApp.buttons[\"zoomOut\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"zoomFull\"].activated) {\n" " myMapApp.buttons[\"zoomFull\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"panManual\"].activated) {\n" " myMapApp.buttons[\"panManual\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"recenterMap\"].activated) {\n" " myMapApp.buttons[\"recenterMap\"].activate();\n" " } \n" " }\n" " //in between\n" " else {\n" " if (!myMapApp.buttons[\"zoomIn\"].activated) {\n" " myMapApp.buttons[\"zoomIn\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"zoomManual\"].activated) {\n" " myMapApp.buttons[\"zoomManual\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"zoomOut\"].activated) {\n" " myMapApp.buttons[\"zoomOut\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"zoomFull\"].activated) {\n" " myMapApp.buttons[\"zoomFull\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"panManual\"].activated) {\n" " myMapApp.buttons[\"panManual\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"recenterMap\"].activated) {\n" " myMapApp.buttons[\"recenterMap\"].activate();\n" " } \n" " } \n" "}\n" "\n" "map.prototype.setNewViewBox = function(xmin,ymin,xmax,ymax,history) {\n" " //check if within constraints\n" " if (xmin < myMapApp.refMapDragger.constrXmin) {\n" " xmin = myMapApp.refMapDragger.constrXmin;\n" " }\n" " if (xmax > myMapApp.refMapDragger.constrXmax) {\n" " xmax = myMapApp.refMapDragger.constrXmin;\n" " }\n" " if (ymin < (myMapApp.refMapDragger.constrYmax * -1)) {\n" " ymin = myMapApp.refMapDragger.constrYmax * -1;\n" " }\n" " if (ymax > (myMapApp.refMapDragger.constrYmin * -1)) {\n" " ymax = myMapApp.refMapDragger.constrYmin * -1;\n" " }\n" " \n" " var origWidth = xmax - xmin;\n" " var origHeight = ymax - ymin;\n" " var myRatio = this.curWidth/this.curHeight;\n" " \n" " if (origWidth / origHeight > myRatio) { //case rect is more wide than ratio\n" " var newWidth = origWidth;\n" " var newHeight = origWidth * 1 / myRatio;\n" " ymin = (ymax + (newHeight - origHeight) / 2) * -1;\n" " }\n" " else {\n" " var newHeight = origHeight;\n" " var newWidth = newHeight * myRatio;\n" " xmin = xmin - (newWidth - origWidth) / 2;\n" " ymin = ymax * -1;\n" " }\n" " //check if within constraints\n" " if (xmin < myMapApp.refMapDragger.constrXmin) {\n" " xmin = myMapApp.refMapDragger.constrXmin;\n" " }\n" " if (ymin < myMapApp.refMapDragger.constrYmin) {\n" " ymin = myMapApp.refMapDragger.constrYmin;\n" " }\n" " if ((xmin + newWidth) > myMapApp.refMapDragger.constrXmax) {\n" " xmin = myMapApp.refMapDragger.constrXmax - newWidth;\n" " }\n" " if ((ymin + newHeight) > myMapApp.refMapDragger.constrYmax) {\n" " ymin = myMapApp.refMapDragger.constrYmax - newHeight;\n" " } \n" " myMapApp.refMapDragger.newView(xmin,ymin,newWidth,newHeight);\n" " this.newViewBox(myMapApp.refMapDragger.dragId,history);\n" "}\n" "\n" "//handles events associated with navigation\n" "map.prototype.handleEvent = function(evt) {\n" " var callerId = evt.currentTarget.getAttributeNS(null,\"id\"));\n" " if (callerId.match(/\\bzoomBgRectManual/)) {\n" " this.zoomManDragRect(evt);\n" " }\n" " if (callerId.match(/\\bzoomBgRectRecenter/)) {\n" " this.recenterFinally(evt);\n" " }\n" " if (callerId.match(/\\bbgPanManual/)) {\n" " this.panManualFinally(evt);\n" " }\n" " if (callerId == \"mainMap\" && evt.type == \"mousemove\")) {\n" " if (this.navStatus != \"panmanualActive\")) {\n" " this.showCoordinates(evt);\n" " }\n" " }\n" "}\n" "\n" "//calcs coordinates; relies on myMapApp to handle different window sizes and resizing of windows\n" "map.prototype.calcCoord = function(evt) {\n" " //with getScreenCTM the values are already in the inner coordinate system\n" " if (!this.getScreenCTM) {\n" " var coords = myMapApp.calcCoord(evt,this.mapSVG);\n" " coords.x = this.curxOrig + (coords.x - this.pixXOffset) * this.pixSize;\n" " coords.y = (this.curyOrig + (coords.y - this.pixYOffset) * this.pixSize);\n" " }\n" " else { \n" " var coords = myMapApp.calcCoord(evt,this.mainMapGroup);\n" " }\n" " return coords;\n" "}\n" "\n" "//displays x and y coordinates in two separate text elements\n" "map.prototype.showCoordinates = function(evt) {\n" " var mapCoords = this.calcCoord(evt);\n" " this.coordXText.nodeValue = \"X: \" + formatNumberString((mapCoords.x * this.unitsFactor).toFixed(this.nrDecimals)) + this.units;\n" " this.coordYText.nodeValue = \"Y: \" + formatNumberString((mapCoords.y * this.unitsFactor * -1).toFixed(this.nrDecimals)) + this.units;\n" "}\n" "\n" "//checks for and removes temporary rectangle objects\n" "map.prototype.stopNavModes = function() {\n" " if (this.navStatus != \"info\")) {\n" " if (this.navStatus == \"zoomManual\")) {\n" " myMapApp.buttons[\"zoomManual\"].setSwitchValue(false,false);\n" " }\n" " if (this.navStatus == \"panmanual\" || this.navStatus == \"panmanualActive\")) {\n" " myMapApp.buttons[\"panManual\"].setSwitchValue(false,false);\n" " }\n" " if (this.navStatus == \"recenter\")) {\n" " myMapApp.buttons[\"recenterMap\"].setSwitchValue(false,false);\n" " }\n" " this.backgroundRect.setAttributeNS(null,\"id\"),\"mapBackgroundRect\"));\n" " myMapApp.buttons[\"infoButton\"].setSwitchValue(true,false);\n" " this.navStatus = \"info\");\n" " this.mapSVG.setAttributeNS(null,\"cursor\"),\"crosshair\"));\n" " statusChange(\"Mode: Infomode\"));\n" " this.mainMapGroup.insertBefore(this.backgroundRect,this.mainMapGroup.firstChild);\n" " }\n" "}\n" "\n" "//starts manual zooming mode\n" "map.prototype.zoomManual = function(evt) {\n" " if (Math.round(myMainMap.curWidth) > myMainMap.minWidth && evt.detail == 1) {\n" " this.navStatus = \"zoomManual\");\n" " this.backgroundRect.setAttributeNS(null,\"id\"),\"zoomBgRectManual\")); \n" " this.mainMapGroup.appendChild(this.backgroundRect);\n" " this.mapSVG.setAttributeNS(null,\"cursor\"),\"se-resize\"));\n" " statusChange(\"Click and drag rectangle for new map extent.\"));\n" " }\n" "}\n" "\n" "//manages manual zooming by drawing a rectangle\n" "map.prototype.zoomManDragRect = function(evt) {\n" " var mapCoords = this.calcCoord(evt);\n" " var myX = mapCoords.x;\n" " var myY = mapCoords.y;\n" " var myYXFact = this.curHeight / this.curWidth;\n" " if (evt.type == \"mousedown\")) {\n" " this.manZoomActive = 1;\n" " this.zoomRect = document.createElementNS(svgNS,\"rect\"));\n" " var myLineWidth = this.curWidth * 0.003;\n" " this.zoomRect.setAttributeNS(null,\"id\"),\"zoomRect\"));\n" " this.zoomRect.setAttributeNS(null,\"fill\"),\"white\"));\n" " this.zoomRect.setAttributeNS(null,\"fill-opacity\"),\"0.5\"));\n" " this.zoomRect.setAttributeNS(null,\"stroke\"),\"dimgray\"));\n" " this.zoomRect.setAttributeNS(null,\"stroke-width\"),myLineWidth);\n" " this.zoomRect.setAttributeNS(null,\"stroke-dasharray\"),(myLineWidth*3)+\"),\"+myLineWidth);\n" " this.zoomRect.setAttributeNS(null,\"pointer-events\"),\"none\"));\n" " this.zoomRect.setAttributeNS(null,\"x\"),myX);\n" " this.zoomRect.setAttributeNS(null,\"y\"),myY);\n" " this.zoomRect.setAttributeNS(null,\"width\"),this.minWidth);\n" " this.zoomRect.setAttributeNS(null,\"height\"),this.minWidth * myYXFact);\n" " this.mainMapGroup.appendChild(this.zoomRect);\n" " this.zoomRectOrigX = myX;\n" " this.zoomRectOrigY = myY;\n" " }\n" " if (evt.type == \"mousemove\" && this.manZoomActive == 1) {\n" " var myZoomWidth = myX - this.zoomRectOrigX;\n" " if (myZoomWidth < 0) {\n" " if (Math.abs(myZoomWidth) < this.minWidth) {\n" " this.zoomRect.setAttributeNS(null,\"x\"),this.zoomRectOrigX - this.minWidth);\n" " this.zoomRect.setAttributeNS(null,\"y\"),this.zoomRectOrigY - this.minWidth * myYXFact);\n" " this.zoomRect.setAttributeNS(null,\"width\"),this.minWidth);\n" " this.zoomRect.setAttributeNS(null,\"height\"),this.minWidth * myYXFact);\n" " }\n" " else {\n" " this.zoomRect.setAttributeNS(null,\"x\"),myX);\n" " this.zoomRect.setAttributeNS(null,\"y\"),this.zoomRectOrigY - Math.abs(myZoomWidth) * myYXFact);\n" " this.zoomRect.setAttributeNS(null,\"width\"),Math.abs(myZoomWidth));\n" " this.zoomRect.setAttributeNS(null,\"height\"),Math.abs(myZoomWidth) * myYXFact); \n" " }\n" " }\n" " else {\n" " this.zoomRect.setAttributeNS(null,\"x\"),this.zoomRectOrigX);\n" " this.zoomRect.setAttributeNS(null,\"y\"),this.zoomRectOrigY);\n" " if (myZoomWidth < this.minWidth) {\n" " this.zoomRect.setAttributeNS(null,\"width\"),this.minWidth);\n" " this.zoomRect.setAttributeNS(null,\"height\"),this.minWidth * myYXFact); \n" " }\n" " else {\n" " this.zoomRect.setAttributeNS(null,\"width\"),myZoomWidth);\n" " this.zoomRect.setAttributeNS(null,\"height\"),myZoomWidth * myYXFact);\n" " }\n" " }\n" " }\n" " if ((evt.type == \"mouseup\" || evt.type == \"mouseout\")) && this.manZoomActive == 1) {\n" " this.manZoomActive = 0;\n" " if (parseFloat(this.zoomRect.getAttributeNS(null,\"width\"))) > this.curWidth * 0.02) {\n" " myMapApp.refMapDragger.newView(parseFloat(this.zoomRect.getAttributeNS(null,\"x\"))),parseFloat(this.zoomRect.getAttributeNS(null,\"y\"))),parseFloat(this.zoomRect.getAttributeNS(null,\"width\"))),parseFloat(this.zoomRect.getAttributeNS(null,\"height\"))));\n" " this.newViewBox(myMapApp.refMapDragger.dragId,true);\n" " }\n" " this.mainMapGroup.removeChild(this.zoomRect);\n" " statusChange(\"Mode: Manual Zooming\"));\n" " }\n" "}\n" "\n" "//initializes recentering mode\n" "map.prototype.recenter = function(evt) {\n" " if (evt.detail == 1) {\n" " this.navStatus = \"recenter\");\n" " this.backgroundRect.setAttributeNS(null,\"id\"),\"zoomBgRectRecenter\")); \n" " this.mainMapGroup.appendChild(this.backgroundRect);\n" " this.mapSVG.setAttributeNS(null,\"cursor\"),\"pointer\"));\n" " statusChange(\"Click in map to define new map center.\"));\n" " }\n" "}\n" "\n" "//finishes recentering after mouse-click\n" "map.prototype.recenterFinally = function(evt) {\n" " if (evt.type == \"click\")) {\n" " var mapCoords = this.calcCoord(evt);\n" " var myX = mapCoords.x;\n" " var myY = mapCoords.y;\n" " var myNewX = myX - this.curWidth / 2;\n" " var myNewY = myY - this.curHeight / 2;\n" " \n" " //check if within constraints\n" " if (myNewX < myMapApp.refMapDragger.constrXmin) {\n" " myNewX = myMapApp.refMapDragger.constrXmin;\n" " }\n" " if (myNewY < myMapApp.refMapDragger.constrYmin) {\n" " myNewY = myMapApp.refMapDragger.constrYmin;\n" " }\n" " if ((myNewX + this.curWidth) > myMapApp.refMapDragger.constrXmax) {\n" " myNewX = myMapApp.refMapDragger.constrXmax - this.curWidth;\n" " }\n" " if ((myNewY + this.curHeight) > myMapApp.refMapDragger.constrYmax) {\n" " myNewY = myMapApp.refMapDragger.constrYmax - this.curHeight;\n" " }\n" " myMapApp.refMapDragger.newView(myNewX,myNewY,this.curWidth,this.curHeight);\n" " this.newViewBox(myMapApp.refMapDragger.dragId,true);\n" " statusChange(\"Mode: Recentering Map\"));\n" " }\n" "}\n" "\n" "//initializes manual panning\n" "map.prototype.panManual = function(evt) {\n" " if (evt.detail == 1) {\n" " this.navStatus = \"panmanual\");\n" " this.backgroundRect.setAttributeNS(null,\"id\"),\"bgPanManual\")); \n" " this.mainMapGroup.appendChild(this.backgroundRect);\n" " this.mapSVG.setAttributeNS(null,\"cursor\"),\"move\"));\n" " statusChange(\"Mouse down and move to pan the map\"));\n" " }\n" "}\n" "\n" "//manages and finishes manual panning\n" "map.prototype.panManualFinally = function(evt) {\n" " if (evt.type == \"mousedown\")) {\n" " this.navStatus = \"panmanualActive\");\n" " this.panCoords = this.calcCoord(evt);\n" " this.panCoorX = this.panCoords.x;\n" " this.panCoorY = this.panCoords.y;\n" " this.diffX = 0;\n" " this.diffY = 0;\n" " this.mainMapGroup.setAttributeNS(batikNS,\"static\"),\"true\"));\n" " }\n" " if (evt.type == \"mousemove\" && this.navStatus == \"panmanualActive\")) {\n" " var mapCoords = this.calcCoord(evt);\n" " if (this.getScreenCTM) {\n" " this.diffX = this.panCoorX - mapCoords.x + this.diffX;\n" " this.diffY = this.panCoorY - mapCoords.y + this.diffY;\n" " }\n" " else {\n" " this.diffX = this.panCoorX - mapCoords.x;\n" " this.diffY = this.panCoorY - mapCoords.y; \n" " }\n" " var myNewX = this.curxOrig + this.diffX;\n" " var myNewY = this.curyOrig + this.diffY;\n" " //check if within constraints\n" " if (myNewX < myMapApp.refMapDragger.constrXmin) {\n" " var myNewXTemp = myMapApp.refMapDragger.constrXmin;\n" " this.diffX = this.diffX + (myNewXTemp - myNewX);\n" " myNewX = myNewXTemp;\n" " }\n" " if (myNewY < myMapApp.refMapDragger.constrYmin) {\n" " var myNewYTemp = myMapApp.refMapDragger.constrYmin;\n" " this.diffY = this.diffY + (myNewYTemp - myNewY);\n" " myNewY = myNewYTemp;\n" " }\n" " if ((myNewX + this.curWidth) > myMapApp.refMapDragger.constrXmax) {\n" " var myNewXTemp = myMapApp.refMapDragger.constrXmax - this.curWidth;\n" " this.diffX = this.diffX + (myNewXTemp - myNewX);\n" " myNewX = myNewXTemp;\n" " }\n" " if ((myNewY + this.curHeight) > myMapApp.refMapDragger.constrYmax) {\n" " var myNewYTemp = myMapApp.refMapDragger.constrYmax - this.curHeight;\n" " this.diffY = this.diffY + (myNewYTemp - myNewY);\n" " myNewY = myNewYTemp;\n" " } \n" " var transformString = \"translate(\"+(this.diffX * -1) +\"),\"+(this.diffY * -1)+\"))\");\n" " this.mainMapGroup.setAttributeNS(null,\"transform\"),transformString);\n" " myMapApp.refMapDragger.newView(myNewX,myNewY,this.curWidth,this.curHeight);\n" " }\n" " if ((evt.type == \"mouseup\" || evt.type == \"mouseout\")) && this.navStatus == \"panmanualActive\")) {\n" " this.navStatus = \"panmanual\");\n" " this.mainMapGroup.setAttributeNS(batikNS,\"static\"),\"false\"));\n" " this.mainMapGroup.setAttributeNS(null,\"transform\"),\"translate(0,0)\"));\n" " this.newViewBox(myMapApp.refMapDragger.dragId,true); \n" " statusChange(\"Mode: Manual Panning\")); \n" " }\n" "}\n" "\n" "//remove all temporarily added elements and event listeners\n" "map.prototype.cleanUp = function() {\n" " //remove background rect\n" " this.backgroundRect.parentNode.removeChild(this.backgroundRect);\n" " //remove eventlisteners\n" " if (this.showCoords == true) {\n" " //add event listener for coordinate display\n" " this.mapSVG.removeEventListener(\"mousemove\"),this,false);\n" " }\n" "\n" "}\n" "\n" "//make an element (rectangle) draggable within constraints\n" "function dragObj(dragId,referenceMap,myDragSymbol,dragSymbThreshold,showCoords,coordXId,coordYId,mainMapObj) {\n" " this.dragId = dragId;\n" " this.myDragger = document.getElementById(this.dragId);\n" " this.myRefMap = document.getElementById(referenceMap);\n" " this.myDragSymbol = document.getElementById(myDragSymbol); \n" " this.dragSymbThreshold = dragSymbThreshold;\n" " var viewBox = this.myRefMap.getAttributeNS(null,\"viewBox\")).split(\" \"));\n" " this.constrXmin = parseFloat(viewBox[0]);\n" " this.constrYmin = parseFloat(viewBox[1]);\n" " this.constrXmax = this.constrXmin + parseFloat(viewBox[2]);\n" " this.constrYmax = this.constrYmin + parseFloat(viewBox[3]);\n" " this.refMapX = parseFloat(this.myRefMap.getAttributeNS(null,\"x\")));\n" " this.refMapY = parseFloat(this.myRefMap.getAttributeNS(null,\"y\")));\n" " this.refMapWidth = parseFloat(this.myRefMap.getAttributeNS(null,\"width\")));\n" " this.pixSize = (this.constrXmax - this.constrXmin) / this.refMapWidth;\n" " this.mainMapObj = mainMapObj;\n" " //initialize coordinate display if showCoords == true\n" " this.showCoords = showCoords;\n" " if (this.showCoords == true) {\n" " if (typeof(coordXId) == \"string\")) {\n" " this.coordXText = document.getElementById(coordXId).firstChild;\n" " }\n" " else {\n" " alert(\"Error: coordXId needs to be an id of type string\"));\n" " }\n" " if (typeof(coordYId) == \"string\")) {\n" " this.coordYText = document.getElementById(coordYId).firstChild;\n" " }\n" " else {\n" " alert(\"Error: coordYId needs to be an id of type string\"));\n" " }\n" " }\n" " //determine if viewer is capable of getScreenCTM\n" " if (document.documentElement.getScreenCTM) {\n" " this.getScreenCTM = true;\n" " }\n" " else {\n" " this.getScreenCTM = false; \n" " }\n" " this.status = false;\n" "}\n" "\n" "dragObj.prototype.calcCoord = function(evt) {\n" " //with getScreenCTM the values are already in the inner coordinate system but without using the outer offset\n" " var coordPoint = myMapApp.calcCoord(evt,this.myRefMap);\n" " if (!this.getScreenCTM) {\n" " coordPoint.x = this.constrXmin + (coordPoint.x - this.refMapX) * this.pixSize;\n" " coordPoint.y = this.constrYmin + (coordPoint.y - this.refMapY) * this.pixSize;\n" " }\n" " return coordPoint;\n" "}\n" "\n" "dragObj.prototype.handleEvent = function(evt) {\n" " if (evt.type == \"mousemove\")) {\n" " var mapCoords = this.calcCoord(evt);\n" " this.coordXText.nodeValue = \"X: \" + formatNumberString(mapCoords.x.toFixed(this.mainMapObj.nrDecimals)) + this.mainMapObj.units;\n" " this.coordYText.nodeValue = \"Y: \" + formatNumberString((mapCoords.y * -1).toFixed(this.mainMapObj.nrDecimals)) + this.mainMapObj.units;\n" " }\n" " this.drag(evt);\n" "}\n" "\n" "dragObj.prototype.newView = function(x,y,width,height) {\n" " this.myDragger.setAttributeNS(null,\"x\"),x);\n" " this.myDragger.setAttributeNS(null,\"y\"),y);\n" " this.myDragger.setAttributeNS(null,\"width\"),width);\n" " this.myDragger.setAttributeNS(null,\"height\"),height);\n" " this.myDragSymbol.setAttributeNS(null,\"x\"),(x + width/2));\n" " this.myDragSymbol.setAttributeNS(null,\"y\"),(y + height/2));\n" " if (width < this.dragSymbThreshold) {\n" " this.myDragSymbol.setAttributeNS(null,\"visibility\"),\"visible\"));\n" " }\n" " else {\n" " this.myDragSymbol.setAttributeNS(null,\"visibility\"),\"hidden\")); \n" " }\n" "}\n" "\n" ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_Navigation_2(void) { return( "//this method was previously called \"resizeDragger\" - now renamed to .getSliderVal\n" "//this method receives values from the zoom slider\n" "dragObj.prototype.getSliderVal = function(status,sliderGroupName,width) {\n" " var myX = parseFloat(this.myDragger.getAttributeNS(null,\"x\")));\n" " var myY = parseFloat(this.myDragger.getAttributeNS(null,\"y\")));\n" " var myWidth = parseFloat(this.myDragger.getAttributeNS(null,\"width\")));\n" " var myHeight = parseFloat(this.myDragger.getAttributeNS(null,\"height\")));\n" " var myCenterX = myX + myWidth / 2;\n" " var myCenterY = myY + myHeight / 2;\n" " var myRatio = myHeight / myWidth;\n" " var toMoveX = myCenterX - width / 2;\n" " var toMoveY = myCenterY - width * myRatio / 2;\n" " if (toMoveX < this.constrXmin) {\n" " toMoveX = this.constrXmin;\n" " }\n" " if ((toMoveX + width) > this.constrXmax) {\n" " toMoveX = this.constrXmax - width;\n" " }\n" " if (toMoveY < this.constrYmin) {\n" " toMoveY = this.constrYmin;\n" " }\n" " if ((toMoveY + width * myRatio) > this.constrYmax) {\n" " toMoveY = this.constrYmax - width * myRatio;\n" " }\n" " this.newView(toMoveX,toMoveY,width,width * myRatio);\n" " if (status == \"release\")) {\n" " myMainMap.stopNavModes();\n" " this.mainMapObj.newViewBox(this.dragId,true);\n" " }\n" "}\n" "\n" "dragObj.prototype.drag = function(evt) {\n" " if (evt.type == \"mousedown\")) {\n" " this.myRefMap.setAttributeNS(null,\"cursor\"),\"move\"));\n" " this.status = true;\n" " }\n" " if ((evt.type == \"mousemove\" || evt.type == \"mousedown\")) && this.status == true) {\n" " var coords = this.calcCoord(evt);\n" " var newEvtX = coords.x;\n" " var newEvtY = coords.y;\n" " var myX = parseFloat(this.myDragger.getAttributeNS(null,\"x\")));\n" " var myY = parseFloat(this.myDragger.getAttributeNS(null,\"y\")));\n" " var myWidth = parseFloat(this.myDragger.getAttributeNS(null,\"width\")));\n" " var myHeight = parseFloat(this.myDragger.getAttributeNS(null,\"height\")));\n" " var toMoveX = newEvtX - myWidth / 2;\n" " var toMoveY = newEvtY - myHeight / 2;\n" " if (toMoveX < this.constrXmin) {\n" " toMoveX = this.constrXmin;\n" " }\n" " if ((toMoveX + myWidth) > this.constrXmax) {\n" " toMoveX = this.constrXmax - myWidth;\n" " }\n" " if (toMoveY < this.constrYmin) {\n" " toMoveY = this.constrYmin;\n" " }\n" " if ((toMoveY + myHeight) > this.constrYmax) {\n" " toMoveY = this.constrYmax - myHeight;\n" " }\n" " this.newView(toMoveX,toMoveY,myWidth,myHeight);\n" " }\n" " if ((evt.type == \"mouseup\" || evt.type == \"mouseout\")) && this.status == true) {\n" " this.status = false;\n" " if (evt.detail == 1) { //second click is ignored\n" " this.myRefMap.setAttributeNS(null,\"cursor\"),\"crosshair\"));\n" " this.mainMapObj.newViewBox('dragRectForRefMap',true);\n" " }\n" " }\n" "}\n" "\n" "dragObj.prototype.zoom = function(inOrOut) {\n" " var myOldX = this.myDragger.getAttributeNS(null,\"x\"));\n" " var myOldY = this.myDragger.getAttributeNS(null,\"y\"));\n" " var myOldWidth = this.myDragger.getAttributeNS(null,\"width\"));\n" " var myOldHeight = this.myDragger.getAttributeNS(null,\"height\"));\n" " switch (inOrOut) {\n" " case \"in\":\n" " var myNewX = parseFloat(myOldX) + myOldWidth / 2 - (myOldWidth * this.mainMapObj.zoomFact * 0.5);\n" " var myNewY = parseFloat(myOldY) + myOldHeight / 2 - (myOldHeight * this.mainMapObj.zoomFact * 0.5);\n" " var myNewWidth = myOldWidth * this.mainMapObj.zoomFact;\n" " var myNewHeight = myOldHeight * this.mainMapObj.zoomFact;\n" " if (myNewWidth < this.mainMapObj.minWidth) {\n" " var myYXFact = this.mainMapObj.curHeight / this.mainMapObj.curWidth;\n" " myNewWidth = this.mainMapObj.minWidth;\n" " myNewHeight = myNewWidth * myYXFact;\n" " myNewX = parseFloat(myOldX) + myOldWidth / 2 - (myNewWidth * 0.5);\n" " myNewY = parseFloat(myOldY) + myOldHeight / 2 - (myNewHeight * 0.5);\n" " }\n" " break;\n" " case \"out\":\n" " var myNewX = parseFloat(myOldX) + myOldWidth / 2 - (myOldWidth * (1 + this.mainMapObj.zoomFact) * 0.5);\n" " var myNewY = parseFloat(myOldY) + myOldHeight / 2 - (myOldHeight * (1 + this.mainMapObj.zoomFact) * 0.5);\n" " var myNewWidth = myOldWidth * (1 + this.mainMapObj.zoomFact);\n" " var myNewHeight = myOldHeight * (1 + this.mainMapObj.zoomFact);\n" " break;\n" " default:\n" " var myNewX = this.constrXmin;\n" " var myNewY = this.constrYmin;\n" " var myNewWidth = this.constrXmax - this.constrXmin;\n" " var myNewHeight = this.constrYmax - this.constrYmin;\n" " break;\n" " } \n" " //check if within constraints\n" " if (myNewWidth > (this.constrXmax - this.constrXmin)) {\n" " myNewWidth = this.constrXmax - this.constrXmin;\n" " }\n" " if (myNewHeight > (this.constrYmax - this.constrYmin)) {\n" " myNewHeight = this.constrYmax - this.constrYmin;\n" " }\n" " if (myNewX < this.constrXmin) {\n" " myNewX = this.constrXmin;\n" " }\n" " if (myNewY < this.constrYmin) {\n" " myNewY = this.constrYmin;\n" " }\n" " if ((myNewX + myNewWidth) > this.constrXmax) {\n" " myNewX = this.constrXmax - myNewWidth;\n" " }\n" " if ((myNewY + myNewHeight) > this.constrYmax) {\n" " myNewY = this.constrYmax - myNewHeight;\n" " }\n" " this.newView(myNewX,myNewY,myNewWidth,myNewHeight);\n" " this.mainMapObj.newViewBox(this.dragId,true);\n" "}\n" "\n" "dragObj.prototype.pan = function (myX,myY,howmuch) {\n" " //get values from draggable rectangle\n" " var xulcorner = parseFloat(this.myDragger.getAttributeNS(null,\"x\")));\n" " var yulcorner = parseFloat(this.myDragger.getAttributeNS(null,\"y\")));\n" " var width = parseFloat(this.myDragger.getAttributeNS(null,\"width\")));\n" " var height = parseFloat(this.myDragger.getAttributeNS(null,\"height\")));\n" "\n" " //set values of draggable rectangle\n" " var rectXulcorner = xulcorner + howmuch * width * myX;\n" " var rectYulcorner = yulcorner + howmuch * height * myY;\n" " //check if within constraints\n" " if (rectXulcorner < this.constrXmin) {\n" " rectXulcorner = this.constrXmin;\n" " }\n" " if (rectYulcorner < this.constrYmin) {\n" " rectYulcorner = this.constrYmin;\n" " }\n" " if ((rectXulcorner + width) > this.constrXmax) {\n" " rectXulcorner = this.constrXmax - width;\n" " }\n" " if ((rectYulcorner + height) > this.constrYmax) {\n" " rectYulcorner = this.constrYmax - height;\n" " }\n" " this.newView(rectXulcorner,rectYulcorner,width,height);\n" "\n" " //set viewport of main map\n" " if ((xulcorner != rectXulcorner) || (yulcorner != rectYulcorner)) {\n" " this.mainMapObj.newViewBox(this.dragId,true);\n" " }\n" "\n" " statusChange(\"map ready ...\"));\n" "}\n" "\n" "//remove all temporarily used elements and event listeners\n" "dragObj.prototype.cleanUp = function() {\n" " //remove eventlisteners\n" " if (this.showCoords == true) {\n" " //add event listener for coordinate display\n" " this.myRefMap.removeEventListener(\"mousemove\"),this,false);\n" " }\n" "}\n" "\n" "function zoomIt(evt,inOrOut) {\n" " if (evt.detail == 1) { //only react on first click, double click: second click is ignored\n" " if (inOrOut == \"in\")) {\n" " if (Math.round(myMainMap.curWidth) > myMainMap.minWidth) {\n" " myMapApp.refMapDragger.zoom(\"in\"));\n" " }\n" " else {\n" " statusChange(\"Maximum zoom factor reached. Cannot zoom in any more.\"));\n" " }\n" " }\n" " if (inOrOut == \"out\")) {\n" " if (Math.round(myMainMap.curWidth) < myMainMap.maxWidth) {\n" " myMapApp.refMapDragger.zoom(\"out\"));\n" " }\n" " else {\n" " statusChange(\"Minimum zoom factor reached. Cannot zoom out any more.\"));\n" " }\n" " }\n" " if (inOrOut == \"full\")) {\n" " if (Math.round(myMainMap.curWidth) < myMainMap.maxWidth) {\n" " myMapApp.refMapDragger.zoom(\"full\"));\n" " }\n" " else {\n" " statusChange(\"Full view already reached.\"));\n" " }\n" " }\n" " }\n" "}\n" "\n" "//this function starts various zoom actions or map extent history functions\n" "function zoomImageButtons(id,evt) {\n" " myMainMap.stopNavModes();\n" " if (id == \"zoomIn\")) {\n" " zoomIt(evt,'in');\n" " }\n" " if (id == \"zoomOut\")) {\n" " zoomIt(evt,'out');\n" " }\n" " if (id == \"zoomFull\")) {\n" " zoomIt(evt,'full');\n" " }\n" " if (id == \"backwardExtent\")) {\n" " myMainMap.backwardExtent();\n" " }\n" " if (id == \"forwardExtent\")) {\n" " myMainMap.forwardExtent();\n" " }\n" "}\n" "\n" "//this function starts various interactive zoom or pan modes\n" "function zoomImageSwitchButtons(id,evt,onOrOff) {\n" " myMainMap.stopNavModes();\n" " if (onOrOff) {\n" " if (id == \"infoButton\")) {\n" " \n" " }\n" " else {\n" " if (id == \"zoomManual\")) {\n" " myMainMap.zoomManual(evt);\n" " }\n" " if (id == \"panManual\")) {\n" " myMainMap.panManual(evt);\n" " }\n" " if (id == \"recenterMap\")) {\n" " myMainMap.recenter(evt);\n" " }\n" " if (myMapApp.buttons[\"infoButton\"].getSwitchValue()) {\n" " myMapApp.buttons[\"infoButton\"].setSwitchValue(false,false);\n" " }\n" " }\n" " }\n" " else {\n" " if (id == \"infoButton\")) {\n" " myMapApp.buttons[\"infoButton\"].setSwitchValue(true,false);\n" " }\n" " }\n" "}\n" "\n" "//alert map extent\n" "function showExtent() {\n" " with(myMainMap) {\n" " alert(\n" " \"Xmin=\"+curxOrig.toFixed(nrDecimals)+units+\n" " \"); Xmax=\"+(curxOrig + curWidth).toFixed(nrDecimals)+units+\n" " \"\\nYmin=\"+((curyOrig + curHeight) * -1).toFixed(nrDecimals) +units+\n" " \"); Ymax=\"+(curyOrig*-1).toFixed(nrDecimals)+units+\n" " \"\\nWidth=\"+curWidth.toFixed(nrDecimals)+units+\n" " \"); Height=\"+curHeight.toFixed(nrDecimals)+units);\n" " }\n" "}\n" "\n" ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/docs/docs_html/MLB_Interface.cpp0000664000175000017500000001057712565125412024045 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("HTML") ); case MLB_INFO_Category: return( _TL("Reports") ); case MLB_INFO_Author: return( SG_T("SAGA User Group (c) 2010") ); case MLB_INFO_Description: return( _TW( "Reports and document creation in Hypertext Mark Up Language (HTML) format." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Reports") ); } } //--------------------------------------------------------- #include "CreateWebContent.h" #include "svg_interactive_map.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CCreateWebContent ); case 1: return( new CSVG_Interactive_Map ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/docs/docs_html/Makefile.am0000664000175000017500000000131712565125412022773 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libdocs_html.la libdocs_html_la_SOURCES =\ CreateWebContent.cpp\ doc_html.cpp\ doc_svg.cpp\ MLB_Interface.cpp\ svg_interactive_map.cpp\ CreateWebContent.h\ doc_html.h\ doc_svg.h\ MLB_Interface.h\ svg_interactive_map.h libdocs_html_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/docs/docs_html/MLB_Interface.h0000664000175000017500000000756612565125412023516 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // MLB_Interface.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__docs_html__mlb_interface_H #define HEADER_INCLUDED__docs_html__mlb_interface_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef docs_html_EXPORTS #define docs_html_EXPORT _SAGA_DLL_EXPORT #else #define docs_html_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__docs_html__mlb_interface_H saga-2.2.3/src/modules/docs/docs_html/doc_html.cpp0000664000175000017500000004475612565125412023252 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_html.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // // // //-------------------------------------------------------// // // // doc_html.cpp // // // // Copyright (C) 2005 by // // Victor Olaya // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Victor Olaya // // // // e-mail: volaya@saga-gis.org // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_html.h" //--------------------------------------------------------- #define GRAPH_WIDTH 700 #define GRAPH_HEIGHT 350 #define MAP_WIDTH 700. #define MAP_HEIGHT 700. #define OFFSET_X 50 #define OFFSET_Y 50 //--------------------------------------------------------- #define HTML_CODE_OPENING_1 SG_T("\n") #define HTML_CODE_OPENING_2 SG_T("\n")\ SG_T("\n")\ SG_T("\n")\ SG_T("\n") #define HTML_CODE_CLOSING SG_T("\n") /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Doc_HTML::CSG_Doc_HTML(){} CSG_Doc_HTML::~CSG_Doc_HTML(){} void CSG_Doc_HTML::Open(const SG_Char *Title) { m_sHTMLCode.Clear(); m_sHTMLCode.Append(HTML_CODE_OPENING_1); m_sHTMLCode.Append(Title); m_sHTMLCode.Append(HTML_CODE_OPENING_2); } bool CSG_Doc_HTML::Save(const SG_Char *Filename) { m_sHTMLCode.Append(HTML_CODE_CLOSING); CSG_File Stream(Filename, SG_FILE_W, false); if( Stream.is_Open() ) { Stream.Printf(SG_T("%s"), m_sHTMLCode.c_str()); return true; } return false; } void CSG_Doc_HTML::AddParagraph(const SG_Char *Text) { m_sHTMLCode.Append(SG_T("

    ")); m_sHTMLCode.Append(Text); m_sHTMLCode.Append(SG_T("

    \n")); } void CSG_Doc_HTML::AddLineBreak() { m_sHTMLCode.Append(SG_T("
    ")); } void CSG_Doc_HTML::AddHeader(const SG_Char *Text, int iOrder) { m_sHTMLCode.Append(SG_T("")); m_sHTMLCode.Append(Text); m_sHTMLCode.Append(SG_T("\n")); } void CSG_Doc_HTML::AddHyperlink(const SG_Char *Text, const SG_Char *URL) { m_sHTMLCode.Append(SG_T("\n")); m_sHTMLCode.Append(Text); m_sHTMLCode.Append(SG_T("\n")); } CSG_String CSG_Doc_HTML::GetHyperlinkCode(const SG_Char *Text, const SG_Char *URL) { CSG_String s; s.Append(SG_T("\n")); s.Append(Text); s.Append(SG_T("\n")); return s; } void CSG_Doc_HTML::AddImage(const SG_Char *Filename) { m_sHTMLCode.Append(SG_T("\n")); } void CSG_Doc_HTML::AddThumbnail(const SG_Char *Filename, int iWidth, bool bIsPercent) { m_sHTMLCode.Append(SG_T("\n")); m_sHTMLCode.Append(SG_T("

    \n")); } void CSG_Doc_HTML::AddThumbnails(const SG_Char **Filename, int iImages, int iThumbnailsPerRow) { int i,j; int iImage = 0; int iRows = (int)ceil((double)iImages / (double)iThumbnailsPerRow); int iWidth = (int)(100.0 / (double)iThumbnailsPerRow); m_sHTMLCode.Append(SG_T("\n")); for (i=0; i\n")); for (j=0; j")); AddThumbnail(Filename[iImage], 100, true); iImage++; if (iImage >= iImages){ break; } m_sHTMLCode.Append(SG_T("")); } m_sHTMLCode.Append(SG_T("\n\n")); } m_sHTMLCode.Append(SG_T("\n
    \n")); } void CSG_Doc_HTML::StartUnorderedList() { m_sHTMLCode.Append(SG_T("
      \n")); } void CSG_Doc_HTML::StartOrderedList() { m_sHTMLCode.Append(SG_T("
        \n")); } void CSG_Doc_HTML::CloseUnorderedList() { m_sHTMLCode.Append(SG_T("
    \n")); } void CSG_Doc_HTML::CloseOrderedList() { m_sHTMLCode.Append(SG_T("\n")); } void CSG_Doc_HTML::AddListElement(const SG_Char *Text) { m_sHTMLCode.Append(SG_T("
  • ")); m_sHTMLCode.Append(Text); m_sHTMLCode.Append(SG_T("
  • \n")); } void CSG_Doc_HTML::AddOrderedList(const SG_Char **Text, int iElements) { StartOrderedList(); for (int i = 0; i < iElements; i++) { AddListElement(Text[i]); } CloseOrderedList(); } void CSG_Doc_HTML::AddUnorderedList(const SG_Char **Text, int iElements) { StartUnorderedList(); for (int i = 0; i < iElements; i++) { AddListElement(Text[i]); } CloseUnorderedList(); } void CSG_Doc_HTML::AddCurve(const SG_Char *Filename, CSG_Points &Data, const SG_Char *Description, int iGraphType, bool bIncludeTableData) { int i; int iMag; int iNumLines; double fMinLine = 0; double fWidth; double fMax, fMin; double fRange, fRangeX; double fStep; double fX, fY, fY2; double fMaxX, fMinX; CSG_String sValue; CSG_String sTableFilename; CSG_Points Points; CSG_Doc_SVG SVG; m_sHTMLCode.Append(SG_T("
    \n")); m_sHTMLCode.Append(SG_T("

    ")); m_sHTMLCode.Append(Description); m_sHTMLCode.Append(SG_T("

    \n")); fMin = fMax = Data[0].y; for (i = 0; i < Data.Get_Count(); i++) { if (Data[i].y > fMax) { fMax = Data[i].y; } if (Data[i].y < fMin) { fMin = Data[i].y; } if (iGraphType == HTML_GRAPH_TYPE_BARS){ fMin = M_GET_MIN(0, fMin); } } fRange = fMax - fMin; fMaxX = Data[Data.Get_Count() - 1].x; fMinX = Data[0].x; fRangeX = fMaxX - fMinX; SVG.Open(GRAPH_WIDTH + OFFSET_X, GRAPH_HEIGHT + OFFSET_Y); if (fMin != fMax){ iMag = (int) (log(fMax - fMin) / log(10.0)); fStep = (int) pow(10.0, (double) iMag); if (fStep == 0) { fStep = 1.; } if (fMin < 0) { iMag = (int) (log(fabs(fMin)) / log(10.0)); fMinLine = -(int) pow(10.0, (double) iMag); } else { fMinLine=(int)(((int)(fMin/fStep)) *fStep); } iNumLines = (int) ((fMax - fMin) / fStep); while (iNumLines < 8) { fStep = fStep / 2.0; iNumLines = (int) ((fMax - fMin) / fStep); } iNumLines = (int) ((fMax - fMinLine) / fStep); } else{ if (fMin > 0) { fStep = fMin = 0; iNumLines = 1; fMinLine = fMax; } else if (fMin < 0) { fStep = 0; fMin = fMin - 1; fMinLine = fMax; } else { return; } } for (i = 0; i < iNumLines; i++) { fY = (fMinLine + fStep * i - fMin) / (fRange) * GRAPH_HEIGHT; fY = GRAPH_HEIGHT - fY; if (fY >= 0 && fY <= GRAPH_HEIGHT) { SVG.Draw_Line(OFFSET_X - 10, fY, GRAPH_WIDTH + OFFSET_X, fY); SVG.Draw_Text(OFFSET_X - 10, fY, SG_Get_String(fMinLine + fStep * i, 1), 0, SG_T("Verdana"), 8, SVG_ALIGNMENT_Right); } } if (iGraphType == HTML_GRAPH_TYPE_BARS) { fWidth = GRAPH_WIDTH / (double) (Data.Get_Count()) ; for (i = 0; i < Data.Get_Count(); i++) { fX = OFFSET_X + i * fWidth; fY = GRAPH_HEIGHT; fY2 = (Data.Get_Y(i) - fMin) / fRange * GRAPH_HEIGHT; fY2 = GRAPH_HEIGHT - fY2; SVG.Draw_Rectangle(fX, fY, fX + fWidth, fY2, 0x660000, 0x000000); } } else { for (i = 0; i < Data.Get_Count(); i++) { fX = OFFSET_X + (Data.Get_X(i) - fMinX) / fRangeX * GRAPH_WIDTH; fY = (Data.Get_Y(i) - fMin) / fRange * GRAPH_HEIGHT; fY = GRAPH_HEIGHT - fY; Points.Add(fX, fY); } SVG.Draw_Line(Points, 4, 0x660000); } if (fMaxX != fMinX) { iMag = (int) (log(fMaxX - fMinX) / log(10.0)); fStep = (double) pow(10.0, (double) iMag); iNumLines = (int) ((fMaxX -fMinX) / fStep); while (iNumLines < 5) { fStep = fStep / 2.0; iNumLines = (int) ((fMaxX-fMinX) / fStep); } fMinLine = (int)(((int)(fMinX/fStep)) * fStep); while (fMinLine = OFFSET_X && fX <= GRAPH_WIDTH + OFFSET_X){ if (fabs(fStep * i +fMinLine) > 100000) { sValue = SG_Get_String(fStep * i +fMinLine); } else { sValue = SG_Get_String(fStep * i + fMinLine, 2, true); } SVG.Draw_Text(fX, GRAPH_HEIGHT + 10, sValue, 0, SG_T("Verdana"), 8, SVG_ALIGNMENT_Center); SVG.Draw_Line(fX, GRAPH_HEIGHT, fX, GRAPH_HEIGHT - 5); } } } SVG.Draw_Line(OFFSET_X, 0, OFFSET_X, GRAPH_HEIGHT, 4); SVG.Draw_Line(OFFSET_X, GRAPH_HEIGHT, OFFSET_X + GRAPH_WIDTH, GRAPH_HEIGHT, 4); SVG.Save(Filename); if (bIncludeTableData) { CSG_Doc_HTML HTMLDoc; HTMLDoc.Open(_TL("Data Table")); sTableFilename = Filename; sTableFilename.Append(SG_T(".htm")); m_sHTMLCode.Append(SG_T("")); m_sHTMLCode.Append(_TL("Data Table")); m_sHTMLCode.Append(SG_T("

    \n")); HTMLDoc._AddBicolumTable(&Data); HTMLDoc.Save(sTableFilename); } }//method void CSG_Doc_HTML::_AddBicolumTable(CSG_Points *pData) { int i; m_sHTMLCode.Append(SG_T("\n")); m_sHTMLCode.Append( SG_T("\n") SG_T("\n") SG_T("\n") ); for (i=0; iGet_Count(); i++) { m_sHTMLCode.Append(SG_T("\n")); m_sHTMLCode.Append(SG_T("")); m_sHTMLCode.Append(SG_T("")); m_sHTMLCode.Append(SG_T("\n\n")); } m_sHTMLCode.Append(SG_T("\n
    XY
    ")); m_sHTMLCode.Append(SG_Get_String(pData->Get_X(i),2)); m_sHTMLCode.Append(SG_T("")); m_sHTMLCode.Append(SG_Get_String(pData->Get_Y(i),2)); m_sHTMLCode.Append(SG_T("
    \n")); m_sHTMLCode.Append(SG_T("

    ")); m_sHTMLCode.Append(_TL("Data Table")); m_sHTMLCode.Append(SG_T("

    \n")); } void CSG_Doc_HTML::AddTable(const SG_Char ***Table, int iRows, int iCols, const SG_Char *Description) { int i,j; int iWidth = (int) (100/iCols); m_sHTMLCode.Append(SG_T("\n")); for (i=0; i\n")); } else { m_sHTMLCode.Append(SG_T("\n")); } for (j=0; j")); try { m_sHTMLCode.Append(Table[i][j]); } catch(...){} m_sHTMLCode.Append(SG_T("")); } m_sHTMLCode.Append(SG_T("\n\n")); } m_sHTMLCode.Append(SG_T("\n
    \n")); m_sHTMLCode.Append(SG_T("

    ")); m_sHTMLCode.Append(Description); m_sHTMLCode.Append(SG_T("

    \n")); } void CSG_Doc_HTML::AddTable(CSG_Table *pTable) { int i,j; int iWidth = (int) (100/pTable->Get_Field_Count()); m_sHTMLCode.Append(SG_T("\n")); m_sHTMLCode.Append(SG_T("\n")); for (i=0; iGet_Field_Count(); i++){ m_sHTMLCode.Append(SG_T("")); } m_sHTMLCode.Append(SG_T("\n\n")); for (i=0; iGet_Record_Count(); i++) { m_sHTMLCode.Append(SG_T("\n")); for (j=0; jGet_Field_Count(); j++){ m_sHTMLCode.Append(SG_T("")); } m_sHTMLCode.Append(SG_T("\n\n")); } m_sHTMLCode.Append(SG_T("\n
    ")); m_sHTMLCode.Append(pTable->Get_Field_Name(i)); m_sHTMLCode.Append(SG_T("
    ")); try { m_sHTMLCode.Append(pTable->Get_Record(i)->asString(j)); } catch(...){} m_sHTMLCode.Append(SG_T("
    \n")); m_sHTMLCode.Append(SG_T("

    ")); m_sHTMLCode.Append(pTable->Get_Name()); m_sHTMLCode.Append(SG_T("

    \n")); } bool CSG_Doc_HTML::_Draw_Shape(CSG_Doc_SVG &SVG, CSG_Shape *pShape, CSG_Rect GlobalRect, int Fill_Color, int Line_Color, int Line_Width, int Point_Width) { if( pShape && pShape->is_Valid() ) { int iPart, iPoint; double x,y; TSG_Point Point; CSG_Points Points; double dWidth, dHeight; double dOffsetX, dOffsetY; if (GlobalRect.Get_XRange() / GlobalRect.Get_YRange() > MAP_WIDTH / MAP_HEIGHT) { dWidth = MAP_WIDTH * .95; dHeight = MAP_HEIGHT / GlobalRect.Get_XRange() * GlobalRect.Get_YRange(); } else{ dHeight = MAP_HEIGHT * .95; dWidth = MAP_WIDTH / GlobalRect.Get_YRange() * GlobalRect.Get_XRange(); } dOffsetX = (MAP_WIDTH - dWidth) / 2.; dOffsetY = (MAP_HEIGHT - dHeight) / 2.; SVG.Draw_Rectangle(0,0,MAP_WIDTH,MAP_HEIGHT,SG_COLOR_NONE,SG_COLOR_BLACK,1); for(iPart=0; iPartGet_Part_Count(); iPart++) { Points.Clear(); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Point = pShape->Get_Point(iPoint, iPart); x = dOffsetX + (Point.x - GlobalRect.Get_XMin()) / GlobalRect.Get_XRange() * dWidth; y = (Point.y - GlobalRect.Get_YMin()) / GlobalRect.Get_YRange() * dHeight; y = MAP_HEIGHT - y - dOffsetY; Points.Add(x, y); } switch( pShape->Get_Type() ) { case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: for(iPoint=0; iPointis_Lake(iPart) ) { SVG.Draw_Polygon(Points, SG_COLOR_WHITE, Line_Color, Line_Width); } else { SVG.Draw_Polygon(Points, Fill_Color, Line_Color, Line_Width); } break; } } return( true ); } return( false ); } bool CSG_Doc_HTML::Draw_Shapes(CSG_Shapes *pShapes, const SG_Char *Filename, int Fill_Color, int Line_Color, int Line_Width) { CSG_Doc_SVG SVG; CSG_Rect r; if( pShapes && pShapes->is_Valid()) { r = pShapes->Get_Extent(); SVG.Open((int)MAP_WIDTH, (int)MAP_HEIGHT); for(int iShape=0; iShapeGet_Count(); iShape++) { _Draw_Shape(SVG, pShapes->Get_Shape(iShape), r, Fill_Color, Line_Color, 1, 3); } SVG.Save(Filename); m_sHTMLCode.Append(SG_T("
    \n

    \n")); return( true ); } return( false ); } saga-2.2.3/src/modules/docs/Makefile.in0000664000175000017500000004551712622651160021040 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/docs DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 = docs_html docs_pdf 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) --foreign src/modules/docs/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/docs/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/docs/Makefile.am0000664000175000017500000000003612565125412021014 0ustar00oconradoconrad00000000000000SUBDIRS = docs_html docs_pdf saga-2.2.3/src/modules/contrib/0000775000175000017500000000000012634325736017501 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/contrib/contrib_peregro/0000775000175000017500000000000012634325736022664 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/contrib/contrib_peregro/directional1.cpp0000664000175000017500000001152012565125413025736 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: directional1.cpp 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // directional1 // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // directional1.cpp // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "directional1.h" //--------------------------------------------------------- Cdirectional1::Cdirectional1(void) { // 1. Info... Set_Name(_TL("Directional Average")); Set_Author(_TL("Alessandro Perego")); Set_Description(_TL("directional1 average for Grids")); // 2. Parameters... Parameters.Add_Grid(NULL, "INPUT", _TL("Input"), _TL("This must be your input data of type grid."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "RESULT", _TL("Output Grid"), _TL("New grid filtered with the directional1 module"), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "ANG", _TL("Angle (in degrees)"), _TL("0 is horizontal, 90 is vertical."), PARAMETER_TYPE_Double, 0.0); Parameters.Add_Value(NULL, "R1", _TL("Main Radius"), _TL(""), PARAMETER_TYPE_Double, 1); Parameters.Add_Value(NULL, "R2", _TL("Transversal radius"), _TL(""), PARAMETER_TYPE_Double, 0.5); } //--------------------------------------------------------- Cdirectional1::~Cdirectional1(void) {} //--------------------------------------------------------- bool Cdirectional1::On_Execute(void) { int x, y, r1, dxmax, dymax, ix, ax, ay, bx, by, iy, iv, iw, n; double r2, ang, a, si, si2, co, co2, cosi, sico, r2co, r2si, Sum; CSG_Grid *pInput, *pResult; pInput = Parameters("INPUT")->asGrid(); pResult = Parameters("RESULT")->asGrid(); ang = Parameters("ANG")->asDouble(); r1 = Parameters("R1")->asInt(); r2 = Parameters("R2")->asDouble(); //----------------------------------------------------- a = ang * 6.283185307179586 / 360; si = sin(a); co = cos(a); si2 = si * si; co2 = co * co; dxmax = (int)((r1*sqrt(co2))+(r2*sqrt(si2))); dymax = (int)((r1*sqrt(si2))+(r2*sqrt(co2))); if(si2 >= co2) { cosi = co / si; r2si = r2 / sqrt(si2); for(y=0; y= Get_NX() ) { bx = Get_NX() - 1; } if( (ay = y - dymax) < 0 ) { ay = 0; } if( (by = y + dymax) >= Get_NY() ) { by = Get_NY() - 1; } //----------------------------------------------------- for(ix=ax; ix<=bx; ix++) { iv = x - ix; for(iy=ay; iy<=by; iy++) { iw = y - iy; if( iv >= (iw*cosi - r2si) && iv <= (iw*cosi + r2si)) { Sum += pInput->asDouble(ix, iy); n++; } } } if( n > 0 ) { pResult->Set_Value(x, y, Sum/n); } } } } if(si2 < co2) { sico = si / co; r2co = r2 / sqrt(co2); for(y=0; y= Get_NX() ) { bx = Get_NX() - 1; } if( (ay = y - dymax) < 0 ) { ay = 0; } if( (by = y + dymax) >= Get_NY() ) { by = Get_NY() - 1; } //----------------------------------------------------- for(iy=ay; iy<=by; iy++) { iw = y - iy; for(ix=ax; ix<=bx; ix++) { iv = x - ix; if( iw >= (iv*sico - r2co) && iw <= (iv*sico + r2co)) { Sum += pInput->asDouble(ix, iy); n++; } } } if( n > 0 ) { pResult->Set_Value(x, y, Sum/n); } } } } return( true ); } saga-2.2.3/src/modules/contrib/contrib_peregro/A2WiTh.cpp0000664000175000017500000001052412565125413024421 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: A2WiTh.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // A2WiTh // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // A2WiTh.cpp // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "A2WiTh.h" //--------------------------------------------------------- CA2WiTh::CA2WiTh(void) { // 1. Info... Set_Name(_TL("Average With Thereshold 2")); Set_Author(_TL("Alessandro Perego")); Set_Description(_TL("Average 2 With Thereshold for Grids calculates average in X and Y distances unsing only the values that differ form central pixel less than a specified threshold. Each value has a weight which is inversely proportional to the distance (method 1).")); // 2. Parameters... Parameters.Add_Grid(NULL, "INPUT", _TL("Input"), _TL("This must be your input data of type grid."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "RESULT", _TL("AWT Grid"), _TL("New grid filtered with the A2WiTh module"), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "RX", _TL("Radius X"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); Parameters.Add_Value(NULL, "RY", _TL("Radius Y"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); Parameters.Add_Value(NULL, "THRESH", _TL("Threshold"), _TL("The values in the specified radius is used in the average calculation only if its difference with the central value is lesser or equal to this threshold."), PARAMETER_TYPE_Double, 2.0); } //--------------------------------------------------------- CA2WiTh::~CA2WiTh(void) {} //--------------------------------------------------------- bool CA2WiTh::On_Execute(void) { int x, y, Rx, Ry, ax, ay, bx, by, ix, iy, iv, iw, irv, irw, n; double Thresh, Diff, Sum, c, d, i; CSG_Grid *pInput, *pResult; pInput = Parameters("INPUT")->asGrid(); pResult = Parameters("RESULT")->asGrid(); Rx = Parameters("RX")->asInt(); Ry = Parameters("RY")->asInt(); Thresh = Parameters("THRESH")->asDouble(); //----------------------------------------------------- for(y=0; y= Get_NX() ) { bx = Get_NX() - 1; } if( (ay = y - Ry) < 0 ) { ay = 0; } if( (by = y + Ry) >= Get_NY() ) { by = Get_NY() - 1; } //----------------------------------------------------- for(iy=ay; iy<=by; iy++) { for(ix=ax; ix<=bx; ix++) { iv = x -ix; if( iv >= 0) { irv = Rx - iv + 1; } else { irv = Rx + iv + 1; } iw = y -iy; if( iw >= 0) { irw = Ry - iw + 1; } else { irw = Ry + iw + 1; } c = pInput->asDouble(ix, iy); d = pInput->asDouble(x, y); Diff = c - d; if( Diff < 0) { Diff = 0 - Diff; } if( Diff <= Thresh ) { i = pInput->asDouble(ix, iy); Sum += ( i *( irv + irw )); n += ( irv + irw ); } } } //------------------------------------------------------ if( n > 0 ) { pResult->Set_Value(x, y, Sum / n); } } } return( true ); } saga-2.2.3/src/modules/contrib/contrib_peregro/AvWiMa1.cpp0000664000175000017500000000766112565125413024600 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: AvWiMa1.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // AvWiMa // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // AvWiMa1.cpp // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "AvWiMa1.h" //--------------------------------------------------------- CAvWiMa1::CAvWiMa1(void) { // 1. Info... Set_Name(_TL("Average With Mask 1")); Set_Author(_TL("Alessandro Perego")); Set_Description(_TL("Average With Mask 1 calculates average for cells specified by a mask grid. Cell excluded by the mask grid are NOT used in the average calculation.")); // 2. Parameters... Parameters.Add_Grid(NULL, "INPUT", _TL("Input"), _TL("This must be your input data of type grid."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "MASK", _TL("Mask Grid"), _TL("This grid indicates the cells you want calculate the average."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "RESULT", _TL("AWM1 Grid"), _TL("New grid filtered with the AvWiMa1 module"), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "V", _TL("Mask value"), _TL("Value of right cells in the Mask Grid"), PARAMETER_TYPE_Double, 1.0); Parameters.Add_Value(NULL, "RX", _TL("Radius X"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); Parameters.Add_Value(NULL, "RY", _TL("Radius Y"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); } //--------------------------------------------------------- CAvWiMa1::~CAvWiMa1(void) {} //--------------------------------------------------------- bool CAvWiMa1::On_Execute(void) { int x, y, Rx, Ry, ax, ay, bx, by, ix, iy, n; double Sum, m, im, v; CSG_Grid *pInput, *pMask, *pResult; pInput = Parameters("INPUT")->asGrid(); pMask = Parameters("MASK")->asGrid(); pResult = Parameters("RESULT")->asGrid(); v = Parameters("V")->asDouble(); Rx = Parameters("RX")->asInt(); Ry = Parameters("RY")->asInt(); //----------------------------------------------------- for(y=0; yasDouble(x, y); if( m == v) { Sum = 0.0; n = 0; ax = x - Rx; bx = x + Ry; ay = y - Ry; by = y + Ry; if( ax < 0 ) { ax = 0; } if( bx >= Get_NX() ){ bx = Get_NX() - 1; } if( ay < 0 ) { ay = 0; } if( by >= Get_NY() ){ by = Get_NY() - 1; } for(iy=ay; iy<=by; iy++) { for(ix=ax; ix<=bx; ix++) { im = pMask->asDouble(ix, iy); if( im == v ) { Sum += pInput->asDouble(ix, iy); n++; } } } if( n > 0 ) { pResult->Set_Value(x, y, Sum/n); } } else { pResult->Set_Value(x, y, pInput->asDouble(x, y)); } } } return( true ); } saga-2.2.3/src/modules/contrib/contrib_peregro/A1WiTh.cpp0000664000175000017500000001015112565125413024414 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: A1WiTh.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // A1WiTh // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // A1WiTh.cpp // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "A1WiTh.h" //--------------------------------------------------------- CA1WiTh::CA1WiTh(void) { // 1. Info... Set_Name(_TL("Average With Thereshold 1")); Set_Author(_TL("Alessandro Perego")); Set_Description(_TL("Average With Thereshold for Grids calculates average in X and Y distances unsing only the values that differ form central pixel less than a specified threshold. It's useful to remove noise whit a known maximum reducing the loss of informations")); // 2. Parameters... Parameters.Add_Grid(NULL, "INPUT", _TL("Input"), _TL("This must be your input data of type grid."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "RESULT", _TL("AWT Grid"), _TL("New grid filtered with the A1WiTh module"), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "RX", _TL("Radius X"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); Parameters.Add_Value(NULL, "RY", _TL("Radius Y"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); Parameters.Add_Value(NULL, "THRESH", _TL("Threshold"), _TL("The values in the specified radius is used in the average calculation only if its difference with the central value is lesser or equal to this threshold."), PARAMETER_TYPE_Double, 2.0); } //--------------------------------------------------------- CA1WiTh::~CA1WiTh(void) {} //--------------------------------------------------------- bool CA1WiTh::On_Execute(void) { int x, y, Rx, Ry, ax, ay, bx, by, ix, iy, n; double Thresh, Diff, Sum, c, d; CSG_Grid *pInput, *pResult; pInput = Parameters("INPUT")->asGrid(); pResult = Parameters("RESULT")->asGrid(); Rx = Parameters("RX")->asInt(); Ry = Parameters("RY")->asInt(); Thresh = Parameters("THRESH")->asDouble(); //----------------------------------------------------- for(y=0; y= Get_NX() ){ bx = Get_NX() - 1; } if( ay < 0 ) { ay = 0; } if( by >= Get_NY() ){ by = Get_NY() - 1; } //----------------------------------------------------- for(iy=ay; iy<=by; iy++) { for(ix=ax; ix<=bx; ix++) { c = pInput->asDouble(ix, iy); d = pInput->asDouble(x, y); Diff = c - d; if( Diff < 0) { Diff = 0 - Diff; } if( Diff <= Thresh ) { Sum += pInput->asDouble(ix, iy); n++; } } } //------------------------------------------------------ if( n > 0 ) { pResult->Set_Value(x, y, Sum / n); } } } return( true ); } saga-2.2.3/src/modules/contrib/contrib_peregro/A1WiTh.h0000664000175000017500000000444412565125413024071 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: A1WiTh.h 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // A1WiTh // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // A1WiTh.h // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__A1WiTh_H #define HEADER_INCLUDED__A1WiTh_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CA1WiTh : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CA1WiTh(void); // constructor virtual ~CA1WiTh(void); // destructor virtual CSG_String Get_MenuPath (void) { return( _TL("Averages") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__A1WiTh_H saga-2.2.3/src/modules/contrib/contrib_peregro/AvWiMa2.h0000664000175000017500000000445312565125413024242 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: AvWiMa2.h 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // AvWiMa // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // AvWiMa2.h // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__AvWiMa2_H #define HEADER_INCLUDED__AvWiMa2_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CAvWiMa2 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CAvWiMa2(void); // constructor virtual ~CAvWiMa2(void); // destructor virtual CSG_String Get_MenuPath (void) { return( _TL("Averages") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__AvWiMa2_H saga-2.2.3/src/modules/contrib/contrib_peregro/destriping1.h0000664000175000017500000000437212565125413025265 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: destriping1.h 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // destriping // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // destriping1.h // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__destriping1_H #define HEADER_INCLUDED__destriping1_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class Cdestriping1 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// Cdestriping1(void); // constructor virtual ~Cdestriping1(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__destriping1_H saga-2.2.3/src/modules/contrib/contrib_peregro/directional1.h0000664000175000017500000000451612565125413025412 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: directional1.h 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // directional1 // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // directional1.h // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__directional1_H #define HEADER_INCLUDED__directional1_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class Cdirectional1 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// Cdirectional1(void); // constructor virtual ~Cdirectional1(void); // destructor virtual CSG_String Get_MenuPath (void) { return( _TL("Averages") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__directional1_H saga-2.2.3/src/modules/contrib/contrib_peregro/AvWiMa2.cpp0000664000175000017500000000757012565125413024600 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: AvWiMa2.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // AvWiMa // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // AvWiMa2.cpp // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "AvWiMa2.h" //--------------------------------------------------------- CAvWiMa2::CAvWiMa2(void) { // 1. Info... Set_Name(_TL("Average With Mask 2")); Set_Author(_TL("Alessandro Perego")); Set_Description(_TL("Average With Mask 2 calculates average for cells specified by a mask grid. However cell excluded by the mask grid are used in the average calculation for right pixels.")); // 2. Parameters... Parameters.Add_Grid(NULL, "INPUT", _TL("Input"), _TL("This must be your input data of type grid."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "MASK", _TL("Mask Grid"), _TL("This grid indicates the cells you want calculate the average."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "RESULT", _TL("AWM2 Grid"), _TL("New grid filtered with the AvWiMa2 module"), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "V", _TL("Mask value"), _TL("Value of right cells in the Mask Grid"), PARAMETER_TYPE_Double, 1.0); Parameters.Add_Value(NULL, "RX", _TL("Radius X"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); Parameters.Add_Value(NULL, "RY", _TL("Radius Y"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); } //--------------------------------------------------------- CAvWiMa2::~CAvWiMa2(void) {} //--------------------------------------------------------- bool CAvWiMa2::On_Execute(void) { int x, y, Rx, Ry, ax, ay, bx, by, ix, iy, n; double Sum, m, v; CSG_Grid *pInput, *pMask, *pResult; pInput = Parameters("INPUT")->asGrid(); pMask = Parameters("MASK")->asGrid(); pResult = Parameters("RESULT")->asGrid(); v = Parameters("V")->asDouble(); Rx = Parameters("RX")->asInt(); Ry = Parameters("RY")->asInt(); //----------------------------------------------------- for(y=0; yasDouble(x, y); if( m == v) { Sum = 0.0; n = 0; ax = x - Rx; bx = x + Ry; ay = y - Ry; by = y + Ry; if( ax < 0 ) { ax = 0; } if( bx >= Get_NX() ){ bx = Get_NX() - 1; } if( ay < 0 ) { ay = 0; } if( by >= Get_NY() ){ by = Get_NY() - 1; } for(iy=ay; iy<=by; iy++) { for(ix=ax; ix<=bx; ix++) { Sum += pInput->asDouble(ix, iy); n++; } } if( n > 0 ) { pResult->Set_Value(x, y, Sum/n); } } else { pResult->Set_Value(x, y, pInput->asDouble(x, y)); } } } return( true ); } saga-2.2.3/src/modules/contrib/contrib_peregro/A3WiTh.h0000664000175000017500000000444412565125413024073 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: A3WiTh.h 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // A3WiTh // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // A3WiTh.h // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__A3WiTh_H #define HEADER_INCLUDED__A3WiTh_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CA3WiTh : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CA3WiTh(void); // constructor virtual ~CA3WiTh(void); // destructor virtual CSG_String Get_MenuPath (void) { return( _TL("Averages") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__A3WiTh_H saga-2.2.3/src/modules/contrib/contrib_peregro/Makefile.in0000664000175000017500000005572712622651157024745 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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_peregro DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libcontrib_perego_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libcontrib_perego_la_OBJECTS = A1WiTh.lo A2WiTh.lo A3WiTh.lo \ AvWiMa1.lo AvWiMa2.lo destriping1.lo destriping2.lo \ directional1.lo MLB_Interface.lo libcontrib_perego_la_OBJECTS = $(am_libcontrib_perego_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libcontrib_perego_la_SOURCES) DIST_SOURCES = $(libcontrib_perego_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libcontrib_perego.la libcontrib_perego_la_SOURCES = \ A1WiTh.cpp\ A2WiTh.cpp\ A3WiTh.cpp\ AvWiMa1.cpp\ AvWiMa2.cpp\ destriping1.cpp\ destriping2.cpp\ directional1.cpp\ MLB_Interface.cpp\ A1WiTh.h\ A2WiTh.h\ A3WiTh.h\ AvWiMa1.h\ AvWiMa2.h\ destriping1.h\ destriping2.h\ directional1.h\ MLB_Interface.h libcontrib_perego_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) --foreign src/modules/contrib/contrib_peregro/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/contrib/contrib_peregro/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libcontrib_perego.la: $(libcontrib_perego_la_OBJECTS) $(libcontrib_perego_la_DEPENDENCIES) $(EXTRA_libcontrib_perego_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libcontrib_perego_la_OBJECTS) $(libcontrib_perego_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/A1WiTh.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/A2WiTh.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/A3WiTh.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AvWiMa1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AvWiMa2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/destriping1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/destriping2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/directional1.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/contrib/contrib_peregro/destriping2.h0000664000175000017500000000437212565125413025266 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: destriping2.h 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // destriping // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // destriping2.h // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__destriping2_H #define HEADER_INCLUDED__destriping2_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class Cdestriping2 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// Cdestriping2(void); // constructor virtual ~Cdestriping2(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__destriping2_H saga-2.2.3/src/modules/contrib/contrib_peregro/destriping1.cpp0000664000175000017500000001600212565125413025611 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: destriping1.cpp 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // destriping // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // destriping1.cpp // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "destriping1.h" //--------------------------------------------------------- Cdestriping1::Cdestriping1(void) { // 1. Info... Set_Name(_TL("Destriping")); Set_Author(_TL("Alessandro Perego")); Set_Description(_TW( "Destriping filter removes straight parallel stripes in raster data. " "It uses two low-pass filters elongated in the stripes direction; " "the first one is 1 pixel unit wide while the second one is wide as the striping wavelength. " "Their difference is the striping error which is removed from the original data to obtain the destriped DEM. " "This method is equivalent to that proposed by Oimoen (2000). " "\n" "\nReferences:\n" "- Oimoen, M.J. (2000): An Effective Filter For Removal Of Production Artifacts. " "In U.S. Geological Survey 7.5-Minute Digital Elevation Models. " "Proceedings of the Fourteenth International Conference on Applied Geologic Remote Sensing, " "6-8 November, Las Vegas, NV.\n" "\n" "- Peregro, A. (2009): SRTM DEM destriping with SAGA GIS: consequences on drainage network extraction. " "online.\n" )); // 2. Parameters... Parameters.Add_Grid(NULL, "INPUT", _TL("Input"), _TL("This must be your input data of type grid."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "RESULT3", _TL("Destriped Grid"), _TL("New grid filtered with the destriping1 module"), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "RESULT1", _TL("Low-pass 1"), _TL("Step 1: low-pass of stripe"), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "RESULT2", _TL("Low-pass 2"), _TL("Step 2: low-pass between stripe and its surruondings"), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "ANG", _TL("Angle (in degrees)"), _TL("0 is horizontal, 90 is vertical."), PARAMETER_TYPE_Double, 0.0); Parameters.Add_Value(NULL, "R", _TL("Radius"), _TL(""), PARAMETER_TYPE_Double, 10); Parameters.Add_Value(NULL, "D", _TL("Stripes distance"), _TL(""), PARAMETER_TYPE_Double, 2); } //--------------------------------------------------------- Cdestriping1::~Cdestriping1(void) {} //--------------------------------------------------------- bool Cdestriping1::On_Execute(void) { int x, y, r, dxmax, dymax, ix, ax, ay, bx, by, iy, iv, iw, n1, n2; double d, ang, a, si, si2, co, co2, Sum1, Sum2; CSG_Grid *pInput, *pRes1, *pRes2, *pRes3; pInput = Parameters("INPUT")->asGrid(); pRes1 = Parameters("RESULT1")->asGrid(); pRes2 = Parameters("RESULT2")->asGrid(); pRes3 = Parameters("RESULT3")->asGrid(); ang = Parameters("ANG")->asDouble(); r = Parameters("R")->asInt(); d = Parameters("D")->asDouble(); //----------------------------------------------------- a = ang * 6.283185307179586 / 360; si = sin(a); co = cos(a); si2 = si * si; co2 = co * co; dxmax = (int)((r*sqrt(co2))+(d/2*sqrt(si2))); dymax = (int)((r*sqrt(si2))+(d/2*sqrt(co2))); if(si2 >= co2) { double cosi, si05, dsi, iwcosi, ivmin1, ivmax1, ivmin2, ivmax2; cosi = co / si; si05 = sqrt( (0.5/si)*(0.5/si) ); dsi = sqrt( (d/2/si)*(d/2/si) ); for(y=0; y= Get_NX() ) { bx = Get_NX() - 1; } if( (ay = y - dymax) < 0 ) { ay = 0; } if( (by = y + dymax) >= Get_NY() ) { by = Get_NY() - 1; } //----------------------------------------------------- for(iy=ay; iy<=by; iy++) { iw = y - iy; iwcosi = iw * cosi; ivmin1 = iwcosi - si05; ivmax1 = iwcosi + si05; ivmin2 = iwcosi - dsi; ivmax2 = iwcosi + dsi; for(ix=ax; ix<=bx; ix++) { iv = x - ix; if( iv >= ivmin1 && iv <= ivmax1) { Sum1 += pInput->asDouble(ix, iy); n1++; } if( iv >= ivmin2 && iv <= ivmax2) { Sum2 += pInput->asDouble(ix, iy); n2++; } } } if( n1 > 0 && n2 > 0 ) { pRes1->Set_Value(x, y, Sum1/n1); pRes2->Set_Value(x, y, Sum2/n2); pRes3->Set_Value(x, y, (Sum1/n1)-(Sum2/n2)+pInput->asDouble(x, y)); } } } } if(si2 < co2) { double sico, co05, dco, ivsico, iwmin1, iwmax1, iwmin2, iwmax2; sico = si / co; co05 = sqrt( (0.5/co)*(0.5/co) ); dco = sqrt( (d/2/co)*(d/2/co) ); for(y=0; y= Get_NX() ) { bx = Get_NX() - 1; } if( (ay = y - dymax) < 0 ) { ay = 0; } if( (by = y + dymax) >= Get_NY() ) { by = Get_NY() - 1; } //----------------------------------------------------- for(ix=ax; ix<=bx; ix++) { iv = x - ix; ivsico = iv * sico; iwmin1 = ivsico - co05; iwmax1 = ivsico + co05; iwmin2 = ivsico - dco; iwmax2 = ivsico + dco; for(iy=ay; iy<=by; iy++) { iw = y - iy; if( iw >= iwmin1 && iw <= iwmax1) { Sum1 += pInput->asDouble(ix, iy); n1++; } if( iw >= iwmin2 && iw <= iwmax2) { Sum2 += pInput->asDouble(ix, iy); n2++; } } } if( n1 > 0 && n2 > 0 ) { pRes1->Set_Value(x, y, Sum1/n1); pRes2->Set_Value(x, y, Sum2/n2); pRes3->Set_Value(x, y, (Sum2/n2)-(Sum1/n1)+pInput->asDouble(x, y)); } } } } return( true ); } saga-2.2.3/src/modules/contrib/contrib_peregro/AvWiMa1.h0000664000175000017500000000445312565125413024241 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: AvWiMa1.h 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // AvWiMa // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // AvWiMa1.h // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__AvWiMa1_H #define HEADER_INCLUDED__AvWiMa1_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CAvWiMa1 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CAvWiMa1(void); // constructor virtual ~CAvWiMa1(void); // destructor virtual CSG_String Get_MenuPath (void) { return( _TL("Averages") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__AvWiMa1_H saga-2.2.3/src/modules/contrib/contrib_peregro/A2WiTh.h0000664000175000017500000000444412565125413024072 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: A2WiTh.h 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // A2WiTh // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // A2WiTh.h // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__A2WiTh_H #define HEADER_INCLUDED__A2WiTh_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CA2WiTh : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CA2WiTh(void); // constructor virtual ~CA2WiTh(void); // destructor virtual CSG_String Get_MenuPath (void) { return( _TL("Averages") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__A2WiTh_H saga-2.2.3/src/modules/contrib/contrib_peregro/destriping2.cpp0000664000175000017500000002120612565125413025614 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: destriping2.cpp 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // destriping // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // destriping2.cpp // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "destriping2.h" //--------------------------------------------------------- Cdestriping2::Cdestriping2(void) { // 1. Info... Set_Name(_TL("Destriping with Mask")); Set_Author(_TL("Alessandro Perego")); Set_Description(_TW( "Destriping filter removes straight parallel stripes in raster data. " "It uses two low-pass filters elongated in the stripes direction; " "the first one is 1 pixel unit wide while the second one is wide as the striping wavelength. " "Their difference is the striping error which is removed from the original data to obtain the destriped DEM. " "This method is equivalent to that proposed by Oimoen (2000). " "With destriping 2 you can choose a range of value (min-max) from the input grid " "and a range of value (Mask min - Mask max) from a mask grid to select the target cells. " "\n" "\nReferences:\n" "- Oimoen, M.J. (2000): An Effective Filter For Removal Of Production Artifacts. " "In U.S. Geological Survey 7.5-Minute Digital Elevation Models. " "Proceedings of the Fourteenth International Conference on Applied Geologic Remote Sensing, " "6-8 November, Las Vegas, NV.\n" "\n" "- Peregro, A. (2009): SRTM DEM destriping with SAGA GIS: consequences on drainage network extraction. " "online.\n" )); // 2. Parameters... Parameters.Add_Grid(NULL, "INPUT", _TL("Input"), _TL("This must be your input data of type grid."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "MASK", _TL("Mask Grid"), _TL("This grid is used to select cells."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "RESULT3", _TL("Destriped Grid"), _TL("New grid filtered with the destriping2 module"), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "RESULT1", _TL("Low-pass 1"), _TL("Step 1: low-pass of stripe"), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "RESULT2", _TL("Low-pass 2"), _TL("Step 2: low-pass between stripe and its surruondings"), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "ANG", _TL("Angle (in degrees)"), _TL("0 is horizontal, 90 is vertical."), PARAMETER_TYPE_Double, 0.0); Parameters.Add_Value(NULL, "R", _TL("Radius"), _TL(""), PARAMETER_TYPE_Double, 20); Parameters.Add_Value(NULL, "D", _TL("Stripes distance"), _TL(""), PARAMETER_TYPE_Double, 2); Parameters.Add_Value(NULL, "MIN", _TL("Min"), _TL(""), PARAMETER_TYPE_Double, -10); Parameters.Add_Value(NULL, "MAX", _TL("Max"), _TL(""), PARAMETER_TYPE_Double, 10); Parameters.Add_Value(NULL, "MMIN", _TL("Mask Min"), _TL(""), PARAMETER_TYPE_Double, -10000); Parameters.Add_Value(NULL, "MMAX", _TL("Mask Max"), _TL(""), PARAMETER_TYPE_Double, 10000); } //--------------------------------------------------------- Cdestriping2::~Cdestriping2(void) {} //--------------------------------------------------------- bool Cdestriping2::On_Execute(void) { int x, y, r, dxmax, dymax, ix, ax, ay, bx, by, iy, iv, iw, n1, n2; double z, mz, iz, imz, d, ang, a, si, si2, co, co2, Sum1, Sum2, min, max, mmin, mmax; CSG_Grid *pInput, *pMask, *pRes1, *pRes2, *pRes3; pInput = Parameters("INPUT")->asGrid(); pMask = Parameters("MASK")->asGrid(); pRes1 = Parameters("RESULT1")->asGrid(); pRes2 = Parameters("RESULT2")->asGrid(); pRes3 = Parameters("RESULT3")->asGrid(); ang = Parameters("ANG")->asDouble(); r = Parameters("R")->asInt(); d = Parameters("D")->asDouble(); min = Parameters("MIN")->asDouble(); max = Parameters("MAX")->asDouble(); mmin = Parameters("MMIN")->asDouble(); mmax = Parameters("MMAX")->asDouble(); //----------------------------------------------------- a = ang * 6.283185307179586 / 360; si = sin(a); co = cos(a); si2 = si * si; co2 = co * co; dxmax = (int)((r*sqrt(co2))+(d/2*sqrt(si2))); dymax = (int)((r*sqrt(si2))+(d/2*sqrt(co2))); if(si2 >= co2) { double cosi, si05, dsi, iwcosi, ivmin1, ivmax1, ivmin2, ivmax2; cosi = co / si; si05 = sqrt( (0.5/si)*(0.5/si) ); dsi = sqrt( (d/2/si)*(d/2/si) ); for(y=0; yasDouble(x, y); mz=pMask->asDouble(x, y); if( z>=min && z<=max && mz>=mmin && mz<=mmax) { Sum1 = 0.0; n1 = 0; Sum2 = 0.0; n2 = 0; //---------------------------------------------------- if( (ax = x - dxmax) < 0 ) { ax = 0; } if( (bx = x + dxmax) >= Get_NX() ) { bx = Get_NX() - 1; } if( (ay = y - dymax) < 0 ) { ay = 0; } if( (by = y + dymax) >= Get_NY() ) { by = Get_NY() - 1; } //----------------------------------------------------- for(iy=ay; iy<=by; iy++) { iw = y - iy; iwcosi = iw * cosi; ivmin1 = iwcosi - si05; ivmax1 = iwcosi + si05; ivmin2 = iwcosi - dsi; ivmax2 = iwcosi + dsi; for(ix=ax; ix<=bx; ix++) { iz = pInput->asDouble(ix, iy); imz=pMask->asDouble(ix, iy); if( iz>=min && iz<=max && imz>=mmin && imz<=mmax) { iv = x - ix; if( iv >= ivmin1 && iv <= ivmax1) { Sum1 += iz; n1++; } if( iv >= ivmin2 && iv <= ivmax2) { Sum2 += iz; n2++; } } } } if( n1 > 0 && n2 > 0 ) { pRes1->Set_Value(x, y, Sum1/n1); pRes2->Set_Value(x, y, Sum2/n2); pRes3->Set_Value(x, y, (Sum1/n1)-(Sum2/n2)+z); } } else { pRes1->Set_Value(x, y, z); pRes2->Set_Value(x, y, z); pRes3->Set_Value(x, y, z); } } } } if(si2 < co2) { double sico, co05, dco, ivsico, iwmin1, iwmax1, iwmin2, iwmax2; sico = si / co; co05 = sqrt( (0.5/co)*(0.5/co) ); dco = sqrt( (d/2/co)*(d/2/co) ); for(y=0; yasDouble(x, y); mz=pMask->asDouble(x, y); if( z>=min && z<=max && mz>=mmin && mz<=mmax) { Sum1 = 0.0; n1 = 0; Sum2 = 0.0; n2 = 0; //---------------------------------------------------- if( (ax = x - dxmax) < 0 ) { ax = 0; } if( (bx = x + dxmax) >= Get_NX() ) { bx = Get_NX() - 1; } if( (ay = y - dymax) < 0 ) { ay = 0; } if( (by = y + dymax) >= Get_NY() ) { by = Get_NY() - 1; } //----------------------------------------------------- for(ix=ax; ix<=bx; ix++) { iv = x - ix; ivsico = iv * sico; iwmin1 = ivsico - co05; iwmax1 = ivsico + co05; iwmin2 = ivsico - dco; iwmax2 = ivsico + dco; for(iy=ay; iy<=by; iy++) { iz = pInput->asDouble(ix, iy); imz=pMask->asDouble(ix, iy); if( iz>=min && iz<=max && imz>=mmin && imz<=mmax) { iw = y - iy; if( iw >= iwmin1 && iw <= iwmax1) { Sum1 += iz; n1++; } if( iw >= iwmin2 && iw <= iwmax2) { Sum2 += iz; n2++; } } } } if( n1 > 0 && n2 > 0 ) { pRes1->Set_Value(x, y, Sum1/n1); pRes2->Set_Value(x, y, Sum2/n2); pRes3->Set_Value(x, y, (Sum2/n2)-(Sum1/n1)+pInput->asDouble(x, y)); } } else { pRes1->Set_Value(x, y, z); pRes2->Set_Value(x, y, z); pRes3->Set_Value(x, y, z); } } } } return( true ); } saga-2.2.3/src/modules/contrib/contrib_peregro/MLB_Interface.cpp0000664000175000017500000000724012565125413025756 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1514 2012-11-06 09:47:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // contrib_a_perego // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Filter (Perego 2009)") ); case MLB_INFO_Category: return( _TL("Grid") ); case MLB_INFO_Author: return( _TL("Alessandro Perego") ); case MLB_INFO_Description: return( _TW( "Contributions from Alessandro Perego. Go to " "" "www.webalice.it/alper78/saga_mod for further information." )); 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 "A1WiTh.h" #include "A2WiTh.h" #include "A3WiTh.h" #include "AvWiMa1.h" #include "AvWiMa2.h" #include "destriping1.h" #include "destriping2.h" #include "directional1.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CA1WiTh ); case 1: return( new CA2WiTh ); case 2: return( new CA3WiTh ); case 3: return( new CAvWiMa1 ); case 4: return( new CAvWiMa2 ); case 5: return( new Cdestriping1 ); case 6: return( new Cdestriping2 ); case 7: return( new Cdirectional1 ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/contrib/contrib_peregro/Makefile.am0000664000175000017500000000144512565125413024715 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libcontrib_perego.la libcontrib_perego_la_SOURCES =\ A1WiTh.cpp\ A2WiTh.cpp\ A3WiTh.cpp\ AvWiMa1.cpp\ AvWiMa2.cpp\ destriping1.cpp\ destriping2.cpp\ directional1.cpp\ MLB_Interface.cpp\ A1WiTh.h\ A2WiTh.h\ A3WiTh.h\ AvWiMa1.h\ AvWiMa2.h\ destriping1.h\ destriping2.h\ directional1.h\ MLB_Interface.h libcontrib_perego_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/contrib/contrib_peregro/MLB_Interface.h0000664000175000017500000000163612565125413025426 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__contrib_a_perego_H #define HEADER_INCLUDED__contrib_a_perego_H //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__contrib_a_perego_H saga-2.2.3/src/modules/contrib/contrib_peregro/A3WiTh.cpp0000664000175000017500000001052412565125413024422 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: A3WiTh.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // Module: // // A3WiTh // // // // for SAGA // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // A3WiTh.cpp // // // // // //-------------------------------------------------------// // // // // // by Alessandro Perego (Italy) // // // // e-mail: alper78@alice.it // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "A3WiTh.h" //--------------------------------------------------------- CA3WiTh::CA3WiTh(void) { // 1. Info... Set_Name(_TL("Average With Thereshold 3")); Set_Author(_TL("Alessandro Perego")); Set_Description(_TL("Average 3 With Thereshold for Grids calculates average in X and Y distances unsing only the values that differ form central pixel less than a specified threshold. Each value has a weight which is inversely proportional to the distance (method 2).")); // 2. Parameters... Parameters.Add_Grid(NULL, "INPUT", _TL("Input"), _TL("This must be your input data of type grid."), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "RESULT", _TL("AWT Grid"), _TL("New grid filtered with the A3WiTh module"), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "RX", _TL("Radius X"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); Parameters.Add_Value(NULL, "RY", _TL("Radius Y"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); Parameters.Add_Value(NULL, "THRESH", _TL("Threshold"), _TL("The values in the specified radius is used in the average calculation only if its difference with the central value is lesser or equal to this threshold."), PARAMETER_TYPE_Double, 2.0); } //--------------------------------------------------------- CA3WiTh::~CA3WiTh(void) {} //--------------------------------------------------------- bool CA3WiTh::On_Execute(void) { int x, y, Rx, Ry, ax, ay, bx, by, ix, iy, iv, iw, irv, irw, n; double Thresh, Diff, Sum, c, d, i; CSG_Grid *pInput, *pResult; pInput = Parameters("INPUT")->asGrid(); pResult = Parameters("RESULT")->asGrid(); Rx = Parameters("RX")->asInt(); Ry = Parameters("RY")->asInt(); Thresh = Parameters("THRESH")->asDouble(); //----------------------------------------------------- for(y=0; y= Get_NX() ) { bx = Get_NX() - 1; } if( (ay = y - Ry) < 0 ) { ay = 0; } if( (by = y + Ry) >= Get_NY() ) { by = Get_NY() - 1; } //----------------------------------------------------- for(iy=ay; iy<=by; iy++) { for(ix=ax; ix<=bx; ix++) { iv = x - ix; if( iv >= 0) { irv = Rx - iv + 1; } else { irv = Rx + iv + 1; } iw = y - iy; if( iw >= 0) { irw = Ry - iw + 1; } else { irw = Ry + iw + 1; } c = pInput->asDouble(ix, iy); d = pInput->asDouble(x, y); Diff = c - d; if( Diff < 0) { Diff = 0 - Diff; } if( Diff <= Thresh ) { i = pInput->asDouble(ix, iy); Sum += ( i * irv * irw ); n += ( irv * irw ); } } } //------------------------------------------------------ if( n > 0 ) { pResult->Set_Value(x, y, Sum / n); } } } return( true ); } saga-2.2.3/src/modules/contrib/Makefile.in0000664000175000017500000004552512622651157021555 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 = contrib_peregro 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) --foreign src/modules/contrib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/contrib/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/contrib/Makefile.am0000664000175000017500000000003312565125413021522 0ustar00oconradoconrad00000000000000SUBDIRS = contrib_peregro saga-2.2.3/src/modules/shapes/0000775000175000017500000000000012634325746017325 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/shapes/Makefile.in0000664000175000017500000004562612622651170021375 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 = shapes_tools shapes_polygons shapes_points shapes_lines shapes_grid shapes_transect 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) --foreign src/modules/shapes/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/shapes/shapes_lines/0000775000175000017500000000000012634325746022002 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/shapes/shapes_lines/line_properties.h0000664000175000017500000001035512565125410025347 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_properties.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_properties.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_properties_H #define HEADER_INCLUDED__line_properties_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Properties : public CSG_Module { public: CLine_Properties(void); protected: virtual bool On_Execute(void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_properties_H saga-2.2.3/src/modules/shapes/shapes_lines/line_simplification.cpp0000664000175000017500000002344512565125410026524 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_simplification.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_simplification.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_simplification.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CStack : public CSG_Stack { public: CStack(void) : CSG_Stack(2 * sizeof(int)) {} bool Push (int iAnchor, int iFloater) { int *Record = (int *)Get_Record_Push(); if( Record ) { Record[0] = iAnchor; Record[1] = iFloater; return( true ); } return( false ); } bool Pop (int &iAnchor, int &iFloater) { int *Record = (int *)Get_Record_Pop(); if( Record ) { iAnchor = Record[0]; iFloater = Record[1]; return( true ); } return( false ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Simplification::CLine_Simplification(void) { //----------------------------------------------------- Set_Name (_TL("Line Simplification")); Set_Author (SG_T("O. Conrad (c) 2010")); Set_Description (_TW( "Line simplification implementing the Ramer-Douglas-Peucker algorithm.\n" "\n" "Refererences:\n" "- Ramer, U. (1972): An iterative procedure for the polygonal approximation of plane curves. Computer Graphics and Image Processing, 1(3), 244-256\n" "- Douglas, D., Peucker, T. (1973): Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. The Canadian Cartographer 10(2), 112-122\n" "\n" "- Polyline Reduction source code at mappinghacks.com\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL("Line or polygon shapefile to simplify."), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Simplified Lines"), _TL("If not set points will be removed from the input data set."), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "TOLERANCE" , _TL("Tolerance"), _TL("Maximum deviation allowed between original and simplified curve [map units]."), PARAMETER_TYPE_Double, 1.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Simplification::On_Execute(void) { CSG_Shapes *pLines = Parameters("LINES")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() <= 0 ) { Error_Set(_TL("invalid or empty shapes layer")); return( false ); } if( pLines->Get_Type() != SHAPE_TYPE_Line && pLines->Get_Type() != SHAPE_TYPE_Polygon ) { Error_Set(_TL("line simplification can only be applied to lines and polygons")); return( false ); } if( Parameters("OUTPUT")->asShapes() && Parameters("OUTPUT")->asShapes() != pLines ) { pLines = Parameters("OUTPUT")->asShapes(); pLines->Create(*Parameters("LINES")->asShapes()); } //----------------------------------------------------- CSG_Array Keep(sizeof(bool)); m_Tolerance = Parameters("TOLERANCE")->asDouble(); int nTotal = 0; int nRemoved = 0; for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { CSG_Shape *pLine = pLines->Get_Shape(iLine); for(int iPart=0; iPartGet_Part_Count(); iPart++) { nTotal += pLine->Get_Point_Count(iPart); Keep.Set_Array(pLine->Get_Point_Count(iPart), false); if( Simplify(pLine, iPart, (bool *)Keep.Get_Array()) ) { for(int iPoint=pLine->Get_Point_Count(iPart)-1; iPoint>=0; iPoint--) { if( !((bool *)Keep.Get_Array())[iPoint] ) { pLine->Del_Point(iPoint, iPart); nRemoved ++; } } } } } Message_Add(CSG_String::Format(SG_T("\n%s: %0.2f%% (%d / %d)"), _TL("Reduction"), 100.0 * nRemoved / (double)nTotal, nRemoved, nTotal), false); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Simplification::Simplify(CSG_Shape *pLine, int iPart, bool *Keep) { int iVertexMax, iVertex, iAnchor, iFloater; double dVertexMax, dVertex, dLength, dProjScalar; TSG_Point Anchor, Floater, Vertex, vAnchor, vVertex; CStack Stack; memset(Keep, 0, sizeof(bool) * pLine->Get_Point_Count(iPart)); Stack.Push(0, pLine->Get_Point_Count(iPart) - 1); while( Stack.Pop(iAnchor, iFloater) && Process_Get_Okay() ) { Anchor = pLine->Get_Point(iAnchor , iPart); Floater = pLine->Get_Point(iFloater, iPart); while( Anchor.x == Floater.x && Anchor.y == Floater.y ) { if( iAnchor >= iFloater - 1 ) { return( false ); } Keep[iFloater--] = iAnchor == 0 && iFloater == pLine->Get_Point_Count(iPart) - 1; Floater = pLine->Get_Point(iFloater, iPart); } vAnchor.x = Floater.x - Anchor.x; vAnchor.y = Floater.y - Anchor.y; dLength = SG_Get_Length(vAnchor.x, vAnchor.y); vAnchor.x = vAnchor.x / dLength; vAnchor.y = vAnchor.y / dLength; for(iVertex=iVertexMax=iAnchor+1, dVertexMax=0.0; iVertexGet_Point(iVertex, iPart); vVertex.x = Vertex.x - Anchor.x; vVertex.y = Vertex.y - Anchor.y; dLength = SG_Get_Length(Vertex.x, Vertex.y); dProjScalar = vVertex.x * vAnchor.x + vVertex.y * vAnchor.y; //dot product: if( dProjScalar < 0.0 ) { dVertex = dLength; } else { vVertex.x = Vertex.x - Floater.x; vVertex.y = Vertex.y - Floater.y; dLength = SG_Get_Length(vVertex.x, vVertex.y); dProjScalar = vVertex.x * (-vAnchor.x) + vVertex.y * (-vAnchor.y); //dot product: if( dProjScalar < 0.0 ) { dVertex = dLength; } else //calculate perpendicular distance to line (pythagorean theorem): { dVertex = sqrt(fabs(dLength*dLength - dProjScalar*dProjScalar)); } } if( dVertexMax < dVertex ) { dVertexMax = dVertex; iVertexMax = iVertex; } } if( dVertexMax <= m_Tolerance ) { Keep[iAnchor] = true; Keep[iFloater] = true; } else { Stack.Push(iAnchor , iVertexMax); Stack.Push(iVertexMax, iFloater ); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_lines/Lines_From_Points.h0000664000175000017500000001071112565125410025531 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Lines_From_Points.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // Lines_From_Points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Lines_From_Points_H #define HEADER_INCLUDED__Lines_From_Points_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLines_From_Points : public CSG_Module { public: CLines_From_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Lines_From_Points_H saga-2.2.3/src/modules/shapes/shapes_lines/line_polygon_intersection.h0000664000175000017500000001077112565125410027432 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_polygon_intersection.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_polygon_intersection.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_polygon_intersection_H #define HEADER_INCLUDED__line_polygon_intersection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Polygon_Intersection : public CSG_Module { public: CLine_Polygon_Intersection(void); protected: virtual bool On_Execute (void); private: bool Get_Intersection (CSG_Shape_Polygon *pPolygon, CSG_Shapes *pLines, CSG_Shapes &New_Lines); TSG_Point Get_Intersection (CSG_Shape_Polygon *pPolygon, const TSG_Point &a, const TSG_Point &b); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_polygon_intersection_H saga-2.2.3/src/modules/shapes/shapes_lines/line_split_with_lines.cpp0000664000175000017500000002743112577724054027105 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_split_with_lines.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_split_with_lines.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_split_with_lines.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Split_with_Lines::CLine_Split_with_Lines(void) { //----------------------------------------------------- Set_Name (_TL("Split Lines with Lines")); Set_Author (SG_T("O. Conrad (c) 2014")); Set_Description (_TW( "Split Lines with Lines." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "SPLIT" , _TL("Split Features"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "INTERSECT" , _TL("Intersection"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("polylines"), _TL("separate lines") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Split_with_Lines::On_Execute(void) { CSG_Shapes *pLines, *pSplit, *pIntersect; pLines = Parameters("LINES" )->asShapes(); pSplit = Parameters("SPLIT" )->asShapes(); pIntersect = Parameters("INTERSECT")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() < 1 || !pSplit->is_Valid() || pSplit->Get_Count() < 1 || pLines->Get_Extent().Intersects(pSplit->Get_Extent()) == INTERSECTION_None ) { Error_Set(_TL("no lines for splitting")); return( false ); } //-------------------------------------------------------- pIntersect->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pLines->Get_Name(), _TL("Splitted"), pSplit->Get_Name()), pLines ); //-------------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { CSG_Shape *pLine = pIntersect->Add_Shape(pLines->Get_Shape(iLine), SHAPE_COPY); for(int iSplit=0; iSplitGet_Count(); iSplit++) { CSG_Shape_Line *pSplit_Line = (CSG_Shape_Line *)pSplit->Get_Shape(iSplit); if( pLine->Intersects(pSplit_Line) ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pLine->Intersects(pSplit_Line->Get_Extent()) ) { Get_Intersection(pLine, pSplit_Line->Get_Part(iPart)); } } } } if( Parameters("OUTPUT")->asInt() == 1 ) { while( pLine->Get_Part_Count() > 1 ) { CSG_Shape_Line *pAdd = (CSG_Shape_Line *)pIntersect->Add_Shape(pLine, SHAPE_COPY_ATTR); // only attributes for(int iPoint=0; iPointGet_Point_Count(1); iPoint++) { pAdd->Add_Point(pLine->Get_Point(iPoint, 1)); } pLine->Del_Part(1); } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Split_with_Lines::Get_Intersection(CSG_Shape *pLine, CSG_Shape_Part *pSplit) { CSG_Shapes New(SHAPE_TYPE_Line); CSG_Shape *pNew = New.Add_Shape(); for(int iPart=0, jPart=0; iPartGet_Part_Count(); iPart++, jPart++) { TSG_Point A[2], B[2], C; pNew->Add_Point(A[0] = pLine->Get_Point(0, iPart), jPart); for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { A[1] = A[0]; A[0] = pLine->Get_Point(iPoint, iPart); B[0] = pSplit->Get_Point(0); for(int jPoint=1; jPointGet_Count(); jPoint++) { B[1] = B[0]; B[0] = pSplit->Get_Point(jPoint); if( SG_Get_Crossing(C, A[0], A[1], B[0], B[1], true) ) { pNew->Add_Point(C, jPart++); pNew->Add_Point(C, jPart); } } pNew->Add_Point(A[0], jPart); } } if( pNew->Get_Part_Count() > pLine->Get_Part_Count() ) { return( pLine->Assign(pNew, false) ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Split_at_Points::CLine_Split_at_Points(void) { //----------------------------------------------------- Set_Name (_TL("Split Lines at Points")); Set_Author (SG_T("O. Conrad (c) 2015")); Set_Description (_TW( "Split Lines at Points." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "SPLIT" , _TL("Split Features"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "INTERSECT" , _TL("Intersection"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("polylines"), _TL("separate lines") ), 1 ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Epsilon"), _TL(""), PARAMETER_TYPE_Double, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Split_at_Points::On_Execute(void) { CSG_Shapes *pLines, *pSplit, *pIntersect; pLines = Parameters("LINES" )->asShapes(); pSplit = Parameters("SPLIT" )->asShapes(); pIntersect = Parameters("INTERSECT")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() < 1 || !pSplit->is_Valid() || pSplit->Get_Count() < 1 || pLines->Get_Extent().Intersects(pSplit->Get_Extent()) == INTERSECTION_None ) { Error_Set(_TL("no lines for splitting")); return( false ); } //-------------------------------------------------------- pIntersect->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pLines->Get_Name(), _TL("Splitted"), pSplit->Get_Name()), pLines ); double Epsilon = Parameters("EPSILON")->asDouble(); //-------------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { CSG_Shape *pLine = pIntersect->Add_Shape(pLines->Get_Shape(iLine), SHAPE_COPY); CSG_Rect Extent = pLine->Get_Extent(); Extent.Inflate(Epsilon, false); for(int iSplit=0; iSplitGet_Count(); iSplit++) { TSG_Point Point = pSplit->Get_Shape(iSplit)->Get_Point(0); if( Extent.Contains(Point) ) { Get_Intersection(pLine, Point, Epsilon); } } if( Parameters("OUTPUT")->asInt() == 1 ) { while( pLine->Get_Part_Count() > 1 ) { CSG_Shape_Line *pAdd = (CSG_Shape_Line *)pIntersect->Add_Shape(pLine, SHAPE_COPY_ATTR); // only attributes for(int iPoint=0; iPointGet_Point_Count(1); iPoint++) { pAdd->Add_Point(pLine->Get_Point(iPoint, 1)); } pLine->Del_Part(1); } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Split_at_Points::Get_Intersection(CSG_Shape *pLine, TSG_Point Point, double Epsilon) { int min_iPart, min_iPoint; double min_Dist = 1.1 * Epsilon; TSG_Point min_C; for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point C, B, A = pLine->Get_Point(0, iPart); for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { B = A; A = pLine->Get_Point(iPoint, iPart); double Dist = SG_Get_Nearest_Point_On_Line(Point, A, B, C, true); if( Dist < min_Dist ) { min_Dist = Dist; min_C = C; min_iPart = iPart; min_iPoint = iPoint; } } } if( min_Dist <= Epsilon ) { int iPoint; CSG_Shape_Part *pPart = ((CSG_Shape_Line *)pLine)->Get_Part(min_iPart); pLine->Add_Point(min_C, min_iPart = pLine->Get_Part_Count()); for(iPoint=min_iPoint; iPointGet_Count(); iPoint++) { pLine->Add_Point(pPart->Get_Point(iPoint), min_iPart); } for(iPoint=pPart->Get_Count()-1; iPoint>=min_iPoint; iPoint--) { pPart->Del_Point(iPoint); } pPart->Add_Point(min_C); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_lines/Lines_From_Polygons.cpp0000664000175000017500000001434212565125410026426 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Lines_From_Polygons.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // Lines_From_Polygons.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Lines_From_Polygons.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLines_From_Polygons::CLines_From_Polygons(void) { Set_Name (_TL("Convert Polygons to Lines")); Set_Author (SG_T("O.Conrad (c) 2005")); Set_Description (_TW( "Convert polygons to lines." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLines_From_Polygons::On_Execute(void) { CSG_Shapes *pLines, *pPolygons; pPolygons = Parameters("POLYGONS") ->asShapes(); pLines = Parameters("LINES") ->asShapes(); //----------------------------------------------------- if( pPolygons->Get_Count() <= 0 ) { Error_Set(_TL("no polygons in input")); return( false ); } //----------------------------------------------------- pLines->Create(SHAPE_TYPE_Line, pPolygons->Get_Name(), pPolygons, pPolygons->Get_Vertex_Type()); for(int iPolygon=0; iPolygonGet_Count(); iPolygon++) { CSG_Shape *pPolygon = pPolygons ->Get_Shape(iPolygon); CSG_Shape *pLine = pLines ->Add_Shape(pPolygon, SHAPE_COPY_ATTR); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pLine->Add_Point(pPolygon->Get_Point(iPoint, iPart), iPart); if( pPolygons->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pLine->Set_Z(pPolygon->Get_Z(iPoint, iPart), iPoint, iPart); if( pPolygons->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pLine->Set_M(pPolygon->Get_M(iPoint, iPart), iPoint, iPart); } } } if( !CSG_Point(pPolygon->Get_Point(0, iPart)).is_Equal(pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart)) ) { pLine->Add_Point(pPolygon->Get_Point(0, iPart), iPart); if( pPolygons->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pLine->Set_Z(pPolygon->Get_Z(0, iPart), pLine->Get_Point_Count(iPart) - 1, iPart); if( pPolygons->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pLine->Set_M(pPolygon->Get_M(0, iPart), pLine->Get_Point_Count(iPart) - 1, iPart); } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_lines/line_dissolve.cpp0000664000175000017500000002220112565125410025327 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_dissolve.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_dissolve.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_dissolve.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Dissolve::CLine_Dissolve(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Line Dissolve")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Dissolves line shapes, which share the same attribute value(s)." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Table_Field( pNode , "FIELD_1" , _TL("1. Attribute"), _TL(""), false ); Parameters.Add_Table_Field( pNode , "FIELD_2" , _TL("2. Attribute"), _TL(""), true ); Parameters.Add_Table_Field( pNode , "FIELD_3" , _TL("3. Attribute"), _TL(""), true ); Parameters.Add_Shapes( NULL , "DISSOLVED" , _TL("Dissolved Lines"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Choice( NULL , "ALL" , _TL("Dissolve..."), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("lines with same attribute value(s)"), _TL("all lines") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CLine_Dissolve::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("LINES")) && pParameters->Get_Parameter("LINES")->asShapes() != NULL ) { int nFields = pParameters->Get_Parameter("LINES")->asShapes()->Get_Field_Count(); pParameters->Get_Parameter("FIELD_2")->Set_Value(nFields); pParameters->Get_Parameter("FIELD_3")->Set_Value(nFields); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Dissolve::On_Execute(void) { bool bAll; int Field_1, Field_2, Field_3, iLine; CSG_String Value; CSG_Shape *pLine , *pUnion; CSG_Shapes *pLines, *pUnions; //----------------------------------------------------- pLines = Parameters("LINES") ->asShapes(); pUnions = Parameters("DISSOLVED") ->asShapes(); Field_1 = Parameters("FIELD_1") ->asInt(); Field_2 = Parameters("FIELD_2") ->asInt(); Field_3 = Parameters("FIELD_3") ->asInt(); bAll = Parameters("ALL") ->asInt() == 1; //----------------------------------------------------- if( pLines->is_Valid() ) { pUnions->Create(SHAPE_TYPE_Line); //------------------------------------------------- if( bAll || Field_1 >= pLines->Get_Field_Count() ) { pUnions->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pLines->Get_Name(), _TL("Dissolved"))); pUnions->Add_Field(_TL("ID"), SG_DATATYPE_Int); pUnion = pUnions->Add_Shape(); for(iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { Add_Line(pUnion, pLines->Get_Shape(iLine)); } } //------------------------------------------------- else { Value = pLines->Get_Field_Name(Field_1); pUnions ->Add_Field(pLines->Get_Field_Name(Field_1), pLines->Get_Field_Type(Field_1)); if( Field_2 >= 0 ) { Value += CSG_String::Format(SG_T(", %s"), pLines->Get_Field_Name(Field_2)); pUnions ->Add_Field(pLines->Get_Field_Name(Field_2), pLines->Get_Field_Type(Field_2)); } if( Field_3 >= 0 ) { Value += CSG_String::Format(SG_T(", %s"), pLines->Get_Field_Name(Field_3)); pUnions ->Add_Field(pLines->Get_Field_Name(Field_3), pLines->Get_Field_Type(Field_3)); } pLines->Set_Index(Field_1, TABLE_INDEX_Ascending, Field_2, TABLE_INDEX_Ascending, Field_3, TABLE_INDEX_Ascending); pUnions->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pLines->Get_Name(), _TL("Dissolved"), Value.c_str())); for(iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(pLines->Get_Record_byIndex(iLine)->Get_Index()); CSG_String s(pLine->asString(Field_1)); if( Field_2 >= 0 ) s += pLine->asString(Field_2); if( Field_3 >= 0 ) s += pLine->asString(Field_3); if( iLine == 0 || Value.Cmp(s) ) { Value = s; pUnion = pUnions->Add_Shape(pLine, SHAPE_COPY_GEOM); pUnion->Set_Value(0, pLine->asString(Field_1)); if( Field_2 >= 0 ) pUnion->Set_Value(1, pLine->asString(Field_2)); if( Field_3 >= 0 ) pUnion->Set_Value(2, pLine->asString(Field_3)); } else { Add_Line(pUnion, pLine); } } } //------------------------------------------------- return( pUnions->is_Valid() ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Dissolve::Add_Line(CSG_Shape *pLine, CSG_Shape *pAdd) { if( pLine && pAdd ) { int nParts = pLine->Get_Part_Count(); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pAdd->Get_Point_Count(iPart) > 1 ) { int jPart = pLine->Get_Part_Count(); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pLine->Add_Point(pAdd->Get_Point(iPoint, iPart), jPart); } } } return( nParts < pLine->Get_Part_Count() ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_lines/line_dissolve.h0000664000175000017500000001060112565125410024775 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_dissolve.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_dissolve.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_dissolve_H #define HEADER_INCLUDED__line_dissolve_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Dissolve : public CSG_Module { public: CLine_Dissolve(void); protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool Add_Line (CSG_Shape *pLine, CSG_Shape *pAdd); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_dissolve_H saga-2.2.3/src/modules/shapes/shapes_lines/Makefile.in0000664000175000017500000005634312622651171024051 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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_lines DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_lines_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_lines_la_OBJECTS = line_dissolve.lo Lines_From_Points.lo \ Lines_From_Polygons.lo line_polygon_intersection.lo \ line_properties.lo line_simplification.lo line_smoothing.lo \ line_split_with_lines.lo MLB_Interface.lo libshapes_lines_la_OBJECTS = $(am_libshapes_lines_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_lines_la_SOURCES) DIST_SOURCES = $(libshapes_lines_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 911 2011-02-14 16:38:15Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_lines.la libshapes_lines_la_SOURCES = \ line_dissolve.cpp\ Lines_From_Points.cpp\ Lines_From_Polygons.cpp\ line_polygon_intersection.cpp\ line_properties.cpp\ line_simplification.cpp\ line_smoothing.cpp\ line_split_with_lines.cpp\ MLB_Interface.cpp\ line_dissolve.h\ Lines_From_Points.h\ Lines_From_Polygons.h\ line_polygon_intersection.h\ line_properties.h\ line_simplification.h\ line_smoothing.h\ line_split_with_lines.h\ MLB_Interface.h libshapes_lines_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) --foreign src/modules/shapes/shapes_lines/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_lines/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_lines.la: $(libshapes_lines_la_OBJECTS) $(libshapes_lines_la_DEPENDENCIES) $(EXTRA_libshapes_lines_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_lines_la_OBJECTS) $(libshapes_lines_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Lines_From_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Lines_From_Polygons.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_dissolve.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_polygon_intersection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_properties.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_simplification.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_smoothing.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_split_with_lines.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/shapes/shapes_lines/Lines_From_Polygons.h0000664000175000017500000001072512565125410026074 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Lines_From_Polygons.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // Lines_From_Polygons.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Lines_From_Polygons_H #define HEADER_INCLUDED__Lines_From_Polygons_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLines_From_Polygons : public CSG_Module { public: CLines_From_Polygons(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Lines_From_Polygons_H saga-2.2.3/src/modules/shapes/shapes_lines/line_properties.cpp0000664000175000017500000001514212565125410025701 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_properties.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_properties.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_properties.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Properties::CLine_Properties(void) { //----------------------------------------------------- Set_Name (_TL("Line Properties")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "Line properties: length, number of vertices." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Lines with Property Attributes"), _TL("If not set property attributes will be added to the orignal layer."), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "BPARTS" , _TL("Number of Parts"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BPOINTS" , _TL("Number of Vertices"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BLENGTH" , _TL("Length"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Properties::On_Execute(void) { //------------------------------------------------- int bParts = Parameters("BPARTS") ->asBool() ? 0 : -1; int bPoints = Parameters("BPOINTS") ->asBool() ? 0 : -1; int bLength = Parameters("BLENGTH") ->asBool() ? 0 : -1; if( bParts && bPoints && bLength ) { Error_Set(_TL("no properties selected")); return( false ); } //------------------------------------------------- CSG_Shapes *pLines = Parameters("LINES")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() <= 0 ) { Error_Set(_TL("invalid lines layer")); return( false ); } if( Parameters("OUTPUT")->asShapes() && Parameters("OUTPUT")->asShapes() != pLines ) { pLines = Parameters("OUTPUT")->asShapes(); pLines->Create(*Parameters("LINES")->asShapes()); } //------------------------------------------------- if( !bParts ) { bParts = pLines->Get_Field_Count(); pLines->Add_Field(SG_T("NPARTS") , SG_DATATYPE_Int ); } if( !bPoints ) { bPoints = pLines->Get_Field_Count(); pLines->Add_Field(SG_T("NPOINTS"), SG_DATATYPE_Int ); } if( !bLength ) { bLength = pLines->Get_Field_Count(); pLines->Add_Field(SG_T("LENGTH") , SG_DATATYPE_Double); } //------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pLines->Get_Count()); i++) { CSG_Shape *pLine = pLines->Get_Shape(i); if( bParts >= 0 ) pLine->Set_Value(bParts , pLine->Get_Part_Count()); if( bPoints >= 0 ) pLine->Set_Value(bPoints, pLine->Get_Point_Count()); if( bLength >= 0 ) pLine->Set_Value(bLength, ((CSG_Shape_Line *)pLine)->Get_Length()); } //------------------------------------------------- if( pLines == Parameters("LINES")->asShapes() ) { DataObject_Update(pLines); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_lines/line_smoothing.cpp0000664000175000017500000005550312565125410025521 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_smoothing.cpp 2347 2014-12-04 10:37:10Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_smoothing.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_smoothing.h" #define MIN_WEIGHT 0.0005 #define EPSILON 1.0e-07 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Smoothing::CLine_Smoothing(void) { //----------------------------------------------------- Set_Name (_TL("Line Smoothing")); Set_Author (SG_T("V. Wichmann, J. Engels (c) 2014")); Set_Description (_TW( "The module provides methods for line smoothing including iterative averaging " "(SIA) and Gaussian filtering.\n\n" "Iterative averaging (SIA) is described by Mansouryar & Hedayati (2012). " "A higher smoothing sensitivity results in a " "stronger smoothing in less iterations and vice versa. The 'improved SIA " "model' simply applies a preservation factor in the first iteration and " "then runs the 'basic SIA model' for the following iterations.\n\n" "Gaussian filtering with shrinkage correction is described by Lowe (1989).\n\n" "In case the density of line vertices is too high, the 'Line Simplification' " "tool can be applied first. If the density of line vertices is too low, " "additional vertices can be inserted by applying the 'Convert Lines to Points' " "and the 'Convert Points to Line(s)' tools prior to smoothing.\n\n" "References:\n" "Lowe, D. (1989): Organization of Smooth Image Curves at Multiple Scales. " "International Journal of Computer Vision, 3: 119-130. " "(pdf)\n\n" "Mansouryar, M. & Hedayati, A. (2012): Smoothing Via Iterative Averaging (SIA) " "- A Basic Technique for Line Smoothing. International Journal of Computer and " "Electrical Engineering Vol. 4, No. 3: 307-311. " "(pdf)\n\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES_IN" , _TL("Lines"), _TL("The input line shapefile to smooth."), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "LINES_OUT" , _TL("Smoothed Lines"), _TL("The smoothed output line shapefile."), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL("Choose the method to apply."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("basic SIA model"), _TL("improved SIA model"), _TL("Gaussian Filtering") ), 2 ); Parameters.Add_Value( NULL , "SENSITIVITY" , _TL("Sensitivity"), _TL("Half the size of the moving window [vertex count], controls smoothing sensitivity."), PARAMETER_TYPE_Int, 3, 1, true ); Parameters.Add_Value( NULL , "ITERATIONS" , _TL("Iterations"), _TL("The number of smoothing iterations [-]."), PARAMETER_TYPE_Int, 10, 1, true ); Parameters.Add_Value( NULL , "PRESERVATION" , _TL("Preservation"), _TL("The smoothing preservation factor [-]."), PARAMETER_TYPE_Double, 10.0, 1.0, true ); Parameters.Add_Value( NULL , "SIGMA" , _TL("Sigma"), _TL("Standard deviation of the Gaussian filter [-]."), PARAMETER_TYPE_Double, 2.0, 0.5, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CLine_Smoothing::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("SENSITIVITY", pParameter->asInt() <= 1); pParameters->Set_Enabled("ITERATIONS", pParameter->asInt() <= 1); pParameters->Set_Enabled("PRESERVATION", pParameter->asInt() == 1); pParameters->Set_Enabled("SIGMA", pParameter->asInt() == 2); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Smoothing::On_Execute(void) { CSG_Shapes *pLines, *pSmooth; int iMethod, iSS, iSI; double dSP, dSigma; bool bResult; pLines = Parameters("LINES_IN")->asShapes(); pSmooth = Parameters("LINES_OUT")->asShapes(); iMethod = Parameters("METHOD")->asInt(); iSS = Parameters("SENSITIVITY")->asInt(); iSI = Parameters("ITERATIONS")->asInt(); dSP = Parameters("PRESERVATION")->asDouble(); dSigma = Parameters("SIGMA")->asDouble(); //-------------------------------------------------------- pSmooth->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s_smoothed"), pLines->Get_Name()), pLines, pLines->Get_Vertex_Type()); if( iMethod <= 1 ) { bResult = Calc_SIA(pLines, pSmooth, iMethod, iSS, iSI, dSP); } else { bResult = Calc_Gaussian(pLines, pSmooth, dSigma); } return( bResult ); } //--------------------------------------------------------- bool CLine_Smoothing::Calc_SIA(CSG_Shapes *pLines, CSG_Shapes *pSmooth, int iMethod, int iSS, int iSI, double dSP) { int iOffset; if( iSS > iSI ) { SG_UI_Msg_Add(_TL("WARNING: smoothing sensitivity is greater than the number of iterations!"), true); } if( iMethod == 1 && iSI < 2 ) { SG_UI_Msg_Add_Error(_TL("The improved SIA model requires more than one smoothing iteration!")); return( false ); } //-------------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { CSG_Shape *pLine = pLines->Get_Shape(iLine); CSG_Shape *pSmoothed = pSmooth->Add_Shape(pLine, SHAPE_COPY_ATTR); //-------------------------------------------------------- for(int iPart=0; iPartGet_Part_Count(); iPart++) { std::vector verticesA(pLine->Get_Point_Count(iPart)); std::vector verticesB(pLine->Get_Point_Count(iPart)); TSG_Point p; for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { p.x = pLine->Get_Point(iPoint, iPart).x; p.y = pLine->Get_Point(iPoint, iPart).y; verticesB.at(iPoint) = p; } //-------------------------------------------------------- for(int i=0; i= (int)verticesA.size() - iSS ) { iOffset = (int)verticesA.size() - 1 - iPoint; } if( iPoint - iOffset < 0 ) // validate lower ... { iOffset = 0; } if( iPoint + iOffset >= verticesA.size() ) // ... and upper limit { iOffset = (int)verticesA.size() - 1 - iPoint; } if( iMethod == 1 && i == 0 ) // improved SIA, apply preservation in first iteration { p.x = (verticesA.at(iPoint - iOffset).x + verticesA.at(iPoint).x + verticesA.at(iPoint + iOffset).x) / 3.0; p.y = (verticesA.at(iPoint - iOffset).y + verticesA.at(iPoint).y + verticesA.at(iPoint + iOffset).y) / 3.0; TSG_Point p_GA; // vector GA (triangle centroid - point) p_GA.x = verticesA.at(iPoint).x - p.x; p_GA.y = verticesA.at(iPoint).y - p.y; double dLength = sqrt(p_GA.x * p_GA.x + p_GA.y * p_GA.y); if( dLength > 0.0 ) { double dScaled = dLength * dSP; // scale by preservation p.x = verticesA.at(iPoint).x + (p_GA.x / dLength) * dScaled; // shift point p.y = verticesA.at(iPoint).y + (p_GA.y / dLength) * dScaled; } else { p = verticesA.at(iPoint); } } else // basic SIA { p.x = (verticesA.at(iPoint - iOffset).x + verticesA.at(iPoint).x + verticesA.at(iPoint + iOffset).x) / 3.0; p.y = (verticesA.at(iPoint - iOffset).y + verticesA.at(iPoint).y + verticesA.at(iPoint + iOffset).y) / 3.0; } verticesB.at(iPoint) = p; } // iPoint } // iIteration //-------------------------------------------------------- for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pSmoothed->Add_Point(verticesB.at(iPoint).x, verticesB.at(iPoint).y, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSmoothed->Set_Z(pLine->Get_Z(iPoint, iPart), iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSmoothed->Set_M(pLine->Get_M(iPoint, iPart), iPoint, iPart); } } } } // iPart } // iLine return( true ); } //--------------------------------------------------------- bool CLine_Smoothing::Calc_Gaussian(CSG_Shapes *pLines, CSG_Shapes *pSmooth, double dSigma) { int half_window_width; bool bClosed; double variance; variance = dSigma * dSigma; double t0d = sqrt (-2.0 * variance * log ( MIN_WEIGHT )); half_window_width = (int) floor (t0d); double nfac = 1.0 / dSigma / sqrt (2.0 * M_PI); if( 2 * half_window_width + 1 < 3 ) { SG_UI_Msg_Add_Error(_TL("The length of the Gaussian window is too small, please provide a larger sigma.")); return( false ); } std::vector gauss_window(2 * half_window_width + 1); std::vector first_deriv_gauss_window(2 * half_window_width + 1); std::vector snd_deriv_gauss_window(2 * half_window_width + 1); std::vector gauss_window_corr(2 * half_window_width + 1); std::vector snd_deriv_gauss_window_corr(2 * half_window_width + 1); double zero_sum_weights = 0.0 ; double snd_sum_weights = 0.0 ; SG_UI_Msg_Add(CSG_String::Format(_TL("Length of the Gaussian window:\t %d"), 2 * half_window_width + 1), true); for (int k=-half_window_width, l=0; k<=half_window_width; k++, l++) { double kd = (double)k; gauss_window [l] = nfac * exp (-kd * kd / (2.0 * variance)); zero_sum_weights += gauss_window [l]; first_deriv_gauss_window [l] = -nfac * kd * exp (-kd * kd / (2.0 * variance)) / variance; snd_deriv_gauss_window [l] = nfac * (kd * kd / variance - 1.0) * exp (-kd * kd / (2.0 * variance)) / variance; snd_sum_weights += snd_deriv_gauss_window [l]; } // The filter kernels have to be corrected because of the discretization // The sum of the elements of the first-derivative-kernel is zero due to antisymmetry for (int k=-half_window_width, l=0; k<=half_window_width; k++, l++) { double kd = (double) k ; gauss_window_corr [l] = gauss_window [l] / zero_sum_weights ; snd_deriv_gauss_window_corr [l] = snd_deriv_gauss_window [l] - snd_sum_weights * gauss_window_corr [l] ; } //-------------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress (iLine, pLines->Get_Count ()); iLine++) { CSG_Shape *pLine = pLines->Get_Shape(iLine); CSG_Shape *pSmoothed = pSmooth->Add_Shape(pLine, SHAPE_COPY_ATTR); //-------------------------------------------------------- for(int iPart=0; iPartGet_Part_Count(); iPart++) { int curve_length = pLine -> Get_Point_Count(iPart); std::vector verticesA (curve_length) ; // the original points std::vector verticesB (curve_length) ; // the intermediate points (after smoothing) std::vector verticesC (curve_length) ; // the points after smoothing and shrinkage correction TSG_Point p; if (pLine->Get_Point(0, iPart).x == pLine->Get_Point(curve_length - 1, iPart).x && pLine->Get_Point(0, iPart).y == pLine->Get_Point(curve_length - 1, iPart).y ) { bClosed = true; curve_length--; } else bClosed = false; double mean_X = 0.0; double mean_Y = 0.0; for(int iPoint=0; iPointGet_Point(iPoint, iPart).x); mean_Y += (pLine->Get_Point(iPoint, iPart).y); } mean_X /= curve_length; mean_Y /= curve_length; for(int iPoint=0; iPointGet_Point(iPoint, iPart).x - mean_X; p.y = pLine->Get_Point(iPoint, iPart).y - mean_Y; verticesA.at(iPoint) = p; } if( curve_length < 2 * half_window_width + 1 ) { SG_UI_Msg_Add(_TL("WARNING: unable to smooth line because Gaussian window too large (number of line vertices too small or sigma too big)."), true); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pSmoothed->Add_Point(pLine->Get_Point(iPoint, iPart).x, pLine->Get_Point(iPoint, iPart).y, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSmoothed->Set_Z(pLine->Get_Z(iPoint, iPart), iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSmoothed->Set_M(pLine->Get_M(iPoint, iPart), iPoint, iPart); } } } continue; } for(int iPoint=0; iPoint curve_length - half_window_width - 1) && bClosed == false) { if( iPoint < half_window_width ) loc_hw = iPoint ; else loc_hw = curve_length - 1 - iPoint ; // same story as before, but with different window length std::vector gwloc(2 * loc_hw + 1); std::vector first_deriv_gwloc(2 * loc_hw + 1); std::vector snd_deriv_gwloc(2 * loc_hw + 1); std::vector gwloc_corr(2 * loc_hw + 1); std::vector first_deriv_gwloc_corr(2 * loc_hw + 1); std::vector snd_deriv_gwloc_corr(2 * loc_hw + 1); double zero_sum_loc = 0.0; double snd_sum_loc = 0.0; for(int k=-loc_hw, l=0; k<=loc_hw; k++, l++) { double kd = (double)k; gwloc [l] = nfac * exp (-kd * kd / (2.0 * variance)); first_deriv_gwloc [l] = -kd * nfac * exp (-kd * kd / (2.0 * variance)) / variance; snd_deriv_gwloc [l] = nfac * (kd * kd / variance - 1.0) * exp (-kd * kd / (2.0 * variance)) / variance; zero_sum_loc += gwloc [l]; snd_sum_loc += snd_deriv_gwloc [l]; } // The filter kernels have to be corrected because of the discretization double first_k_sum_loc = 0.0 ; for(int k=-loc_hw, l=0; k<=loc_hw; k++, l++) { double kd = (double)k; gwloc_corr [l] = gwloc [l] / zero_sum_loc; snd_deriv_gwloc_corr [l] = snd_deriv_gwloc [l] - snd_sum_loc * gwloc_corr [l]; // attention: it is convolution not correlation, therefore the minus sign first_k_sum_loc -= kd * first_deriv_gwloc [l]; } double snd_kk_sum_loc = 0.0; for(int k=-loc_hw, l=0; k<=loc_hw; k++, l++) { double kd = (double)k; first_deriv_gwloc_corr [l] = first_deriv_gwloc [l] / first_k_sum_loc; snd_kk_sum_loc += kd * kd * snd_deriv_gwloc_corr [l]; } for(int k=-loc_hw, l=0; k<=loc_hw; k++, l++) { snd_deriv_gwloc_corr [l] *= (2.0 / snd_kk_sum_loc); } std::vector values_red_x(2 * half_window_width + 1); std::vector values_red_y(2 * half_window_width + 1); for(int l=iPoint - loc_hw, k=0; l<=iPoint + loc_hw; k++, l++) { values_red_x [k] = verticesA.at(l).x - mean_loc_x; values_red_y [k] = verticesA.at(l).y - mean_loc_y; } int lstart = iPoint - loc_hw; int lend = iPoint + loc_hw; for(int i=0, l=lstart; l<=lend; i++, l++) { value_x += gwloc_corr [i] * values_red_x [i]; value_y += gwloc_corr [i] * values_red_y [i]; // attention: it is convolution not correlation, and the first-derivative-kernel is antisymmetric first_deriv_x -= first_deriv_gwloc [i] * values_red_x [i]; first_deriv_y -= first_deriv_gwloc [i] * values_red_y [i]; snd_deriv_x += snd_deriv_gwloc_corr [i] * values_red_x [i]; snd_deriv_y += snd_deriv_gwloc_corr [i] * values_red_y [i]; } value_x += mean_loc_x; value_y += mean_loc_y; if( loc_hw <= 3 ) { p.x = value_x; p.y = value_y; verticesB.at(iPoint) = p; verticesC.at(iPoint) = p; continue; } } else // if( (half_window_width <= iPoint && iPoint < curve_length - half_window_width) || bClosed == true ) { std::vector values_red_x(2 * half_window_width + 1); std::vector values_red_y(2 * half_window_width + 1); loc_hw = half_window_width; for(int l=iPoint - half_window_width, k=0; l<=iPoint + half_window_width; k++, l++) { int leff = l; if( l < 0 ) leff = curve_length + l ; else if( l >= curve_length ) leff = l - curve_length ; values_red_x [k] = verticesA.at(leff).x - mean_loc_x; values_red_y [k] = verticesA.at(leff).y - mean_loc_y; } for(int l=iPoint - half_window_width, k=0; l<=iPoint + half_window_width; k++, l++) { value_x += gauss_window [k] * values_red_x [k]; value_y += gauss_window [k] * values_red_y [k]; first_deriv_x -= first_deriv_gauss_window [k] * values_red_x [k]; first_deriv_y -= first_deriv_gauss_window [k] * values_red_y [k]; snd_deriv_x += snd_deriv_gauss_window_corr [k] * values_red_x [k]; snd_deriv_y += snd_deriv_gauss_window_corr [k] * values_red_y [k]; } value_x += mean_loc_x; value_y += mean_loc_y; } double denom = first_deriv_x * first_deriv_x + first_deriv_y * first_deriv_y; if( abs(denom) < EPSILON ) { Error_Set(_TL("First Derivative is singular! Probably the shape containes consecutive identical points.\n\n")); return( false ); } double sqrt_denom = sqrt (denom); double kappa = (first_deriv_x * snd_deriv_y - first_deriv_y * snd_deriv_x) / (denom * sqrt_denom); p.x = value_x; p.y = value_y; verticesB.at(iPoint) = p; if( abs(kappa) < EPSILON ) { verticesC.at(iPoint) = verticesB.at(iPoint); continue; } // Newton's method for the determination of the (original) curvature radius double rsmooth = 1.0 / kappa; double r = rsmooth; for(int k=0; ; k++) { double efunc = exp (- denom * variance / (2.0 * r * r)); double f = r * efunc - rsmooth; double fs = efunc * (1.0 + denom * variance / r / r); if( abs(fs) < EPSILON ) { r = rsmooth; break; } r = r - f / fs; if( k == 5 || abs(f) < EPSILON ) { break; } } first_deriv_x /= sqrt_denom; first_deriv_y /= sqrt_denom; value_x += first_deriv_y * (r - rsmooth); value_y += first_deriv_x * (rsmooth - r); p.x = value_x; p.y = value_y; verticesC.at(iPoint) = p; } // iPoint //-------------------------------------------------------- for(int iPoint = 0 ; iPointAdd_Point(verticesC.at(iPoint).x + mean_X, verticesC.at(iPoint).y + mean_Y, iPart); if( pLines -> Get_Vertex_Type () != SG_VERTEX_TYPE_XY ) { pSmoothed-> Set_Z (pLine->Get_Z (iPoint, iPart), iPoint, iPart); if( pLines -> Get_Vertex_Type () == SG_VERTEX_TYPE_XYZM ) { pSmoothed -> Set_M (pLine -> Get_M (iPoint, iPart), iPoint, iPart); } } } } // iPart } // iLine return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_lines/Lines_From_Points.cpp0000664000175000017500000001473712565125410026100 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Lines_From_Points.cpp 2176 2014-06-25 13:48:50Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // Lines_From_Points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Lines_From_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLines_From_Points::CLines_From_Points(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Convert Points to Line(s)")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "Converts points to line(s)." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "ORDER" , _TL("Order by..."), _TL(""), true ); Parameters.Add_Table_Field( pNode , "SEPARATE" , _TL("Separate by..."), _TL(""), true ); Parameters.Add_Table_Field( pNode , "ELEVATION" , _TL("Elevation"), _TL(""), true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLines_From_Points::On_Execute(void) { int Order, Separate, Elevation; CSG_String s; CSG_Shape *pLine , *pPoint; CSG_Shapes *pLines, *pPoints; pPoints = Parameters("POINTS" )->asShapes(); pLines = Parameters("LINES" )->asShapes(); Order = Parameters("ORDER" )->asInt(); Separate = Parameters("SEPARATE" )->asInt(); Elevation = Parameters("ELEVATION")->asInt(); //------------------------------------------------- if( pPoints->Get_Count() < 1 ) { return( false ); } //------------------------------------------------- pLines->Create(SHAPE_TYPE_Line, pPoints->Get_Name(), NULL, Elevation >= 0 ? SG_VERTEX_TYPE_XYZ : SG_VERTEX_TYPE_XY); pLines->Add_Field(SG_T("ID"), SG_DATATYPE_Int); if( Separate >= 0 ) { pLines->Add_Field(pPoints->Get_Field_Name(Separate), pPoints->Get_Field_Type(Separate)); pPoints->Set_Index(Separate, TABLE_INDEX_Ascending, Order, TABLE_INDEX_Ascending); } else { pPoints->Set_Index(Order, TABLE_INDEX_Ascending); } //------------------------------------------------- int iVertex = 0; for(int iPoint=0; iPointGet_Count(); iPoint++) { pPoint = pPoints->Get_Shape_byIndex(iPoint); if( pLines->Get_Count() == 0 || (Separate >= 0 && s.Cmp(pPoint->asString(Separate))) ) { pLine = pLines->Add_Shape(); iVertex = 0; pLine->Set_Value(0, pLines->Get_Count()); if( Separate >= 0 ) { pLine->Set_Value(1, s = pPoint->asString(Separate)); } } pLine->Add_Point(pPoint->Get_Point(0)); if( Elevation >= 0 ) { pLine->Set_Z(pPoint->asDouble(Elevation), iVertex); iVertex++; } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_lines/line_simplification.h0000664000175000017500000001054012565125410026161 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_simplification.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_simplification.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_simplification_H #define HEADER_INCLUDED__line_simplification_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Simplification : public CSG_Module { public: CLine_Simplification(void); protected: virtual bool On_Execute (void); private: double m_Tolerance; bool Simplify (CSG_Shape *pLine, int iPart, bool *Keep); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_simplification_H saga-2.2.3/src/modules/shapes/shapes_lines/line_polygon_intersection.cpp0000664000175000017500000002153412565125410027764 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_polygon_intersection.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_polygon_intersection.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_polygon_intersection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Polygon_Intersection::CLine_Polygon_Intersection(void) { //----------------------------------------------------- Set_Name (_TL("Line-Polygon Intersection")); Set_Author (SG_T("O. Conrad (c) 2010")); Set_Description (_TW( "Line-polygon intersection." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "INTERSECT" , _TL("Intersection"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("one multi-line per polygon"), _TL("keep original line attributes") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Polygon_Intersection::On_Execute(void) { int Method; CSG_Shapes *pLines, *pPolygons, *pNew_Lines, New_Lines; pLines = Parameters("LINES") ->asShapes(); pPolygons = Parameters("POLYGONS") ->asShapes(); pNew_Lines = Parameters("INTERSECT") ->asShapes(); Method = Parameters("METHOD") ->asInt(); if( !pLines ->is_Valid() || pLines ->Get_Count() < 1 || !pPolygons->is_Valid() || pPolygons->Get_Count() < 1 || pLines->Get_Extent().Intersects(pPolygons->Get_Extent()) == INTERSECTION_None ) { Error_Set(_TL("no shapes for intersection found")); return( false ); } //-------------------------------------------------------- switch( Method ) { case 0: pNew_Lines->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pLines->Get_Name(), _TL("Intersection"), pPolygons->Get_Name()), pPolygons ); break; case 1: default: pNew_Lines->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pLines->Get_Name(), _TL("Intersection"), pPolygons->Get_Name()), pLines ); break; } New_Lines.Create(SHAPE_TYPE_Line, NULL, pLines); //-------------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { if( Get_Intersection((CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon), pLines, New_Lines) ) { switch( Method ) { case 0: { CSG_Shape *pNew_Line = pNew_Lines->Add_Shape(pPolygons->Get_Shape(iPolygon), SHAPE_COPY_ATTR); for(int iLine=0, jPart=0; iLineGet_Part_Count(); iPart++, jPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pNew_Line->Add_Point(pLine->Get_Point(iPoint), jPart); } } } } break; case 1: { for(int iLine=0; iLineAdd_Shape(New_Lines.Get_Shape(iLine)); } } break; } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Polygon_Intersection::Get_Intersection(CSG_Shape_Polygon *pPolygon, CSG_Shapes *pLines, CSG_Shapes &New_Lines) { if( !pLines->Select(pPolygon->Get_Extent()) ) { return( false ); } New_Lines.Del_Records(); for(int iSelection=0; iSelectionGet_Selection_Count(); iSelection++) { CSG_Shape *pNew_Line, *pLine = pLines->Get_Selection(iSelection); for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point B, A = pLine->Get_Point(0, iPart); if( pPolygon->Contains(A) ) { pNew_Line = New_Lines.Add_Shape(pLine, SHAPE_COPY_ATTR); pNew_Line ->Add_Point(A); } else { pNew_Line = NULL; } for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { B = A; A = pLine->Get_Point(iPoint, iPart); if( pNew_Line ) { if( pPolygon->Contains(A) ) { pNew_Line ->Add_Point(A); } else { pNew_Line ->Add_Point(Get_Intersection(pPolygon, A, B)); pNew_Line = NULL; } } else if( pPolygon->Contains(A) ) { pNew_Line = New_Lines.Add_Shape(pLine, SHAPE_COPY_ATTR); pNew_Line ->Add_Point(Get_Intersection(pPolygon, A, B)); pNew_Line ->Add_Point(A); } } } } return( New_Lines.Get_Count() > 0 ); } //--------------------------------------------------------- TSG_Point CLine_Polygon_Intersection::Get_Intersection(CSG_Shape_Polygon *pPolygon, const TSG_Point &a, const TSG_Point &b) { TSG_Point c = a; for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point A, B; B = pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { A = B; B = pPolygon->Get_Point(iPoint, iPart); if( SG_Get_Crossing(c, A, B, a, b) ) { return( c ); } } } return( c ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_lines/MLB_Interface.cpp0000664000175000017500000001230312577724054025100 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2573 2015-09-04 12:25:29Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Lines") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Wichmann (c) 2005-2014") ); case MLB_INFO_Description: return( _TL("Tools for lines.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Lines") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Lines_From_Polygons.h" #include "Lines_From_Points.h" #include "line_properties.h" #include "line_polygon_intersection.h" #include "line_simplification.h" #include "line_dissolve.h" #include "line_split_with_lines.h" #include "line_smoothing.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CLines_From_Polygons ); case 1: return( new CLines_From_Points ); case 2: return( new CLine_Properties ); case 3: return( new CLine_Polygon_Intersection ); case 4: return( new CLine_Simplification ); case 5: return( new CLine_Dissolve ); case 6: return( new CLine_Split_with_Lines ); case 8: return( new CLine_Split_at_Points ); case 7: return( new CLine_Smoothing ); case 10: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/shapes/shapes_lines/Makefile.am0000664000175000017500000000167012565125410024027 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 911 2011-02-14 16:38:15Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_lines.la libshapes_lines_la_SOURCES =\ line_dissolve.cpp\ Lines_From_Points.cpp\ Lines_From_Polygons.cpp\ line_polygon_intersection.cpp\ line_properties.cpp\ line_simplification.cpp\ line_smoothing.cpp\ line_split_with_lines.cpp\ MLB_Interface.cpp\ line_dissolve.h\ Lines_From_Points.h\ Lines_From_Polygons.h\ line_polygon_intersection.h\ line_properties.h\ line_simplification.h\ line_smoothing.h\ line_split_with_lines.h\ MLB_Interface.h libshapes_lines_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/shapes/shapes_lines/MLB_Interface.h0000664000175000017500000000772312565125410024543 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__shapes_lines_H #define HEADER_INCLUDED__shapes_lines_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef shapes_lines_EXPORTS #define shapes_lines_EXPORT _SAGA_DLL_EXPORT #else #define shapes_lines_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_lines_H saga-2.2.3/src/modules/shapes/shapes_lines/line_split_with_lines.h0000664000175000017500000001142412577724054026545 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_split_with_lines.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_split_with_lines.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_split_with_lines_H #define HEADER_INCLUDED__line_split_with_lines_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Split_with_Lines : public CSG_Module { public: CLine_Split_with_Lines(void); protected: virtual bool On_Execute (void); private: bool Get_Intersection (CSG_Shape *pLine, CSG_Shape_Part *pSplit); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Split_at_Points : public CSG_Module { public: CLine_Split_at_Points(void); protected: virtual bool On_Execute (void); private: bool Get_Intersection (CSG_Shape *pLine, TSG_Point Point, double Epsilon); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_split_with_lines_H saga-2.2.3/src/modules/shapes/shapes_lines/line_smoothing.h0000664000175000017500000001112112565125410025152 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_smoothing.h 2347 2014-12-04 10:37:10Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_smoothing.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_smoothing_H #define HEADER_INCLUDED__line_smoothing_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Smoothing : public CSG_Module { public: CLine_Smoothing(void); protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool Calc_SIA(CSG_Shapes *pLines, CSG_Shapes *pSmooth, int iMethod, int iSS, int iSI, double dSP); bool Calc_Gaussian(CSG_Shapes *pLines, CSG_Shapes *pSmooth, double dSigma); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_smoothing_H saga-2.2.3/src/modules/shapes/shapes_points/0000775000175000017500000000000012634325746022204 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/shapes/shapes_points/thiessen_polygons.h0000664000175000017500000001002212565125407026117 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: thiessen_polygons.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // thiessen_polygons.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__thiessen_polygons_H #define HEADER_INCLUDED__thiessen_polygons_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CThiessen_Polygons : public CSG_Module { public: CThiessen_Polygons(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__thiessen_polygons_H saga-2.2.3/src/modules/shapes/shapes_points/points_thinning.h0000664000175000017500000001046212565125407025565 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_thinning.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // points_thinning.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_thinning_H #define HEADER_INCLUDED__points_thinning_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_Thinning : public CSG_Module { public: CPoints_Thinning(void); protected: virtual bool On_Execute (void); private: double m_Resolution; CSG_PRQuadTree m_Search; CSG_Shapes *m_pPoints; bool Set_Search_Engine (CSG_Shapes *pPoints, int Field); void Get_Points (CSG_PRQuadTree_Item *pItem); void Add_Point (CSG_PRQuadTree_Leaf *pLeaf); void Add_Point (CSG_PRQuadTree_Node_Statistics *pNode); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_thinning_H saga-2.2.3/src/modules/shapes/shapes_points/convex_hull.h0000664000175000017500000001067212565125407024704 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_filter.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // convex_hull.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__convex_hull_H #define HEADER_INCLUDED__convex_hull_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CConvex_Hull : public CSG_Module { public: CConvex_Hull(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Tools") ); } protected: virtual bool On_Execute (void); private: static CSG_Shapes *m_pPoints; static int Compare (const int iElement_1, const int iElement_2); double is_Left (const TSG_Point &Line_A, const TSG_Point &Line_B, const TSG_Point &Point); bool Get_Chain_Hull (CSG_Shapes *pPoints, CSG_Shapes *pHulls, CSG_Shape *pAttributes = NULL); int Get_Chain_Hull (CSG_Points &P, CSG_Points &H); bool Get_Bounding_Box (CSG_Shape *pHull, CSG_Shape *pBox); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__convex_hull_H saga-2.2.3/src/modules/shapes/shapes_points/add_polygon_attributes.cpp0000664000175000017500000001575512565125407027465 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: add_polygon_attributes.cpp 1959 2014-02-03 12:41:37Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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( "Spatial join for points. Retrieves for each point the selected " "attributes from those polygon, which contain the point. " )); //----------------------------------------------------- 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_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("Attributes to add. Select none to add all") ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CAdd_Polygon_Attributes::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pInput = Parameters("INPUT")->asShapes(); if( !pInput->is_Valid() ) { Error_Set(_TL("Invalid points layer.")); return( false ); } //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( !pPolygons->is_Valid() ) { Error_Set(_TL("Invalid polygon layer.")); return( false ); } //----------------------------------------------------- CSG_Parameter_Table_Fields *pFields = Parameters("FIELDS")->asTableFields(); if( pFields->Get_Count() == 0 ) { CSG_String sFields; for(int iField=0; iFieldGet_Field_Count(); iField++) { sFields += CSG_String::Format(SG_T("%d,"), iField); } pFields->Set_Value(sFields); } //----------------------------------------------------- CSG_Shapes *pOutput = Parameters("OUTPUT")->asShapes(); if( pOutput && pOutput != pInput ) { pOutput->Create(*pInput); } else { Parameters("OUTPUT")->Set_Value(pOutput = pInput); } pOutput->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), pPolygons->Get_Name())); //----------------------------------------------------- int outField = pOutput->Get_Field_Count(); { for(int iField=0; iFieldGet_Count(); iField++) { int jField = pFields->Get_Index(iField); pOutput->Add_Field(pPolygons->Get_Field_Name(jField), pPolygons->Get_Field_Type(jField)); } } //----------------------------------------------------- for(int iPoint=0; iPointGet_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 ) { for(int iField=0; iFieldGet_Count(); iField++) { int jField = pFields->Get_Index(iField); switch( pPolygons->Get_Field_Type(jField) ) { case SG_DATATYPE_String: case SG_DATATYPE_Date: pPoint->Set_Value(outField + iField, pPolygon->asString(jField)); break; default: pPoint->Set_Value(outField + iField, pPolygon->asDouble(jField)); break; } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/CountPoints.cpp0000664000175000017500000000633512565125407025177 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CountPoints.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* CountPoints.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "CountPoints.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCountPoints::CCountPoints(void) { Set_Name (_TL("Count Points in Polygons")); Set_Author (SG_T("Victor Olaya (c) 2004")); Set_Description (_TW( "Count Points in Polygons." )); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCountPoints::On_Execute(void) { CSG_Shapes *pPoints = Parameters("POINTS") ->asShapes(); CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); int Field = pPolygons->Get_Field_Count(); pPolygons->Add_Field(_TL("Points"), SG_DATATYPE_Int); for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); int nPoints = 0; for(int iPoint=0; iPointGet_Count(); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); if( pPolygon->Contains(pPoint->Get_Point(iPoint)) ) { nPoints++; } } pPolygon->Set_Value(Field, nPoints); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/Points_From_Lines.cpp0000664000175000017500000004455412565125407026310 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Points_From_Lines.cpp 2545 2015-07-28 07:46:45Z reklov_w $ *********************************************************/ /******************************************************************************* Points_From_Lines.cpp Copyright (C) Victor Olaya, Volker Wichmann 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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Points_From_Lines.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_From_Lines::CPoints_From_Lines(void) { Set_Name (_TL("Convert Lines to Points")); Set_Author (_TL("V. Olaya, V. Wichmann (c) 2004-2015")); Set_Description (_TW( "Converts lines to points. " "Optionally inserts additional points in user-defined distances. " )); Parameters.Add_Shapes( NULL, "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL, "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL, "ADD" , _TL("Insert Additional Points"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL, "METHOD_INSERT" , _TL("Insertion"), _TL("Choose the method how to insert additional points."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("per line segment"), _TL("per line"), _TL("from line center") ), 0 ); Parameters.Add_Value( NULL, "DIST" , _TL("Insertion Distance"), _TL("Point insertion distance [map units]."), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL, "ADD_POINT_ORDER" , _TL("Add Point Order"), _TL("Add point order as additional attribute."), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPoints_From_Lines::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "ADD") ) { pParameters->Get_Parameter("METHOD_INSERT") ->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("DIST") ->Set_Enabled(pParameter->asBool()); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_From_Lines::On_Execute(void) { CSG_Shapes *pLines, *pPoints; bool bAddPoints, bAddPtOrder; int iMethod; double dDist; //----------------------------------------------------- pLines = Parameters("LINES") ->asShapes(); pPoints = Parameters("POINTS") ->asShapes(); bAddPoints = Parameters("ADD") ->asBool(); iMethod = Parameters("METHOD_INSERT") ->asInt(); dDist = Parameters("DIST") ->asDouble(); bAddPtOrder = Parameters("ADD_POINT_ORDER") ->asBool(); pPoints->Create(SHAPE_TYPE_Point, pLines->Get_Name(), pLines, pLines->Get_Vertex_Type()); if( bAddPtOrder ) pPoints->Add_Field(_TL("PT_ID"), SG_DATATYPE_Int); if( bAddPoints ) { switch (iMethod) { case 0: default: Convert_Add_Points_Segment(pLines, pPoints, dDist, bAddPtOrder); break; case 1: Convert_Add_Points_Line(pLines, pPoints, dDist, bAddPtOrder); break; case 2: Convert_Add_Points_Center(pLines, pPoints, dDist, bAddPtOrder); break; } } else { Convert(pLines, pPoints, bAddPtOrder); } return( true ); } //--------------------------------------------------------- void CPoints_From_Lines::Convert_Add_Points_Segment(CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder) { CSG_Shape *pLine, *pPoint; TSG_Point Pt_A, Pt_B; double dx, dy, dz, dm, dLine, A_z, B_z, A_m, B_m; for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); int iPoints = 0; for(int iPart=0; iPartGet_Part_Count(); iPart++) { Pt_B = pLine->Get_Point(0, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { B_z = pLine->Get_Z(0, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { B_m = pLine->Get_M(0, iPart); } } for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { Pt_A = Pt_B; Pt_B = pLine->Get_Point(iPoint, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z = B_z; B_z = pLine->Get_Z(iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m = B_m; B_m = pLine->Get_M(iPoint, iPart); } } dx = Pt_B.x - Pt_A.x; dy = Pt_B.y - Pt_A.y; dLine = sqrt(dx*dx + dy*dy); dx /= dLine; dy /= dLine; if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { dz = (B_z - A_z) / dLine; if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { dm = (B_m - A_m) / dLine; } } pPoint = pPoints->Add_Shape(pLine, SHAPE_COPY_ATTR); pPoint ->Add_Point(Pt_A); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pPoint->Set_Z(A_z, 0); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pPoint->Set_M(A_m, 0); } } if( bAddPtOrder ) { pPoint->Set_Value(pPoints->Get_Field_Count()-1, iPoints); iPoints++; } double dLength = 0.0; while( dLength + dDist < dLine ) { Pt_A.x += dDist * dx; Pt_A.y += dDist * dy; pPoint = pPoints->Add_Shape(pLine, SHAPE_COPY_ATTR); pPoint ->Add_Point(Pt_A); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z += dDist * dz; pPoint->Set_Z(A_z, 0); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m += dDist * dm; pPoint->Set_M(A_m, 0); } } if( bAddPtOrder ) { pPoint->Set_Value(pPoints->Get_Field_Count()-1, iPoints); iPoints++; } dLength += dDist; } } } } return; } //--------------------------------------------------------- void CPoints_From_Lines::Convert_Add_Points_Line(CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder) { CSG_Shape *pLine, *pPoint; TSG_Point Pt_A, Pt_B; double dx, dy, dz, dm, dLine, A_z, B_z, A_m, B_m; for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); int iPoints = 0; double dOffset = 0.0; for(int iPart=0; iPartGet_Part_Count(); iPart++) { Pt_B = pLine->Get_Point(0, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { B_z = pLine->Get_Z(0, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { B_m = pLine->Get_M(0, iPart); } } for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { Pt_A = Pt_B; Pt_B = pLine->Get_Point(iPoint, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z = B_z; B_z = pLine->Get_Z(iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m = B_m; B_m = pLine->Get_M(iPoint, iPart); } } dx = Pt_B.x - Pt_A.x; dy = Pt_B.y - Pt_A.y; dLine = sqrt(dx*dx + dy*dy); dx /= dLine; dy /= dLine; Pt_A.x += dOffset * dx; Pt_A.y += dOffset * dy; if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { dz = (B_z - A_z) / dLine; A_z += dOffset * dz; if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { dm = (B_m - A_m) / dLine; A_m += dOffset * dm; } } pPoint = pPoints->Add_Shape(pLine, SHAPE_COPY_ATTR); pPoint ->Add_Point(Pt_A); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pPoint->Set_Z(A_z, 0); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pPoint->Set_M(A_m, 0); } } if( bAddPtOrder ) { pPoint->Set_Value(pPoints->Get_Field_Count()-1, iPoints); iPoints++; } double dLength = 0.0; dLine -= dOffset; while( dLength + dDist < dLine ) { Pt_A.x += dDist * dx; Pt_A.y += dDist * dy; pPoint = pPoints->Add_Shape(pLine, SHAPE_COPY_ATTR); pPoint ->Add_Point(Pt_A); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z += dDist * dz; pPoint->Set_Z(A_z, 0); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m += dDist * dm; pPoint->Set_M(A_m, 0); } } if( bAddPtOrder ) { pPoint->Set_Value(pPoints->Get_Field_Count()-1, iPoints); iPoints++; } dLength += dDist; } dOffset = (dLength + dDist) - dLine; } } } return; } //--------------------------------------------------------- void CPoints_From_Lines::Convert_Add_Points_Center(CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder) { CSG_Shape *pLine; TSG_Point Pt_A, Pt_B, Pt_C; double dx, dy, dz, dm, dLine, A_z, B_z, C_z, A_m, B_m, C_m; int iSplitPart, iSplitPoint; for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); double dCenter = ((CSG_Shape_Line *)pLine)->Get_Length() / 2.0; double dLength = 0.0; //--------------------------------------------------------- // search for the part we need to split for(int iPart=0; iPartGet_Part_Count(); iPart++) { dLine = ((CSG_Shape_Line *)pLine)->Get_Length(iPart); if( dLength + dLine < dCenter ) { dLength += dLine; } else { iSplitPart = iPart; break; } } double dOffset = dCenter - dLength; Pt_B = pLine->Get_Point(0, iSplitPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { B_z = pLine->Get_Z(0, iSplitPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { B_m = pLine->Get_M(0, iSplitPart); } } dLength = 0.0; //--------------------------------------------------------- // search for the point after which we need to split for(int iPoint=1; iPointGet_Point_Count(iSplitPart); iPoint++) { Pt_A = Pt_B; Pt_B = pLine->Get_Point(iPoint, iSplitPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z = B_z; B_z = pLine->Get_Z(iPoint, iSplitPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m = B_m; B_m = pLine->Get_M(iPoint, iSplitPart); } } dx = Pt_B.x - Pt_A.x; dy = Pt_B.y - Pt_A.y; dLine = sqrt(dx*dx + dy*dy); if (dLength + dLine < dOffset) { dLength += dLine; } else { iSplitPoint = iPoint - 1; dOffset = dOffset - dLength; break; } } //--------------------------------------------------------- // create center point dx /= dLine; dy /= dLine; Pt_A.x += dOffset * dx; Pt_A.y += dOffset * dy; Pt_C = Pt_A; if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { dz = (B_z - A_z) / dLine; A_z += dOffset * dz; C_z = A_z; if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { dm = (B_m - A_m) / dLine; A_m += dOffset * dm; C_m = A_m; } } //--------------------------------------------------------- // create line part from center to end of line CSG_Shapes SplitLines; CSG_Shape *pSplitLine; SplitLines.Create(pLines->Get_Type(), pLines->Get_Name(), pLines, pLines->Get_Vertex_Type()); int iPartOffset = 0; int iPointOffset; pSplitLine = SplitLines.Add_Shape(pLine, SHAPE_COPY_ATTR); pSplitLine ->Add_Point(Pt_C, iPartOffset); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSplitLine->Set_Z(C_z, iPartOffset); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSplitLine->Set_M(C_m, iPartOffset); } } for(int iPart=iSplitPart; iPartGet_Part_Count(); iPart++) { if( iPart == iSplitPart ) { iPointOffset = iSplitPoint + 1; } else { iPointOffset = 0; } for(int iPoint=iPointOffset; iPointGet_Point_Count(iPart); iPoint++) { Pt_A = pLine->Get_Point(iPoint, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z = pLine->Get_Z(iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m = pLine->Get_M(iPoint, iPart); } } pSplitLine ->Add_Point(Pt_A, iPartOffset); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSplitLine->Set_Z(A_z, iPartOffset); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSplitLine->Set_M(A_m, iPartOffset); } } } // for iPoint iPartOffset++; } // for iPart; Convert_Add_Points_Line(&SplitLines, pPoints, dDist, bAddPtOrder); //--------------------------------------------------------- // create line part from center to start of line SplitLines.Create(pLines->Get_Type(), pLines->Get_Name(), pLines, pLines->Get_Vertex_Type()); iPartOffset = 0; pSplitLine = SplitLines.Add_Shape(pLine, SHAPE_COPY_ATTR); pSplitLine ->Add_Point(Pt_C, iPartOffset); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSplitLine->Set_Z(C_z, iPartOffset); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSplitLine->Set_M(C_m, iPartOffset); } } for(int iPart=iSplitPart; iPart>=0; iPart--) { if( iPart == iSplitPart ) { iPointOffset = iSplitPoint; } else { iPointOffset = pLine->Get_Point_Count(iPart); } for(int iPoint=iPointOffset; iPoint>=0; iPoint--) { Pt_A = pLine->Get_Point(iPoint, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z = pLine->Get_Z(iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m = pLine->Get_M(iPoint, iPart); } } pSplitLine ->Add_Point(Pt_A, iPartOffset); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSplitLine->Set_Z(A_z, iPartOffset); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSplitLine->Set_M(A_m, iPartOffset); } } } // for iPoint iPartOffset++; } // for iPart; Convert_Add_Points_Line(&SplitLines, pPoints, dDist, bAddPtOrder); } // for iLine return; } //--------------------------------------------------------- void CPoints_From_Lines::Convert(CSG_Shapes *pLines, CSG_Shapes *pPoints, bool bAddPtOrder) { CSG_Shape *pLine, *pPoint; for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); int iPoints = 0; for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pPoint = pPoints->Add_Shape(pLine, SHAPE_COPY_ATTR); pPoint ->Add_Point(pLine->Get_Point(iPoint, iPart)); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pPoint->Set_Z(pLine->Get_Z(iPoint, iPart), 0); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pPoint->Set_M(pLine->Get_M(iPoint, iPart), 0); } } if( bAddPtOrder ) { pPoint->Set_Value(pPoints->Get_Field_Count()-1, iPoints); iPoints++; } } } } return; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_From_MultiPoints::CPoints_From_MultiPoints(void) { Set_Name (_TL("Convert Multipoints to Points")); Set_Author (_TL("O.Conrad (c) 2011")); Set_Description (_TW( "Converts multipoints to points. " )); Parameters.Add_Shapes( NULL , "MULTIPOINTS" , _TL("Multipoints"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Points ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_From_MultiPoints::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pMultipoints = Parameters("MULTIPOINTS") ->asShapes(); CSG_Shapes *pPoints = Parameters("POINTS") ->asShapes(); pPoints->Create(SHAPE_TYPE_Point, pMultipoints->Get_Name(), pMultipoints, pMultipoints->Get_Vertex_Type()); //----------------------------------------------------- for(int iMultipoint=0; iMultipointGet_Count() && Set_Progress(iMultipoint, pMultipoints->Get_Count()); iMultipoint++) { CSG_Shape *pMultipoint = pMultipoints->Get_Shape(iMultipoint); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { CSG_Shape *pPoint = pPoints->Add_Shape(pMultipoint, SHAPE_COPY_ATTR); pPoint->Add_Point(pMultipoint->Get_Point(iPoint, iPart)); if( pMultipoints->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pPoint->Set_Z(pMultipoint->Get_Z(iPoint, iPart), 0); if( pMultipoints->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pPoint->Set_M(pMultipoint->Get_M(iPoint, iPart), 0); } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/points_filter.cpp0000664000175000017500000002511512565125407025570 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: remove_duplicates.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // points_filter.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "points_filter.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_Filter::CPoints_Filter(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Points Filter")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "" )); //----------------------------------------------------- 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_Shapes( NULL , "FILTER" , _TL("Filtered Points"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Radius"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL , "MINNUM" , _TL("Minimum Number of Points"), _TL("only points with given minimum number of points in search radius will be processed"), PARAMETER_TYPE_Int, 0, 0.0, true ); Parameters.Add_Value( NULL , "MAXNUM" , _TL("Maximum Number of Points"), _TL("Number of nearest points, which will be evaluated for filtering. Set to zero to investigate all points in search radius."), PARAMETER_TYPE_Int, 0, 0.0, true ); Parameters.Add_Value( NULL , "QUADRANTS" , _TL("Quadrants"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Filter Criterion"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("keep maxima (with tolerance)"), _TL("keep minima (with tolerance)"), _TL("remove maxima (with tolerance)"), _TL("remove minima (with tolerance)"), _TL("remove below percentile"), _TL("remove above percentile") ), 0 ); Parameters.Add_Value( NULL , "TOLERANCE" , _TL("Tolerance"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Value( NULL , "PERCENT" , _TL("Percentile"), _TL(""), PARAMETER_TYPE_Double, 50.0, 0.0, true, 100.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_Filter::On_Execute(void) { bool bQuadrants; int zField; CSG_Shapes *pPoints, *pFilter; //----------------------------------------------------- pPoints = Parameters("POINTS") ->asShapes(); pFilter = Parameters("FILTER") ->asShapes(); zField = Parameters("FIELD") ->asInt(); bQuadrants = Parameters("QUADRANTS") ->asBool(); m_Method = Parameters("METHOD") ->asInt(); m_nMinPoints = Parameters("MINNUM") ->asInt(); m_nMaxPoints = Parameters("MAXNUM") ->asInt(); m_Radius = Parameters("RADIUS") ->asDouble(); m_Tolerance = Parameters("TOLERANCE") ->asDouble(); m_Percentile = Parameters("PERCENT") ->asDouble(); //----------------------------------------------------- if( !pPoints->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( pPoints->Get_Count() <= 0 ) { Error_Set(_TL("no points in layer")); return( false ); } if( !m_Search.Create(pPoints, zField) ) { Error_Set(_TL("failed to initialise search engine")); return( false ); } //----------------------------------------------------- if( pFilter ) { pFilter->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Filtered")), pPoints); } else { pPoints->Select(); } //----------------------------------------------------- int nFiltered = 0; for(int i=0; iGet_Count() && Set_Progress(i, pPoints->Get_Count()); i++) { CSG_Shape *pPoint = pPoints->Get_Shape(i); if( pPoint ) { bool bFilter = bQuadrants ? Do_Filter(pPoint->Get_Point(0), pPoint->asDouble(zField), 0) || Do_Filter(pPoint->Get_Point(0), pPoint->asDouble(zField), 1) || Do_Filter(pPoint->Get_Point(0), pPoint->asDouble(zField), 2) || Do_Filter(pPoint->Get_Point(0), pPoint->asDouble(zField), 3) : Do_Filter(pPoint->Get_Point(0), pPoint->asDouble(zField)); if( bFilter ) { nFiltered++; if( !pFilter ) { pPoints->Select(i, true); } } else if( pFilter ) { pFilter->Add_Shape(pPoint); } } } //----------------------------------------------------- if( !pFilter ) { pPoints->Del_Selection(); DataObject_Update(pPoints); } Message_Add(CSG_String::Format(SG_T("%d %s"), nFiltered, _TL("points have been filtered"))); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_Filter::Do_Filter(TSG_Point Point, double zPoint, int Quadrant) { if( !m_Search.Select_Nearest_Points(Point.x, Point.y, m_nMaxPoints, m_Radius, Quadrant) ) { return( false ); } if( m_Search.Get_Selected_Count() <= m_nMinPoints ) { return( true ); } switch( m_Method ) { //----------------------------------------------------- case 0: // keep maxima case 1: // keep minima case 2: // remove maxima case 3: // remove minima { for(int i=0; ihas_Statistics() ) { switch( m_Method ) { case 0: z = ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Maximum(); break; // keep maxima case 1: z = ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Minimum(); break; // keep minima case 2: z = ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Maximum(); break; // remove maxima case 3: z = ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Minimum(); break; // remove minima } } else { z = pLeaf->Get_Z(); } switch( m_Method ) { case 0: if( zPoint < (z - m_Tolerance) ) return( true ); break; // keep maxima case 1: if( zPoint > (z + m_Tolerance) ) return( true ); break; // keep minima case 2: if( zPoint < (z - m_Tolerance) ) return( false ); break; // remove maxima case 3: if( zPoint > (z + m_Tolerance) ) return( false ); break; // remove minima } } } return( m_Method <= 1 ? false : true ); } //----------------------------------------------------- case 4: // remove below percentile case 5: // remove above percentile { double n = 0.0; for(int i=0; ihas_Statistics() ) { for(int j=0; j<((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Count(); j++) { if( zPoint > ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Value(j) ) { n++; } } } else if( zPoint > pLeaf->Get_Z() ) { n++; } } } n *= 100.0 / m_Search.Get_Selected_Count(); return( m_Method == 4 ? n < m_Percentile : n > m_Percentile ); } } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/FitNPointsToShape.cpp0000664000175000017500000000744712565125407026240 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: FitNPointsToShape.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* FitNPointsToShape.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "FitNPointsToShape.h" #define MAX_REP 30 #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif CFitNPointsToShape::CFitNPointsToShape(void){ Parameters.Set_Name(_TL("Fit N Points to shape")); Parameters.Set_Description(_TW( "(c) 2004 by Victor Olaya. Fit N Points to shape")); Parameters.Add_Shapes(NULL, "POINTS", _TL("Points"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Shapes(NULL, "SHAPES", _TL("Shapes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Value(NULL, "NUMPOINTS", _TL("Number of points"), _TL("Number of points"), PARAMETER_TYPE_Int, 100, 1, true); }//constructor CFitNPointsToShape::~CFitNPointsToShape(void) {} bool CFitNPointsToShape::On_Execute(void){ CSG_Shapes *pShapes, *pPoints; CSG_Shape *pShape, *pShape2; bool bCopy; int iPoints; int iPointsIn = 0; int iRep = 0; int i,j; double x,y; double dArea; double dDist; double dDistInf, dDistSup; bool bFirstTime; TSG_Rect Extent; pShapes = Parameters("SHAPES")->asShapes(); pPoints = Parameters("POINTS")->asShapes(); iPoints = Parameters("NUMPOINTS")->asInt(); if(pShapes == pPoints){ bCopy = true; pPoints = SG_Create_Shapes(); }//if else{ bCopy = false; }//else pPoints->Create(SHAPE_TYPE_Point, _TL("Point Grid")); pPoints->Add_Field("X", SG_DATATYPE_Double); pPoints->Add_Field("Y", SG_DATATYPE_Double); for (i = 0; i < pShapes->Get_Selection_Count(); i++){ iRep = 0; pShape = pShapes->Get_Selection(i); dArea = ((CSG_Shape_Polygon*)pShape)->Get_Area(); dDist = sqrt(dArea / (double) iPoints); dDistInf = sqrt(dArea / (double) (iPoints + 2)); dDistSup = sqrt(dArea / (double) (iPoints - min(2, iPoints-1))); Extent = ((CSG_Shape_Polygon*)pShape)->Get_Extent(); bFirstTime = true; do{ if (!bFirstTime){ for (j = 0; j < iPointsIn; j++){ pPoints->Del_Shape(pPoints->Get_Count()-1); }//for }//if iPointsIn = 0; iRep++; for (x=Extent.xMin; xContains(x,y)){ pShape2 = pPoints->Add_Shape(); pShape2->Add_Point(x,y); pShape2->Set_Value(0, x); pShape2->Set_Value(1, y); iPointsIn++; }//if }//for }//for if (iPointsIn > iPoints){ dDistInf = dDist; dDist = (dDistInf + dDistSup) / 2.; }//if else if (iPointsIn < iPoints){ dDistSup = dDist; dDist = (dDistInf + dDistSup) / 2.; }//if bFirstTime = false; }while(iPointsIn != iPoints && iRep < MAX_REP); }//for if(bCopy){ pShapes->Assign(pPoints); delete(pPoints); }//if return true; }//method saga-2.2.3/src/modules/shapes/shapes_points/DistanceMatrix.h0000664000175000017500000000411112565125407025264 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: DistanceMatrix.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* DistanceMatrix.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDistanceMatrix : public CSG_Module { public: CDistanceMatrix(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/Points_From_Table.h0000664000175000017500000000471212565125407025722 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Points_From_Table.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* Points_From_Table.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Points_From_Table_H #define HEADER_INCLUDED__Points_From_Table_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_From_Table : public CSG_Module { public: CPoints_From_Table(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Points_From_Table_H saga-2.2.3/src/modules/shapes/shapes_points/remove_duplicates.cpp0000664000175000017500000002356312565125407026426 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: remove_duplicates.cpp 2447 2015-03-19 14:43:42Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // Remove_Duplicates.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "remove_duplicates.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CRemove_Duplicates::CRemove_Duplicates(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Remove Duplicate Points")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- 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_Shapes( NULL , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Point to Keep"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("first point"), _TL("last point"), _TL("point with minimum attribute value"), _TL("point with maximum attribute value") ), 0 ); Parameters.Add_Choice( NULL , "NUMERIC" , _TL("Numeric Attribute Values"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("take value from the point to be kept"), _TL("minimum value of all duplicates"), _TL("maximum value of all duplicates"), _TL("mean value of all duplicates") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CRemove_Duplicates::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("METHOD")) ) { pParameters->Get_Parameter("FIELD")->Set_Enabled(pParameter->asInt() >= 2); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CRemove_Duplicates::On_Execute(void) { CSG_PRQuadTree Search; //----------------------------------------------------- m_pPoints = Parameters("RESULT") ->asShapes(); m_Field = Parameters("FIELD") ->asInt(); m_Method = Parameters("METHOD") ->asInt(); m_Numeric = Parameters("NUMERIC") ->asInt(); //----------------------------------------------------- if( m_pPoints == NULL ) { m_pPoints = Parameters("POINTS")->asShapes(); } else if( m_pPoints != Parameters("POINTS")->asShapes() ) { m_pPoints ->Assign(Parameters("POINTS")->asShapes()); } //----------------------------------------------------- if( !m_pPoints->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( m_pPoints->Get_Count() <= 0 ) { Error_Set(_TL("no points in layer")); return( false ); } if( !Search.Create(m_pPoints, -1) ) { Error_Set(_TL("failed to initialise search engine")); return( false ); } //----------------------------------------------------- m_pPoints->Add_Field(_TL("Duplicates"), SG_DATATYPE_Int); m_pPoints->Select(); for(int i=0; iGet_Count() && Set_Progress(i, m_pPoints->Get_Count()); i++) { CSG_Shape *pPoint = m_pPoints->Get_Shape(i); if( !pPoint->is_Selected() ) { double Distance; CSG_PRQuadTree_Leaf *pLeaf = Search.Get_Nearest_Leaf(pPoint->Get_Point(0), Distance); if( Distance == 0.0 && pLeaf && pLeaf->has_Statistics() ) { Set_Attributes(pPoint, (CSG_PRQuadTree_Leaf_List *)pLeaf); } } } //----------------------------------------------------- if( m_pPoints->Get_Selection_Count() == 0 ) { Message_Add(_TL("No duplicates found.")); } else { Message_Add(CSG_String::Format(SG_T("%d %s"), m_pPoints->Get_Selection_Count(), _TL("duplicates have been identified."))); m_pPoints->Del_Selection(); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CRemove_Duplicates::Set_Attributes(CSG_Shape *pPoint, CSG_PRQuadTree_Leaf_List *pList) { int iDuplicate; double dKeep; CSG_Shape *pKeep; //----------------------------------------------------- for(iDuplicate=0, pKeep=NULL; iDuplicateGet_Count(); iDuplicate++) { CSG_Shape *pDuplicate = m_pPoints->Get_Shape((int)pList->Get_Value(iDuplicate)); if( pDuplicate != pPoint ) { m_pPoints->Select(pDuplicate->Get_Index(), true); } switch( m_Method ) { case 2: // point with minimum attribute value if( !pKeep || (!pDuplicate->is_NoData(m_Field) && pDuplicate->asDouble(m_Field) < dKeep) ) { dKeep = pDuplicate->asDouble(m_Field); pKeep = pDuplicate; } break; case 3: // point with maximum attribute value") if( !pKeep || (!pDuplicate->is_NoData(m_Field) && pDuplicate->asDouble(m_Field) > dKeep) ) { dKeep = pDuplicate->asDouble(m_Field); pKeep = pDuplicate; } break; } } //----------------------------------------------------- if( m_Method == 1 ) // last point { pKeep = m_pPoints->Get_Shape((int)pList->Get_Value((int)(pList->Get_Count() - 1))); } if( pKeep ) { ((CSG_Table_Record *)pPoint)->Assign(pKeep); } pPoint->Set_Value(m_pPoints->Get_Field_Count() - 1, (double)pList->Get_Count()); //----------------------------------------------------- if( m_Numeric > 0 ) { for(int iField=0; iFieldGet_Field_Count()-1; iField++) { if( SG_Data_Type_is_Numeric(m_pPoints->Get_Field_Type(iField)) ) { CSG_Simple_Statistics s; for(iDuplicate=0; iDuplicateGet_Count(); iDuplicate++) { CSG_Shape *pDuplicate = m_pPoints->Get_Shape((int)pList->Get_Value(iDuplicate)); if( !pDuplicate->is_NoData(iField) ) { s += m_pPoints->Get_Shape((int)pList->Get_Value(iDuplicate))->asDouble(iField); } } switch( m_Numeric ) { case 1: pPoint->Set_Value(iField, s.Get_Minimum()); break; // minimun value case 2: pPoint->Set_Value(iField, s.Get_Maximum()); break; // maximum value case 3: pPoint->Set_Value(iField, s.Get_Mean()); break; // mean value } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/AddCoordinates.h0000664000175000017500000000240512565125407025234 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: AddCoordinates.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* AddCoordinates.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "MLB_Interface.h" class CAddCoordinates : public CSG_Module { public: CAddCoordinates(void); protected: virtual bool On_Execute(void); }; saga-2.2.3/src/modules/shapes/shapes_points/snap_points_to_features.h0000664000175000017500000001035612565125407027312 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snap_points_to_features.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // snap_points_to_features.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__snap_points_to_features_H #define HEADER_INCLUDED__snap_points_to_features_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSnap_Points_to_Features : public CSG_Module { public: CSnap_Points_to_Features(TSG_Shape_Type Type); protected: virtual bool On_Execute (void); private: void Snap_To_Point (const TSG_Point &Point, CSG_Shape *pPoint, TSG_Point &snap_Point, double &snap_Dist); void Snap_To_Line (const TSG_Point &Point, CSG_Shape *pLine , TSG_Point &snap_Point, double &snap_Dist); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__snap_points_to_features_H saga-2.2.3/src/modules/shapes/shapes_points/gps_track_aggregation.h0000664000175000017500000001131612565125407026676 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gps_track_aggregation.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // gps_track_aggregation.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gps_track_aggregation_H #define HEADER_INCLUDED__gps_track_aggregation_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGPS_Track_Aggregation : public CSG_Module { public: CGPS_Track_Aggregation(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool Set_Statistic (CSG_Table_Record *pAggregate, CSG_Simple_Statistics &Statistic, CSG_Simple_Statistics &Time, int nDropped, bool bVerbose); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gps_track_aggregation_H saga-2.2.3/src/modules/shapes/shapes_points/convex_hull.cpp0000664000175000017500000004135212565125407025236 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: remove_duplicates.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // convex_hull.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "convex_hull.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CConvex_Hull::CConvex_Hull(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Convex Hull")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Implementation of 'Andrew's Monotone Chain Algorithm' for convex hull construction. " "\nReferences:\n" "Algorithmist (2011): Monotone Chain Convex Hull. algorithmist.com.\n" "Andrew, A.M. (1979): Another Efficient Algorithm for Convex Hulls in Two Dimensions. Info. Proc. Letters 9, pp.216-219.\n" "Sunday, D. (2001-2006): The Convex Hull of a 2D Point Set or Polygon. Softsurfer.com.\n" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "HULLS" , _TL("Convex Hull"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "BOXES" , _TL("Minimum Bounding Box"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "POLYPOINTS" , _TL("Hull Construction"), _TL("This option does not apply to simple point layers."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("one hull for all shapes"), _TL("one hull per shape"), _TL("one hull per shape part") ), 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CConvex_Hull::On_Execute(void) { CSG_Shapes *pShapes, *pHulls, *pBoxes; //----------------------------------------------------- pShapes = Parameters("SHAPES")->asShapes(); pHulls = Parameters("HULLS" )->asShapes(); pBoxes = Parameters("BOXES" )->asShapes(); //----------------------------------------------------- pHulls->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Convex Hull"))); pHulls->Add_Field(_TL("ID" ), SG_DATATYPE_Int); pHulls->Add_Field(_TL("AREA" ), SG_DATATYPE_Double); pHulls->Add_Field(_TL("PERIMETER"), SG_DATATYPE_Double); //----------------------------------------------------- int nOkay = 0; //----------------------------------------------------- if( pShapes->Get_Type() == SHAPE_TYPE_Point ) { nOkay = Get_Chain_Hull(pShapes, pHulls) ? 1 : 0; } //----------------------------------------------------- else { CSG_Shapes Points(SHAPE_TYPE_Point); int Construction = Parameters("POLYPOINTS")->asInt(); if( Construction != 0 ) { for(int iField=0; iFieldGet_Field_Count(); iField++) { pHulls->Add_Field(pShapes->Get_Field_Name(iField), pShapes->Get_Field_Type(iField)); } } for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Points.Add_Shape()->Add_Point(pShape->Get_Point(iPoint, iPart)); } if( Construction == 2 ) // one hull per shape part { if( Get_Chain_Hull(&Points, pHulls, pShape) ) nOkay++; Points.Del_Records(); } } if( Construction == 1 ) // one hull per shape { if( Get_Chain_Hull(&Points, pHulls, pShape) ) nOkay++; Points.Del_Records(); } } if( Construction == 0 ) // one hull for all shapes { if( Get_Chain_Hull(&Points, pHulls) ) nOkay++; Points.Del_Records(); } } if( nOkay <= 0 ) { return( false ); } //----------------------------------------------------- if( pBoxes ) { pBoxes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Bounding Box"))); pBoxes->Add_Field(_TL("ID") , SG_DATATYPE_Int); pBoxes->Add_Field(_TL("AREA") , SG_DATATYPE_Double); pBoxes->Add_Field(_TL("PERIMETER") , SG_DATATYPE_Double); for(int iHull=0; iHullGet_Count() && Set_Progress(iHull, pHulls->Get_Count()); iHull++) { Get_Bounding_Box(pHulls->Get_Shape(iHull), pBoxes->Add_Shape()); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CConvex_Hull::Get_Bounding_Box(CSG_Shape *pHull, CSG_Shape *pBox) { int i, iBox; double a, aBox, d, dBox, dSin, dCos; TSG_Rect r, rBox; TSG_Point A, B; B = pHull->Get_Point(pHull->Get_Point_Count() - 1); for(i=0; iGet_Point_Count(); i++) { A = B; B = pHull->Get_Point(i); d = SG_Get_Angle_Of_Direction(A, B); dSin = sin(-d); dCos = cos(-d); for(int j=0; jGet_Point_Count(); j++) { TSG_Point q, p = pHull->Get_Point(j); q.x = p.x * dCos - p.y * dSin; q.y = p.x * dSin + p.y * dCos; if( j == 0 ) { r.xMin = r.xMax = q.x; r.yMin = r.yMax = q.y; } else { if( r.xMin > q.x ) r.xMin = q.x; else if( r.xMax < q.x ) r.xMax = q.x; if( r.yMin > q.y ) r.yMin = q.y; else if( r.yMax < q.y ) r.yMax = q.y; } } a = (r.xMax - r.xMin) * (r.yMax - r.yMin); if( i == 0 || a < aBox ) { iBox = i; aBox = a; dBox = d; rBox = r; } } //----------------------------------------------------- dSin = sin(dBox); dCos = cos(dBox); pBox->Add_Point(rBox.xMin * dCos - rBox.yMin * dSin, rBox.xMin * dSin + rBox.yMin * dCos); pBox->Add_Point(rBox.xMin * dCos - rBox.yMax * dSin, rBox.xMin * dSin + rBox.yMax * dCos); pBox->Add_Point(rBox.xMax * dCos - rBox.yMax * dSin, rBox.xMax * dSin + rBox.yMax * dCos); pBox->Add_Point(rBox.xMax * dCos - rBox.yMin * dSin, rBox.xMax * dSin + rBox.yMin * dCos); pBox->Add_Point(pBox->Get_Point(0)); pBox->Set_Value(0, pBox->Get_Index()); pBox->Set_Value(1, aBox); pBox->Set_Value(2, 2.0 * ((rBox.xMax - rBox.xMin) + (rBox.yMax - rBox.yMin))); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CConvex_Hull::Get_Chain_Hull(CSG_Shapes *pPoints, CSG_Shapes *pHulls, CSG_Shape *pAttributes) { int i, n; CSG_Points Points, Hull; //----------------------------------------------------- if( pPoints->Get_Count() < 3 ) { return( false ); } //----------------------------------------------------- m_pPoints = pPoints; CSG_Index Index(m_pPoints->Get_Count(), (TSG_PFNC_Compare)CConvex_Hull::Compare); m_pPoints = NULL; if( !Index.is_Okay() ) { return( false ); } for(i=0; iGet_Count(); i++) { Points.Add(pPoints->Get_Shape(Index[i])->Get_Point(0)); } //----------------------------------------------------- if( (n = Get_Chain_Hull(Points, Hull)) < 3 ) { return( false ); } //----------------------------------------------------- CSG_Shape *pHull = pHulls->Add_Shape(); for(i=0; iAdd_Point(Hull[i]); } pHull->Set_Value(0, pHull->Get_Index()); pHull->Set_Value(1, ((CSG_Shape_Polygon *)pHull)->Get_Area()); pHull->Set_Value(2, ((CSG_Shape_Polygon *)pHull)->Get_Perimeter()); if( pAttributes ) { for(i=3, n=0; iGet_Field_Count(); i++, n++) { *pHull->Get_Value(i) = *pAttributes->Get_Value(n); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shapes * CConvex_Hull::m_pPoints = NULL; //--------------------------------------------------------- int CConvex_Hull::Compare(const int iElement_1, const int iElement_2) { TSG_Point a = m_pPoints->Get_Shape(iElement_1)->Get_Point(0); TSG_Point b = m_pPoints->Get_Shape(iElement_2)->Get_Point(0); if( a.x < b.x ) { return( -1 ); } if( a.x > b.x ) { return( 1 ); } if( a.y < b.y ) { return( -1 ); } if( a.y > b.y ) { return( 1 ); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // Copyright 2001, softSurfer (www.softsurfer.com) // This code may be freely used and modified for any purpose // providing that this copyright notice is included with it. // SoftSurfer makes no warranty for this code, and cannot be held // liable for any real or imagined damage resulting from its use. // Users of this code must verify correctness for their application. //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // is_Left(): tests if a point is Left|On|Right of an infinite line. // Input: three points Line_A, Line_B, and Point // Return: >0 for Point left of the line through P0 and P1 // =0 for Point on the line // <0 for Point right of the line // See: the January 2001 Algorithm on Area of Triangles //--------------------------------------------------------- inline double CConvex_Hull::is_Left(const TSG_Point &Line_A, const TSG_Point &Line_B, const TSG_Point &Point) { return( (Line_B.x - Line_A.x) * (Point.y - Line_A.y) - (Point.x - Line_A.x) * (Line_B.y - Line_A.y) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // chainHull_2D(): Andrew's monotone chain 2D convex hull algorithm // Input: P[] = an array of 2D points // presorted by increasing x- and y-coordinates // n = the number of points in P[] // Output: H[] = an array of the convex hull vertices (max is n) // Return: the number of points in H[] //--------------------------------------------------------- int CConvex_Hull::Get_Chain_Hull(CSG_Points &P, CSG_Points &H) { int i, n, bot, top, minmin, minmax, maxmin, maxmax; double xmin, xmax; //----------------------------------------------------- // the output array H[] will be used as the stack n = P.Get_Count(); H.Set_Count(2 * n); bot = 0; // index for bottom of the stack top = -1; // index for top of the stack //----------------------------------------------------- // Get the indices of points with min x-coord and min|max y-coord minmin = 0; xmin = P[0].x; for(i=1; i=0; i--) { if( P[i].x != xmax ) { break; } } maxmin = i + 1; //----------------------------------------------------- // Compute the lower hull on the stack H H[++top] = P[minmin]; // push minmin point onto stack i = minmax; while( ++i <= maxmin && Process_Get_Okay() ) { // the lower line joins P[minmin] with P[maxmin] if( is_Left(P[minmin], P[maxmin], P[i]) >= 0 && i < maxmin ) continue; // ignore P[i] above or on the lower line while( top > 0 ) // there are at least 2 points on the stack { // test if P[i] is left of the line at the stack top if( is_Left(H[top-1], H[top], P[i]) > 0 ) break; // P[i] is a new hull vertex else top--; // pop top point off stack } H[++top] = P[i]; // push P[i] onto stack } //----------------------------------------------------- // Next, compute the upper hull on the stack H above the bottom hull if( maxmax != maxmin ) // if distinct xmax points { H[++top] = P[maxmax]; // push maxmax point onto stack } bot = top; // the bottom point of the upper hull stack i = maxmin; while( --i >= minmax && Process_Get_Okay() ) { // the upper line joins P[maxmax] with P[minmax] if( is_Left(P[maxmax], P[minmax], P[i]) >= 0 && i > minmax ) continue; // ignore P[i] below or on the upper line while( top > bot ) // at least 2 points on the upper stack { // test if P[i] is left of the line at the stack top if( is_Left(H[top-1], H[top], P[i]) > 0 ) break; // P[i] is a new hull vertex else top--; // pop top point off stack } H[++top] = P[i]; // push P[i] onto stack } if( minmax != minmin ) { H[++top] = P[minmin]; // push joining endpoint onto stack } return( top + 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/select_points.h0000664000175000017500000001033212565125407025222 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // select_points.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__select_points_H #define HEADER_INCLUDED__select_points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelect_Points : public CSG_Module_Interactive { public: CSelect_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: bool m_bAddCenter; int m_MaxPoints, m_Quadrant; double m_Radius; CSG_Shapes *m_pPoints, *m_pSelection; CSG_PRQuadTree m_Search; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__select_points_H saga-2.2.3/src/modules/shapes/shapes_points/Makefile.in0000664000175000017500000006137212622651171024251 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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_points DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } 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 = add_polygon_attributes.lo \ AddCoordinates.lo Clip_Points.lo convex_hull.lo CountPoints.lo \ CreatePointGrid.lo DistanceMatrix.lo FitNPointsToShape.lo \ gps_track_aggregation.lo MLB_Interface.lo points_filter.lo \ Points_From_Lines.lo Points_From_Table.lo points_thinning.lo \ remove_duplicates.lo select_points.lo separate_by_direction.lo \ snap_points_to_features.lo snap_points_to_grid.lo \ thiessen_polygons.lo libshapes_points_la_OBJECTS = $(am_libshapes_points_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_points_la_SOURCES) DIST_SOURCES = $(libshapes_points_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1568 2012-12-14 13:00:29Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_points.la libshapes_points_la_SOURCES = \ add_polygon_attributes.cpp\ AddCoordinates.cpp\ Clip_Points.cpp\ convex_hull.cpp\ CountPoints.cpp\ CreatePointGrid.cpp\ DistanceMatrix.cpp\ FitNPointsToShape.cpp\ gps_track_aggregation.cpp\ MLB_Interface.cpp\ points_filter.cpp\ Points_From_Lines.cpp\ Points_From_Table.cpp\ points_thinning.cpp\ remove_duplicates.cpp\ select_points.cpp\ separate_by_direction.cpp\ snap_points_to_features.cpp\ snap_points_to_grid.cpp\ thiessen_polygons.cpp\ add_polygon_attributes.h\ AddCoordinates.h\ convex_hull.h\ CountPoints.h\ Clip_Points.h\ CreatePointGrid.h\ DistanceMatrix.h\ FitNPointsToShape.h\ gps_track_aggregation.h\ MLB_Interface.h\ points_filter.h\ Points_From_Lines.h\ Points_From_Table.h\ points_thinning.h\ remove_duplicates.h\ select_points.h\ separate_by_direction.h\ snap_points_to_features.h\ snap_points_to_grid.h\ thiessen_polygons.h libshapes_points_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) --foreign src/modules/shapes/shapes_points/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_points/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_points.la: $(libshapes_points_la_OBJECTS) $(libshapes_points_la_DEPENDENCIES) $(EXTRA_libshapes_points_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_points_la_OBJECTS) $(libshapes_points_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AddCoordinates.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Clip_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CountPoints.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CreatePointGrid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DistanceMatrix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FitNPointsToShape.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Points_From_Lines.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Points_From_Table.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_polygon_attributes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convex_hull.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gps_track_aggregation.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_filter.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_thinning.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/remove_duplicates.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/select_points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/separate_by_direction.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snap_points_to_features.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snap_points_to_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thiessen_polygons.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/shapes/shapes_points/Clip_Points.h0000664000175000017500000001012312565125407024570 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Clip_Points.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Clip_Points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Clip_Points_H #define HEADER_INCLUDED__Clip_Points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CClip_Points : public CSG_Module { public: CClip_Points(void); virtual ~CClip_Points(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Clip_Points_H saga-2.2.3/src/modules/shapes/shapes_points/separate_by_direction.h0000664000175000017500000001035012565125407026705 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: separate_by_direction.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // separate_by_direction.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__separate_by_direction_H #define HEADER_INCLUDED__separate_by_direction_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSeparate_by_Direction : public CSG_Module { public: CSeparate_by_Direction(void); protected: virtual bool On_Execute (void); private: int m_nSectors; double m_Tolerance, m_dSector; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__separate_by_direction_H saga-2.2.3/src/modules/shapes/shapes_points/thiessen_polygons.cpp0000664000175000017500000001500412565125407026457 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: thiessen_polygons.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // thiessen_polygons.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "thiessen_polygons.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CThiessen_Polygons::CThiessen_Polygons(void) { //----------------------------------------------------- Set_Name (_TL("Thiessen Polygons")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description(_TW( "Creates Thiessen or Voronoi polygons for given point data set." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "FRAME" , _TL("Frame Size"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CThiessen_Polygons::On_Execute(void) { //----------------------------------------------------- CSG_TIN TIN; if( !TIN.Create(Parameters("POINTS")->asShapes()) ) { Error_Set(_TL("TIN creation failed")); return( false ); } //----------------------------------------------------- int nNodes = TIN.Get_Node_Count(); CSG_Rect r(TIN.Get_Extent()); r.Inflate(Parameters("FRAME")->asDouble(), false); //----------------------------------------------------- CSG_Shapes Frame(SHAPE_TYPE_Polygon); CSG_Shape *pFrame = Frame.Add_Shape(); pFrame->Add_Point(r.Get_XMin(), r.Get_YMin()); pFrame->Add_Point(r.Get_XMin(), r.Get_YMax()); pFrame->Add_Point(r.Get_XMax(), r.Get_YMax()); pFrame->Add_Point(r.Get_XMax(), r.Get_YMin()); //----------------------------------------------------- r.Inflate(3 * r.Get_XRange(), 3 * r.Get_YRange(), false); TIN.Add_Node(CSG_Point(r.Get_XCenter(), r.Get_YMin ()), NULL, false); TIN.Add_Node(CSG_Point(r.Get_XMax (), r.Get_YCenter()), NULL, false); TIN.Add_Node(CSG_Point(r.Get_XCenter(), r.Get_YMax ()), NULL, false); TIN.Add_Node(CSG_Point(r.Get_XMin (), r.Get_YCenter()), NULL, false); TIN.Update(); //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); pPolygons->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), TIN.Get_Name(), _TL("Thiessen Polygons")), &TIN); //----------------------------------------------------- for(int iNode=0; iNodeGet_Polygon(Points) ) { CSG_Shape *pPolygon = pPolygons->Add_Shape(TIN.Get_Record(iNode), SHAPE_COPY_ATTR); for(int iPoint=0; iPointAdd_Point(Points[iPoint]); } SG_Polygon_Intersection(pPolygon, pFrame); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/snap_points_to_features.cpp0000664000175000017500000002201512565125407027640 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snap_points_to_features.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // snap_points_to_features.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "snap_points_to_features.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSnap_Points_to_Features::CSnap_Points_to_Features(TSG_Shape_Type Type) { //----------------------------------------------------- Set_Name (Type == SHAPE_TYPE_Point ? _TL("Snap Points to Points") : _TL("Snap Points to Lines") ); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "SNAP" , _TL("Snap Features"), _TL(""), PARAMETER_INPUT, Type ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "MOVES" , _TL("Moves"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "DISTANCE" , _TL("Search Distance"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSnap_Points_to_Features::On_Execute(void) { double Distance; CSG_Shapes *pInput, *pPoints, *pSnap, *pMoves; //----------------------------------------------------- pInput = Parameters("INPUT" )->asShapes(); pPoints = Parameters("OUTPUT" )->asShapes(); pSnap = Parameters("SNAP" )->asShapes(); pMoves = Parameters("MOVES" )->asShapes(); Distance = Parameters("DISTANCE")->asDouble(); //----------------------------------------------------- if( !pInput->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( !pSnap->is_Valid() || pSnap->Get_Count() <= 0 ) { Error_Set(_TL("invalid snap features")); return( false ); } //----------------------------------------------------- if( pPoints && pPoints != pInput ) { pPoints->Create(*pInput); } else { Parameters("RESULT")->Set_Value(pPoints = pInput); } pPoints->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pInput->Get_Name(), _TL("snapped"), pSnap->Get_Name())); if( pMoves ) { pMoves->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pInput->Get_Name(), _TL("snap move"), pSnap->Get_Name()), pPoints); } //----------------------------------------------------- bool bDistance = Distance > 0.0; if( !bDistance ) { CSG_Rect r(pPoints->Get_Extent()); r.Union(pSnap->Get_Extent()); Distance = SG_Get_Distance(r.Get_BottomRight(), r.Get_TopLeft()); } //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); TSG_Point Point = pPoint->Get_Point(0), snap_Point; double snap_Dist = Distance; if( bDistance ) { if( pSnap->Select(CSG_Rect(Point.x - Distance, Point.y - Distance, Point.x + Distance, Point.y + Distance)) ) { for(int i=0; iGet_Selection_Count() && snap_Dist>0.0; i++) { if( pSnap->Get_Type() == SHAPE_TYPE_Point ) { Snap_To_Point(Point, pSnap->Get_Selection(i), snap_Point, snap_Dist); } else { Snap_To_Line (Point, pSnap->Get_Selection(i), snap_Point, snap_Dist); } } } } else { for(int i=0; iGet_Count() && snap_Dist>0.0; i++) { if( pSnap->Get_Type() == SHAPE_TYPE_Point ) { Snap_To_Point(Point, pSnap->Get_Shape(i), snap_Point, snap_Dist); } else { Snap_To_Line (Point, pSnap->Get_Shape(i), snap_Point, snap_Dist); } } } //------------------------------------------------- if( snap_Dist < Distance ) { pPoint->Set_Point(snap_Point, 0); if( pMoves ) { CSG_Shape *pMove = pMoves->Add_Shape(pPoint, SHAPE_COPY_ATTR); pMove->Add_Point(Point); pMove->Add_Point(snap_Point); } } } //----------------------------------------------------- if( bDistance ) { pSnap->Select(); // reset selection } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSnap_Points_to_Features::Snap_To_Point(const TSG_Point &Point, CSG_Shape *pPoint, TSG_Point &snap_Point, double &snap_Dist) { double d = SG_Get_Distance(Point, pPoint->Get_Point(0)); if( d < snap_Dist ) { snap_Dist = d; snap_Point = pPoint->Get_Point(0); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSnap_Points_to_Features::Snap_To_Line(const TSG_Point &Point, CSG_Shape *pLine, TSG_Point &snap_Point, double &snap_Dist) { CSG_Rect r(pLine->Get_Extent()); r.Inflate(snap_Dist, false); if( r.Contains(Point) ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point C, B, A = pLine->Get_Point(0, iPart); for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { B = A; A = pLine->Get_Point(iPoint, iPart); r.Assign(A, B); r.Inflate(snap_Dist, false); if( r.Contains(Point) ) { double d = SG_Get_Nearest_Point_On_Line(Point, A, B, C, true); if( d >= 0.0 && d < snap_Dist ) { snap_Dist = d; snap_Point = C; } } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/FitNPointsToShape.h0000664000175000017500000000265712565125407025703 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: FitNPointsToShape.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* FitNPointsToShape.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CFitNPointsToShape : public CSG_Module { public: CFitNPointsToShape(void); virtual ~CFitNPointsToShape(void); virtual bool is_ProjectDependent(void) {return( false );} protected: virtual bool On_Execute(void); }; saga-2.2.3/src/modules/shapes/shapes_points/gps_track_aggregation.cpp0000664000175000017500000003557512565125407027246 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gps_track_aggregation.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // gps_track_aggregation.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gps_track_aggregation.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { AGG_ID = 0, AGG_TRACK, AGG_DATE, AGG_TIME, AGG_PARM, AGG_MIN, AGG_MAX, AGG_RANGE, AGG_STDDEV, AGG_COUNT, AGG_DROPPED, AGG_DTIME, AGG_X, AGG_Y }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGPS_Track_Aggregation::CGPS_Track_Aggregation(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Aggregate Point Observations")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- // 2. Parameters... pNode = Parameters.Add_Shapes( NULL , "REFERENCE" , _TL("Reference Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "REFERENCE_ID" , _TL("ID"), _TL("") ); pNode = Parameters.Add_Table( NULL , "OBSERVATIONS" , _TL("Observations"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "X" , _TL("X"), _TL("") ); Parameters.Add_Table_Field( pNode , "Y" , _TL("Y"), _TL("") ); Parameters.Add_Table_Field( pNode , "TRACK" , _TL("Track"), _TL("") ); Parameters.Add_Table_Field( pNode , "DATE" , _TL("Date"), _TL("") ); Parameters.Add_Table_Field( pNode , "TIME" , _TL("Time"), _TL("expected to be the second of day") ); Parameters.Add_Table_Field( pNode , "PARAMETER" , _TL("Parameter"), _TL("") ); Parameters.Add_Table( NULL , "AGGREGATED" , _TL("Aggregated"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "TIME_SPAN" , _TL("Time Span Aggregation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("ignore"), _TL("floating"), _TL("fixed") ), 1 ); Parameters.Add_Value( NULL , "FIX_TIME" , _TL("Fixed Time Span (minutes)"), _TL("ignored if set to zero"), PARAMETER_TYPE_Double, 20.0, 0.0, true ); Parameters.Add_Value( NULL , "OFF_TIME" , _TL("Fixed Time Span Offset (minutes)"), _TL("offset in minutes relative to 00:00 (midnight)"), PARAMETER_TYPE_Double, -10.0 ); Parameters.Add_Value( NULL , "EPS_TIME" , _TL("Maximum Time Span (Seconds)"), _TL("ignored if set to zero"), PARAMETER_TYPE_Double, 60.0, 0.0, true ); Parameters.Add_Value( NULL , "EPS_SPACE" , _TL("Maximum Distance"), _TL("given as map units or meters if polar coordinates switch is on; ignored if set to zero"), PARAMETER_TYPE_Double, 100.0, 0.0, true ); Parameters.Add_Value( NULL , "VERBOSE" , _TL("Verbose"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "POLAR" , _TL("Polar Coordinates"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGPS_Track_Aggregation::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("TIME_SPAN")) ) { pParameters->Get_Parameter("FIX_TIME")->Set_Enabled(pParameter->asInt() == 2); pParameters->Get_Parameter("OFF_TIME")->Set_Enabled(pParameter->asInt() == 2); pParameters->Get_Parameter("EPS_TIME")->Set_Enabled(pParameter->asInt() == 1); } return( -1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGPS_Track_Aggregation::On_Execute(void) { bool bVerbose, bPolar; int Time_Span, fRefID, fX, fY, fTrack, fDate, fTime, fParameter, Observation, iDropped, nDropped; double eps_Space, eps_Time, off_Time, iTime; TSG_Point Position; CSG_String iTrack, iDate; CSG_Table_Record *pAggregate, *pObservation; CSG_Shape *pReference, *pNearest; CSG_Simple_Statistics Statistic, Time; CSG_Table *pObservations, *pAggregated, Observations; CSG_Shapes_Search Reference; //----------------------------------------------------- pObservations = Parameters("OBSERVATIONS") ->asTable (); pAggregated = Parameters("AGGREGATED") ->asTable (); fRefID = Parameters("REFERENCE_ID") ->asInt (); fX = Parameters("X") ->asInt (); fY = Parameters("Y") ->asInt (); fTrack = Parameters("TRACK") ->asInt (); fDate = Parameters("DATE") ->asInt (); fTime = Parameters("TIME") ->asInt (); fParameter = Parameters("PARAMETER") ->asInt (); Time_Span = Parameters("TIME_SPAN") ->asInt (); eps_Space = Parameters("EPS_SPACE") ->asDouble(); off_Time = Parameters("OFF_TIME") ->asDouble() * 60.0; bVerbose = Parameters("VERBOSE") ->asBool (); bPolar = Parameters("POLAR") ->asBool (); switch( Time_Span ) { default: eps_Time = 0.0; break; case 1: eps_Time = Parameters("EPS_TIME")->asDouble(); break; case 2: eps_Time = Parameters("FIX_TIME")->asDouble() * 60.0; break; } if( eps_Time <= 0.0 ) { Time_Span = 0; } //----------------------------------------------------- if( !Reference.Create(Parameters("REFERENCE")->asShapes()) ) { Error_Set(_TL("could not initialize reference point search engine")); return( false ); } //----------------------------------------------------- if( Time_Span == 2 ) // pre-processing for 'fix' time span { Observations.Create(*pObservations); Observations.Add_Field(SG_T("REF_ID"), SG_DATATYPE_String); fTrack = pObservations->Get_Field_Count(); pObservations = &Observations; for(Observation=0; ObservationGet_Count() && Set_Progress(Observation, pObservations->Get_Count()); Observation++) { pObservation = pObservations->Get_Record(Observation); pNearest = Reference.Get_Point_Nearest(pObservation->asDouble(fX), pObservation->asDouble(fY)); pObservation ->Set_Value(fTrack, pNearest->asString(fRefID)); } } //----------------------------------------------------- if( !pObservations->Set_Index(fTrack, TABLE_INDEX_Ascending, fDate, TABLE_INDEX_Ascending, fTime, TABLE_INDEX_Ascending) ) { Error_Set(_TL("could not create index on observations")); return( false ); } //----------------------------------------------------- pAggregated->Destroy(); pAggregated->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pObservations->Get_Name(), _TL("aggregated"))); pAggregated->Add_Field(SG_T("REFID") , SG_DATATYPE_String); // AGG_ID pAggregated->Add_Field(SG_T("TRACK") , SG_DATATYPE_String); // AGG_TRACK pAggregated->Add_Field(SG_T("DATE") , SG_DATATYPE_String); // AGG_DATE pAggregated->Add_Field(SG_T("TIME") , SG_DATATYPE_String); // AGG_TIME pAggregated->Add_Field(pObservations->Get_Field_Name(fParameter), SG_DATATYPE_Double); // AGG_PARM if( bVerbose ) { pAggregated->Add_Field(SG_T("MIN") , SG_DATATYPE_Double); // AGG_MIN, pAggregated->Add_Field(SG_T("MAX") , SG_DATATYPE_Double); // AGG_MAX pAggregated->Add_Field(SG_T("RANGE") , SG_DATATYPE_Double); // AGG_RANGE pAggregated->Add_Field(SG_T("STDDEV") , SG_DATATYPE_Double); // AGG_STDDEV, pAggregated->Add_Field(SG_T("COUNT") , SG_DATATYPE_Int ); // AGG_COUNT, pAggregated->Add_Field(SG_T("DROPPED") , SG_DATATYPE_Int ); // AGG_DROPPED, pAggregated->Add_Field(SG_T("DTIME") , SG_DATATYPE_Double); // AGG_DTIME, pAggregated->Add_Field(SG_T("X") , SG_DATATYPE_Double); // AGG_X pAggregated->Add_Field(SG_T("Y") , SG_DATATYPE_Double); // AGG_Y } //----------------------------------------------------- pAggregate = NULL; nDropped = 0; iDropped = 0; //----------------------------------------------------- for(Observation=0; ObservationGet_Count() && Set_Progress(Observation, pObservations->Get_Count()); Observation++) { pObservation = pObservations->Get_Record_byIndex(Observation); if( !pAggregate || iTrack.Cmp(pObservation->asString(fTrack)) || iDate .Cmp(pObservation->asString(fDate )) || (eps_Time > 0.0 && eps_Time <= pObservation->asDouble(fTime) - iTime) ) { pReference = NULL; } Position.x = pObservation->asDouble(fX); Position.y = pObservation->asDouble(fY); pNearest = Reference.Get_Point_Nearest(Position.x, Position.y); if( eps_Space > 0.0 && eps_Space <= (bPolar ? SG_Get_Distance_Polar(Position, pNearest->Get_Point(0)) : SG_Get_Distance(Position, pNearest->Get_Point(0))) ) { nDropped++; iDropped++; } else { if( pReference != pNearest ) { Set_Statistic(pAggregate, Statistic, Time, iDropped, bVerbose); Statistic .Invalidate(); Time .Invalidate(); iDropped = 0; iTrack = pObservation->asString(fTrack); iDate = pObservation->asString(fDate ); switch( Time_Span ) { default: iTime = 0.0; break; case 1: iTime = pObservation->asDouble(fTime); break; case 2: iTime = (int)(pObservation->asDouble(fTime) / eps_Time) * eps_Time - off_Time; break; } pReference = pNearest; pAggregate = pAggregated->Add_Record(); pAggregate ->Set_Value(AGG_ID , pReference->asString(fRefID)); pAggregate ->Set_Value(AGG_TRACK, iTrack); pAggregate ->Set_Value(AGG_DATE , iDate ); if( bVerbose ) { pAggregate ->Set_Value(AGG_X, pReference->Get_Point(0).x); pAggregate ->Set_Value(AGG_Y, pReference->Get_Point(0).y); } } Statistic += pObservation->asDouble(fParameter); Time += pObservation->asDouble(fTime ); } } Set_Statistic(pAggregate, Statistic, Time, iDropped, bVerbose); //----------------------------------------------------- if( nDropped > 0 ) { Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("number of dropped observations"), nDropped)); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGPS_Track_Aggregation::Set_Statistic(CSG_Table_Record *pAggregate, CSG_Simple_Statistics &Statistic, CSG_Simple_Statistics &Time, int nDropped, bool bVerbose) { if( pAggregate ) { pAggregate ->Set_Value(AGG_PARM , Statistic.Get_Mean()); pAggregate ->Set_Value(AGG_TIME , Time .Get_Mean()); if( bVerbose ) { pAggregate ->Set_Value(AGG_MIN , Statistic.Get_Minimum()); pAggregate ->Set_Value(AGG_MAX , Statistic.Get_Maximum()); pAggregate ->Set_Value(AGG_RANGE , Statistic.Get_Range ()); pAggregate ->Set_Value(AGG_STDDEV , Statistic.Get_StdDev ()); pAggregate ->Set_Value(AGG_COUNT , Statistic.Get_Count ()); pAggregate ->Set_Value(AGG_DTIME , Time .Get_Range ()); pAggregate ->Set_Value(AGG_DROPPED, nDropped); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/CreatePointGrid.h0000664000175000017500000000265012565125407025376 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CreatePointGrid.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* CreatePointGrid.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CCreatePointGrid : public CSG_Module { public: CCreatePointGrid(void); virtual ~CCreatePointGrid(void); virtual bool is_ProjectDependent(void) {return( false );} protected: virtual bool On_Execute(void); }; saga-2.2.3/src/modules/shapes/shapes_points/snap_points_to_grid.h0000664000175000017500000001013412565125407026413 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snap_points_to_grid.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // snap_points_to_grid.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__snap_points_to_grid_H #define HEADER_INCLUDED__snap_points_to_grid_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSnap_Points_to_Grid : public CSG_Module_Grid { public: CSnap_Points_to_Grid(void); protected: virtual bool On_Execute (void); private: void Snap_To_Grid (const TSG_Point &Point, CSG_Shape *pPoint, TSG_Point &snap_Point, double &snap_Dist); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__snap_points_to_grid_H saga-2.2.3/src/modules/shapes/shapes_points/AddCoordinates.cpp0000664000175000017500000000610212565125407025565 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: AddCoordinates.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* 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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, 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( "The module attaches the x- and y-coordinates of each point to the attribute table. " "For 3D shapefiles, also the z/m-coordinates are reported.\n" )); 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); int zField = 0, mField = 0; if( pShapes->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { zField = pShapes->Get_Field_Count(); pShapes->Add_Field("Z", SG_DATATYPE_Double); if( pShapes->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { mField = pShapes->Get_Field_Count(); pShapes->Add_Field("M", SG_DATATYPE_Double); } } //----------------------------------------------------- for(int i=0; iGet_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); if( pShapes->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pShape->Set_Value(zField, pShape->Get_Z(0)); if( pShapes->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShape->Set_Value(mField, pShape->Get_M(0)); } } } DataObject_Update(pShapes); return( true ); } saga-2.2.3/src/modules/shapes/shapes_points/points_filter.h0000664000175000017500000001022112565125407025225 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_filter.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // points_filter.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_filter_H #define HEADER_INCLUDED__points_filter_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_Filter : public CSG_Module { public: CPoints_Filter(void); protected: virtual bool On_Execute (void); private: int m_Method, m_nMinPoints, m_nMaxPoints; double m_Radius, m_Tolerance, m_Percentile; CSG_PRQuadTree m_Search; bool Do_Filter (TSG_Point Point, double zPoint, int Quadrant = -1); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_filter_H saga-2.2.3/src/modules/shapes/shapes_points/Clip_Points.cpp0000664000175000017500000001672012565125407025134 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Clip_Points.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // Clip_Points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Clip_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CClip_Points::CClip_Points(void) { Set_Name (_TL("Clip Points with Polygons")); Set_Author (SG_T("(c) 2008 by O.Conrad")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, 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("Add Attribute to Clipped Points"), _TL(""), true ); Parameters.Add_Shapes_List( NULL , "CLIPS" , _TL("Clipped Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Clipping Options"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("one layer for all points"), _TL("separate layer for each polygon") ), 0 ); } //--------------------------------------------------------- CClip_Points::~CClip_Points(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CClip_Points::On_Execute(void) { int Method, iField; CSG_Shapes *pPoints, *pPolygons, *pClip; CSG_Parameter_Shapes_List *pClips; //----------------------------------------------------- pPoints = Parameters("POINTS") ->asShapes(); pPolygons = Parameters("POLYGONS") ->asShapes(); pClips = Parameters("CLIPS") ->asShapesList(); Method = Parameters("METHOD") ->asInt(); iField = Parameters("FIELD") ->asInt(); //----------------------------------------------------- if( !pPoints->is_Valid() ) { Message_Add(_TL("Invalid points layer.")); return( false ); } else if( !pPolygons->is_Valid() ) { Message_Add(_TL("Invalid polygon layer.")); return( false ); } //----------------------------------------------------- if( iField >= pPolygons->Get_Field_Count() ) { iField = -1; } pClips->Del_Items(); if( Method == 0 ) { pClip = SG_Create_Shapes(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), pPolygons->Get_Name()), pPoints); if( iField >= 0 ) { pClip->Add_Field(pPolygons->Get_Field_Name(iField), pPolygons->Get_Field_Type(iField)); } } //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); if( Method == 1 ) { CSG_String Name(pPoints->Get_Name()); Name += iField >= 0 ? CSG_String::Format(SG_T(" [%s]"), pPolygon->asString(iField)) : CSG_String::Format(SG_T(" [%00d]"), 1 + pClips->Get_Count()); pClip = SG_Create_Shapes(SHAPE_TYPE_Point, Name, pPoints); if( iField >= 0 ) { pClip->Add_Field(pPolygons->Get_Field_Name(iField), pPolygons->Get_Field_Type(iField)); } } for(int iPoint=0; iPointGet_Count() && Process_Get_Okay(false); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); if( pPolygon->Contains(pPoint->Get_Point(0)) ) { pPoint = pClip->Add_Shape(pPoint, SHAPE_COPY); if( iField >= 0 ) { pPoint->Set_Value(pPoints->Get_Field_Count(), pPolygon->asString(iField)); } } } if( Method == 1 ) { if( pClip->Get_Count() > 0 ) { pClips->Add_Item(pClip); } else { delete(pClip); } } } //----------------------------------------------------- if( Method == 0 ) { if( pClip->Get_Count() > 0 ) { pClips->Add_Item(pClip); } else { delete(pClip); } } return( pClips->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/separate_by_direction.cpp0000664000175000017500000001654112565125407027250 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: separate_by_direction.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // separate_by_direction.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "separate_by_direction.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSeparate_by_Direction::CSeparate_by_Direction(void) { Set_Name (_TL("Separate points by direction")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "Separates points by direction. Direction is determined as average direction of three consecutive points A, B, C. " "If the angle between the directions of A-B and B-C is higher than given tolerance angle the point is dropped. " "This module has been designed to separate GPS tracks recorded by tractors while preparing a field. " )); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL , "OUTPUT" , _TL("Ouput"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "DIRECTIONS" , _TL("Number of Directions"), _TL(""), PARAMETER_TYPE_Double , 4.0, 2.0, true ); Parameters.Add_Value( NULL , "TOLERANCE" , _TL("Tolerance (Degree)"), _TL(""), PARAMETER_TYPE_Double , 5.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSeparate_by_Direction::On_Execute(void) { int iSector, dir_Field; CSG_Shapes *pPoints; CSG_Parameter_Shapes_List *pOutput; //----------------------------------------------------- pOutput = Parameters("OUTPUT") ->asShapesList(); pPoints = Parameters("POINTS") ->asShapes(); m_Tolerance = Parameters("TOLERANCE") ->asDouble() * M_DEG_TO_RAD; m_nSectors = Parameters("DIRECTIONS") ->asInt(); m_dSector = M_PI_360 / m_nSectors; if( !pPoints || !pPoints->is_Valid() || pPoints->Get_Count() < 3 ) { return( false ); } //----------------------------------------------------- pOutput->Del_Items(); dir_Field = pPoints->Get_Field_Count(); for(iSector=0; iSectorAdd_Item(SG_Create_Shapes(SHAPE_TYPE_Point, CSG_String::Format(SG_T("Direction %.2f"), iSector * m_dSector * M_RAD_TO_DEG), pPoints)); pOutput->asShapes(iSector)->Add_Field(_TL("Direction"), SG_DATATYPE_Double); } //----------------------------------------------------- int iPoint; double dir_A, dir_B, dir, dif; CSG_Shape *pt_A, *pt_B; pt_B = pPoints->Get_Shape(pPoints->Get_Count() - 2); pt_A = pPoints->Get_Shape(pPoints->Get_Count() - 1); dir_A = SG_Get_Angle_Of_Direction(pt_B->Get_Point(0), pt_A->Get_Point(0)); for(iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { pt_B = pt_A; pt_A = pPoints->Get_Shape(iPoint); dir_B = dir_A; dir_A = SG_Get_Angle_Of_Direction(pt_B->Get_Point(0), pt_A->Get_Point(0)); dif = fmod(dir_A - dir_B, M_PI_360); if( dif > M_PI_180 ) { dif -= M_PI_360; } else if( dif < -M_PI_180 ) { dif += M_PI_360; } if( fabs(dif) <= m_Tolerance ) { dir = dir_B + 0.5 * dif; iSector = (int)(fmod(M_PI_360 + 0.5 * m_dSector + dir, M_PI_360) / m_dSector); if( iSector >= 0 && iSector < m_nSectors ) { pOutput->asShapes(iSector)->Add_Shape(pt_B)->Set_Value(dir_Field, dir * M_RAD_TO_DEG); } } } //----------------------------------------------------- for(iSector=pOutput->Get_Count()-1; iSector>=0; iSector--) { if( pOutput->asShapes(iSector)->Get_Count() == 0 ) { delete(pOutput->asShapes(iSector)); pOutput->Del_Item(iSector); } } //----------------------------------------------------- return( pOutput->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/points_thinning.cpp0000664000175000017500000002261512565125407026123 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_thinning.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // points_thinning.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "points_thinning.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_Thinning::CPoints_Thinning(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Points Thinning")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- 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_Shapes( NULL , "THINNED" , _TL("Thinned Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "RESOLUTION" , _TL("Resolution"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_Thinning::On_Execute(void) { int Field; CSG_Shapes *pPoints; //----------------------------------------------------- pPoints = Parameters("POINTS") ->asShapes(); Field = Parameters("FIELD") ->asInt(); m_pPoints = Parameters("THINNED") ->asShapes(); m_Resolution = Parameters("RESOLUTION") ->asDouble(); //----------------------------------------------------- if( m_Resolution <= 0.0 ) { Error_Set(_TL("resolution has to be greater than zero")); return( false ); } if( !pPoints->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( pPoints->Get_Count() < 2 ) { Error_Set(_TL("not more than one point in layer")); return( false ); } if( !Set_Search_Engine(pPoints, Field) ) { Error_Set(_TL("failed to initialise search engine")); return( false ); } //----------------------------------------------------- m_pPoints->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), pPoints->Get_Field_Name(Field))); m_pPoints->Add_Field(_TL("Count") , SG_DATATYPE_Int); m_pPoints->Add_Field(_TL("Mean") , SG_DATATYPE_Double); m_pPoints->Add_Field(_TL("Minimun") , SG_DATATYPE_Double); m_pPoints->Add_Field(_TL("Maximun") , SG_DATATYPE_Double); m_pPoints->Add_Field(_TL("StdDev") , SG_DATATYPE_Double); pPoints->Select(); //----------------------------------------------------- Get_Points(m_Search.Get_Root_Pointer()); //----------------------------------------------------- if( m_pPoints->Get_Count() == pPoints->Get_Count() ) { Message_Add(_TL("no points removed")); } else { Message_Add(CSG_String::Format(SG_T("%d %s"), pPoints->Get_Count() - m_pPoints->Get_Count(), _TL("no points removed"))); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_Thinning::Set_Search_Engine(CSG_Shapes *pPoints, int Field) { CSG_Rect r(pPoints->Get_Extent()); r.Assign( r.Get_XCenter() - 0.5 * m_Resolution, r.Get_YCenter() - 0.5 * m_Resolution, r.Get_XCenter() + 0.5 * m_Resolution, r.Get_YCenter() + 0.5 * m_Resolution ); while( r.Intersects(pPoints->Get_Extent()) != INTERSECTION_Contains ) { r.Inflate(200.0); } if( !m_Search.Create(r, true) ) { return( false ); } for(int i=0; iGet_Count() && Set_Progress(i, pPoints->Get_Count()); i++) { CSG_Shape *pPoint = pPoints->Get_Shape(i); m_Search.Add_Point( pPoint->Get_Point(0).x, pPoint->Get_Point(0).y, pPoint->asDouble(Field) ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_Thinning::Get_Points(CSG_PRQuadTree_Item *pItem) { if( pItem ) { if( pItem->is_Leaf() ) { Add_Point(pItem->asLeaf()); } else if( pItem->Get_Size() <= m_Resolution ) { Add_Point((CSG_PRQuadTree_Node_Statistics *)pItem); } else { for(int i=0; i<4; i++) { Get_Points(pItem->asNode()->Get_Child(i)); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_Thinning::Add_Point(CSG_PRQuadTree_Leaf *pLeaf) { CSG_Shape *pPoint = m_pPoints->Add_Shape(); pPoint->Add_Point(pLeaf->Get_X(), pLeaf->Get_Y()); if( pLeaf->has_Statistics() ) { CSG_PRQuadTree_Leaf_List *pList = (CSG_PRQuadTree_Leaf_List *)pLeaf; pPoint->Set_Value(0, pList->Get_Count()); // Count pPoint->Set_Value(1, pList->Get_Mean()); // Mean pPoint->Set_Value(2, pList->Get_Minimum()); // Minimun pPoint->Set_Value(3, pList->Get_Maximum()); // Maximun pPoint->Set_Value(4, pList->Get_StdDev()); // StdDev } else { pPoint->Set_Value(0, 1); // Count pPoint->Set_Value(1, pLeaf->Get_Z()); // Mean pPoint->Set_Value(2, pLeaf->Get_Z()); // Minimun pPoint->Set_Value(3, pLeaf->Get_Z()); // Maximun pPoint->Set_Value(4, 0.0); // StdDev } } //--------------------------------------------------------- void CPoints_Thinning::Add_Point(CSG_PRQuadTree_Node_Statistics *pNode) { CSG_Shape *pPoint = m_pPoints->Add_Shape(); pPoint->Add_Point(pNode->Get_X()->Get_Mean(), pNode->Get_Y()->Get_Mean()); pPoint->Set_Value(0, pNode->Get_Z()->Get_Count()); // Count pPoint->Set_Value(1, pNode->Get_Z()->Get_Mean()); // Mean pPoint->Set_Value(2, pNode->Get_Z()->Get_Minimum()); // Minimun pPoint->Set_Value(3, pNode->Get_Z()->Get_Maximum()); // Maximun pPoint->Set_Value(4, pNode->Get_Z()->Get_StdDev()); // StdDev } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/select_points.cpp0000664000175000017500000001616312565125407025565 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // select_points.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "select_points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelect_Points::CSelect_Points(void) { Set_Name (_TL("Select Points")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "SELECTION" , _TL("Selection"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Radius"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL , "MAXNUM" , _TL("Maximum Number of Points"), _TL(""), PARAMETER_TYPE_Int, 0.0, 0.0, true ); Parameters.Add_Choice( NULL , "QUADRANT" , _TL("Quadrant"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("all quadrants"), _TL("1. quadrant (upper right)"), _TL("2. quadrant (lower right)"), _TL("3. quadrant (lower left)"), _TL("4. quadrant (upper left)") ), 0 ); Parameters.Add_Value( NULL , "ADDCENTER" , _TL("Add Center"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_Points::On_Execute(void) { //----------------------------------------------------- m_pPoints = Parameters("POINTS") ->asShapes(); m_pSelection = Parameters("SELECTION") ->asShapes(); m_Radius = Parameters("RADIUS") ->asDouble(); m_MaxPoints = Parameters("MAXNUM") ->asInt(); m_Quadrant = Parameters("QUADRANT") ->asInt() - 1; m_bAddCenter = Parameters("ADDCENTER") ->asBool(); //----------------------------------------------------- if( !m_pPoints->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( m_pPoints->Get_Count() <= 0 ) { Error_Set(_TL("no points in layer")); return( false ); } if( !m_Search.Create(m_pPoints, -1) ) { Error_Set(_TL("failed to initialise search engine")); return( false ); } //----------------------------------------------------- m_pSelection->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), m_pPoints->Get_Name(), _TL("Selection")), m_pPoints); m_pSelection->Add_Field(_TL("Order") , SG_DATATYPE_Int); m_pSelection->Add_Field(_TL("Distance") , SG_DATATYPE_Double); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_Points::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { switch( Mode ) { case MODULE_INTERACTIVE_LUP: m_pSelection->Del_Records(); if( m_bAddCenter ) { m_pSelection->Add_Shape()->Add_Point(ptWorld); } if( m_Search.Select_Nearest_Points(ptWorld.Get_X(), ptWorld.Get_Y(), m_MaxPoints, m_Radius, m_Quadrant) ) { for(int i=0; iAdd_Shape(m_pPoints->Get_Shape((int)m_Search.Get_Selected_Z(i))); pPoint->Set_Value(m_pSelection->Get_Field_Count() - 2, i + 1); pPoint->Set_Value(m_pSelection->Get_Field_Count() - 1, m_Search.Get_Selected_Distance(i)); } } DataObject_Update(m_pSelection); break; default: break; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/MLB_Interface.cpp0000664000175000017500000001351412565125407025301 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2281 2014-10-09 15:49:41Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: volaya@ya.com // // // // contact: Victor Olaya Ferrero // // Madrid // // Spain // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Points") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( _TL("Various Authors") ); case MLB_INFO_Description: return( _TL("Tools for the manipulation of point vector data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Points") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Points_From_Table.h" #include "Points_From_Lines.h" #include "CountPoints.h" #include "CreatePointGrid.h" #include "DistanceMatrix.h" #include "FitNPointsToShape.h" #include "AddCoordinates.h" #include "remove_duplicates.h" #include "Clip_Points.h" #include "separate_by_direction.h" #include "add_polygon_attributes.h" #include "points_filter.h" #include "convex_hull.h" #include "select_points.h" #include "points_thinning.h" #include "thiessen_polygons.h" #include "gps_track_aggregation.h" #include "snap_points_to_features.h" #include "snap_points_to_grid.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... 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 10: return( new CAdd_Polygon_Attributes ); case 11: return( new CPoints_Filter ); case 12: return( new CConvex_Hull ); case 13: return( new CSelect_Points ); case 14: return( new CPoints_Thinning ); case 15: return( new CPoints_From_MultiPoints ); case 16: return( new CThiessen_Polygons ); case 17: return( new CGPS_Track_Aggregation ); case 18: return( new CSnap_Points_to_Features(SHAPE_TYPE_Point) ); case 19: return( new CSnap_Points_to_Features(SHAPE_TYPE_Line) ); case 20: return( new CSnap_Points_to_Grid() ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/shapes/shapes_points/Makefile.am0000664000175000017500000000256312565125407024241 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1568 2012-12-14 13:00:29Z oconrad $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_points.la libshapes_points_la_SOURCES =\ add_polygon_attributes.cpp\ AddCoordinates.cpp\ Clip_Points.cpp\ convex_hull.cpp\ CountPoints.cpp\ CreatePointGrid.cpp\ DistanceMatrix.cpp\ FitNPointsToShape.cpp\ gps_track_aggregation.cpp\ MLB_Interface.cpp\ points_filter.cpp\ Points_From_Lines.cpp\ Points_From_Table.cpp\ points_thinning.cpp\ remove_duplicates.cpp\ select_points.cpp\ separate_by_direction.cpp\ snap_points_to_features.cpp\ snap_points_to_grid.cpp\ thiessen_polygons.cpp\ add_polygon_attributes.h\ AddCoordinates.h\ convex_hull.h\ CountPoints.h\ Clip_Points.h\ CreatePointGrid.h\ DistanceMatrix.h\ FitNPointsToShape.h\ gps_track_aggregation.h\ MLB_Interface.h\ points_filter.h\ Points_From_Lines.h\ Points_From_Table.h\ points_thinning.h\ remove_duplicates.h\ select_points.h\ separate_by_direction.h\ snap_points_to_features.h\ snap_points_to_grid.h\ thiessen_polygons.h libshapes_points_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/shapes/shapes_points/remove_duplicates.h0000664000175000017500000001052412565125407026064 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: remove_duplicates.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Remove_Duplicates.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Remove_Duplicates_H #define HEADER_INCLUDED__Remove_Duplicates_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CRemove_Duplicates : public CSG_Module { public: CRemove_Duplicates(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_Field, m_Method, m_Numeric; CSG_Shapes *m_pPoints; void Set_Attributes (CSG_Shape *pPoint, CSG_PRQuadTree_Leaf_List *pList); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Remove_Duplicates_H saga-2.2.3/src/modules/shapes/shapes_points/MLB_Interface.h0000664000175000017500000000744512565125407024754 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2004 by // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: volaya@ya.com // // // // contact: Victor Olaya Ferrero // // Madrid // // Spain // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__shapes_points_H #define HEADER_INCLUDED__shapes_points_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef shapes_points_EXPORTS #define shapes_points_EXPORT _SAGA_DLL_EXPORT #else #define shapes_points_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_points_H saga-2.2.3/src/modules/shapes/shapes_points/snap_points_to_grid.cpp0000664000175000017500000001762012565125407026755 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snap_points_to_grid.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // snap_points_to_grid.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "snap_points_to_grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSnap_Points_to_Grid::CSnap_Points_to_Grid(void) { //----------------------------------------------------- Set_Name (_TL("Snap Points to Grid")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Moves all points to grid cell positions that have the highest or" "lowest value respectively within the given search distance around " "each point." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "MOVES" , _TL("Moves"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "DISTANCE" , _TL("Search Distance (Map Units)"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Choice( NULL , "SHAPE" , _TL("Search Shape"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("circle"), _TL("square") ), 0 ); Parameters.Add_Choice( NULL , "EXTREME" , _TL("Extreme"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("minimum"), _TL("maximum") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSnap_Points_to_Grid::On_Execute(void) { double Distance, Sign; CSG_Shapes *pInput, *pPoints, *pMoves; CSG_Grid *pGrid; //----------------------------------------------------- pInput = Parameters("INPUT" )->asShapes(); pPoints = Parameters("OUTPUT" )->asShapes(); pGrid = Parameters("GRID" )->asGrid(); pMoves = Parameters("MOVES" )->asShapes(); Distance = Parameters("DISTANCE")->asDouble() / Get_Cellsize(); Sign = Parameters("EXTREME" )->asInt() == 1 ? 1 : -1; //----------------------------------------------------- if( !pInput->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( pInput->Get_Extent().Intersects(pGrid->Get_Extent()) == INTERSECTION_None ) { Error_Set(_TL("points layer and grid do not intersect at all")); return( false ); } if( Distance < 0.5 ) { if( !Error_Set(_TL("search distance is less than half of grid cell size")) ) // ignore { return( false ); } } //----------------------------------------------------- if( pPoints && pPoints != pInput ) { pPoints->Create(*pInput); } else { Parameters("RESULT")->Set_Value(pPoints = pInput); } pPoints->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pInput->Get_Name(), _TL("snapped"), pGrid->Get_Name())); if( pMoves ) { pMoves->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pInput->Get_Name(), _TL("snap move"), pGrid->Get_Name()), pPoints); } //----------------------------------------------------- CSG_Grid_Cell_Addressor Search; Search.Set_Radius(Distance, Parameters("SHAPE")->asInt() == 1); //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); TSG_Point Point = pPoint->Get_Point(0); int x = Get_System()->Get_xWorld_to_Grid(Point.x); int y = Get_System()->Get_yWorld_to_Grid(Point.y); int iMax = -1; double dMax; for(int i=0; iis_InGrid(ix, iy) ) { if( iMax < 0 || dMax < Sign * pGrid->asDouble(ix, iy) ) { iMax = i; dMax = Sign * pGrid->asDouble(ix, iy); } } } //------------------------------------------------- if( iMax >= 0 ) { TSG_Point snap_Point = pGrid->Get_System().Get_Grid_to_World(Search.Get_X(iMax, x), Search.Get_Y(iMax, y)); if( SG_Get_Distance(Point, snap_Point) > 0.0 ) { pPoint->Set_Point(snap_Point, 0); if( pMoves ) { CSG_Shape *pMove = pMoves->Add_Shape(pPoint, SHAPE_COPY_ATTR); pMove->Add_Point(Point); pMove->Add_Point(snap_Point); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/add_polygon_attributes.h0000664000175000017500000000776312565125407027132 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: add_polygon_attributes.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 saga-2.2.3/src/modules/shapes/shapes_points/Points_From_Lines.h0000664000175000017500000000660512565125407025750 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Points_From_Lines.h 2545 2015-07-28 07:46:45Z reklov_w $ *********************************************************/ /******************************************************************************* Points_From_Lines.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Points_From_Lines_H #define HEADER_INCLUDED__Points_From_Lines_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_From_Lines : public CSG_Module { public: CPoints_From_Lines(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); void Convert_Add_Points_Segment (CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder); void Convert_Add_Points_Line (CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder); void Convert_Add_Points_Center (CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder); void Convert (CSG_Shapes *pLines, CSG_Shapes *pPoints, bool bAddPtOrder); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_From_MultiPoints : public CSG_Module { public: CPoints_From_MultiPoints(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Points_From_Lines_H saga-2.2.3/src/modules/shapes/shapes_points/CountPoints.h0000664000175000017500000000372512565125407024644 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CountPoints.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* CountPoints.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCountPoints : public CSG_Module { public: CCountPoints(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/DistanceMatrix.cpp0000664000175000017500000001520312565125407025623 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: DistanceMatrix.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* DistanceMatrix.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "DistanceMatrix.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDistanceMatrix::CDistanceMatrix(void) { CSG_Parameter *pNode; Set_Name (_TL("Point Distances")); Set_Author ("V.Olaya (c) 2004, O.Conrad (c) 2014"); Set_Description (_TW( "Computes distances between pairs of points." )); pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "ID_POINTS" , _TL("Identifier"), _TL(""), true ); pNode = Parameters.Add_Shapes( NULL , "NEAR" , _TL("Near Points"), _TL(""), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "ID_NEAR" , _TL("Identifier"), _TL(""), true ); Parameters.Add_Table( NULL , "DISTANCES" , _TL("Distances"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "FORMAT" , _TL("Output Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("complete input times near points matrix"), _TL("each pair with a single record") ), 1 ); Parameters.Add_Value( NULL , "MAX_DIST" , _TL("Maximum Distance"), _TL("ignored if set to zero (consider all pairs)"), PARAMETER_TYPE_Double, 0.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CDistanceMatrix::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "FORMAT") ) { pParameters->Get_Parameter("MAX_DIST")->Set_Enabled(pParameter->asInt() == 1); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "NEAR") ) { pParameters->Get_Parameter("ID_NEAR")->Set_Enabled(pParameter->asShapes() != NULL); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_ID(p, id, i) (id < 0 ? CSG_String::Format(SG_T("%d"), i + 1) : CSG_String(p->Get_Shape(i)->asString(id))) //--------------------------------------------------------- bool CDistanceMatrix::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS" )->asShapes(); int id_Points = Parameters("ID_POINTS")->asInt (); CSG_Shapes *pNear = Parameters("NEAR" )->asShapes(); int id_Near = Parameters("ID_NEAR" )->asInt (); CSG_Table *pDistances = Parameters("DISTANCES")->asTable (); double max_Dist = Parameters("MAX_DIST" )->asDouble(); //----------------------------------------------------- if( pNear == NULL ) { pNear = pPoints; id_Near = id_Points; } pDistances->Destroy(); if( pPoints != pNear ) { pDistances->Set_Name(CSG_String::Format(SG_T("%s [%s / %s]"), _TL("Distances"), pPoints->Get_Name(), pNear->Get_Name())); } else { pDistances->Set_Name(CSG_String::Format(SG_T("%s [%s]"), _TL("Distances"), pPoints->Get_Name())); } //----------------------------------------------------- if( Parameters("FORMAT")->asInt() == 1 ) { pDistances->Add_Field("ID_POINT", SG_DATATYPE_String); pDistances->Add_Field("ID_NEAR" , SG_DATATYPE_String); pDistances->Add_Field("DISTANCE", SG_DATATYPE_Double); for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { TSG_Point Point = pPoints->Get_Shape(iPoint)->Get_Point(0); for(int iNear=0; iNearGet_Count(); iNear++) { if( pPoints != pNear || iPoint != iNear ) { double Distance = SG_Get_Distance(Point, pNear->Get_Shape(iNear)->Get_Point(0)); if( Distance <= max_Dist || max_Dist <= 0.0 ) { CSG_Table_Record *pRecord = pDistances->Add_Record(); pRecord->Set_Value(0, GET_ID(pPoints, id_Points, iPoint)); pRecord->Set_Value(1, GET_ID(pNear , id_Near , iNear )); pRecord->Set_Value(2, Distance); } } } } } //----------------------------------------------------- else // Matrix { int iNear; pDistances->Add_Field("ID_POINT", SG_DATATYPE_String); for(iNear=0; iNearGet_Count(); iNear++) { pDistances->Add_Field(GET_ID(pNear, id_Near, iNear), SG_DATATYPE_Double); } for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { TSG_Point Point = pPoints->Get_Shape(iPoint)->Get_Point(0); CSG_Table_Record *pRecord = pDistances->Add_Record(); pRecord->Set_Value(0, GET_ID(pPoints, id_Points, iPoint)); for(iNear=0; iNearGet_Count(); iNear++) { pRecord->Set_Value(1 + iNear, SG_Get_Distance(Point, pNear->Get_Shape(iNear)->Get_Point(0))); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_points/CreatePointGrid.cpp0000664000175000017500000000550012565125407025726 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CreatePointGrid.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* CreatePointGrid.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "CreatePointGrid.h" CCreatePointGrid::CCreatePointGrid(void){ Parameters.Set_Name(_TL("Create Point Grid")); Parameters.Set_Description(_TW( "(c) 2004 by Victor Olaya. Creates a regular grid of points.")); Parameters.Add_Shapes(NULL, "POINTS", _TL("Point Grid"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Range(NULL, "X_EXTENT", _TL("X-Extent"), _TL("")); Parameters.Add_Range(NULL, "Y_EXTENT", _TL("Y-Extent"), _TL("")); Parameters.Add_Value(NULL, "DIST", _TL("Distance"), _TL("Distance between points (grid units)."), PARAMETER_TYPE_Double, 100); }//constructor CCreatePointGrid::~CCreatePointGrid(void) {} bool CCreatePointGrid::On_Execute(void){ CSG_Shape *pShape; double dXMin = ((CSG_Parameter_Range *) Parameters("X_EXTENT")->Get_Data())->Get_LoVal(); double dYMin = ((CSG_Parameter_Range *) Parameters("Y_EXTENT")->Get_Data())->Get_LoVal(); double dXMax = ((CSG_Parameter_Range *) Parameters("X_EXTENT")->Get_Data())->Get_HiVal(); double dYMax = ((CSG_Parameter_Range *) Parameters("Y_EXTENT")->Get_Data())->Get_HiVal(); double dDistance = Parameters("DIST")->asDouble(); if (dDistance<=0){ return false; }//if CSG_Shapes *pShapes = Parameters("POINTS")->asShapes(); pShapes->Create(SHAPE_TYPE_Point, _TL("Point Grid")); pShapes->Add_Field("X", SG_DATATYPE_Double); pShapes->Add_Field("Y", SG_DATATYPE_Double); for (double x=dXMin; xAdd_Shape(); pShape->Add_Point(x,y); pShape->Set_Value(0, x); pShape->Set_Value(1, y); }//for }//for return true; }//method saga-2.2.3/src/modules/shapes/shapes_points/Points_From_Table.cpp0000664000175000017500000000741112565125407026254 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Points_From_Table.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* Points_From_Table.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Points_From_Table.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_From_Table::CPoints_From_Table(void) { CSG_Parameter *pNode; Set_Name (_TL("Convert Table to Points")); Set_Author (_TL("Victor Olaya (c) 2004")); Set_Description (_TW( "Create Point Theme From Table" )); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "X" , _TL("X"), _TL("") ); Parameters.Add_Table_Field( pNode , "Y" , _TL("Y"), _TL("") ); Parameters.Add_Table_Field( pNode , "Z" , _TL("Z"), _TL(""), true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_From_Table::On_Execute(void) { int xField, yField, zField; CSG_Table *pTable; CSG_Shapes *pShapes; pTable = Parameters("TABLE") ->asTable(); pShapes = Parameters("POINTS") ->asShapes(); xField = Parameters("X") ->asInt(); yField = Parameters("Y") ->asInt(); zField = Parameters("Z") ->asInt(); if( pTable->Get_Field_Count() < 1 || pTable->Get_Record_Count() <= 0 ) { return( false ); } pShapes->Create(SHAPE_TYPE_Point, pTable->Get_Name(), pTable, zField < 0 ? SG_VERTEX_TYPE_XY : SG_VERTEX_TYPE_XYZ); for(int iRecord=0; iRecordGet_Record_Count() && Set_Progress(iRecord, pTable->Get_Record_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); if( !pRecord->is_NoData(xField) && !pRecord->is_NoData(yField) ) { CSG_Shape *pShape = pShapes->Add_Shape(pRecord, SHAPE_COPY_ATTR); pShape->Add_Point(pRecord->asDouble(xField), pRecord->asDouble(yField)); if( zField >= 0 ) { pShape->Set_Z(pRecord->asDouble(zField), 0); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_transect/0000775000175000017500000000000012634325746022513 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/shapes/shapes_transect/Polygon_Transect.h0000664000175000017500000001027112565125410026144 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Transect.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 saga-2.2.3/src/modules/shapes/shapes_transect/Makefile.in0000664000175000017500000005437612622651172024567 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_transect_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_transect_la_OBJECTS = Polygon_Transect.lo \ MLB_Interface.lo libshapes_transect_la_OBJECTS = $(am_libshapes_transect_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_transect_la_SOURCES) DIST_SOURCES = $(libshapes_transect_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1789 2013-08-20 08:28:18Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version -avoid-version pkglib_LTLIBRARIES = libshapes_transect.la libshapes_transect_la_SOURCES = \ Polygon_Transect.h\ MLB_Interface.h\ Polygon_Transect.cpp\ MLB_Interface.cpp libshapes_transect_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) --foreign src/modules/shapes/shapes_transect/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign 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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_transect.la: $(libshapes_transect_la_OBJECTS) $(libshapes_transect_la_DEPENDENCIES) $(EXTRA_libshapes_transect_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_transect_la_OBJECTS) $(libshapes_transect_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Transect.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/shapes/shapes_transect/Polygon_Transect.cpp0000664000175000017500000003066312565125410026506 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Transect.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Transect.h" #include #include 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" "
    |  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"
                        "|   ...     |   ...   |  ...  |     ...      |
    \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; iLineGet_Count() && Set_Progress(iLine, pTransect->Get_Count()); iLine++) { pLine =(CSG_Shape_Line *) pTransect->Get_Shape(iLine); for (int iLinePart=0;iLinePartGet_Part_Count();iLinePart++) { CSG_Shape_Part *pLinePart =pLine->Get_Part(iLinePart); CSG_Rect LinePartExtent = pLinePart->Get_Extent(); map > LineBorders; for (int iShape=0; iShapeGet_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; iPartGet_Part_Count(); iPart++) { CSG_Shape_Polygon_Part *pPart = (CSG_Shape_Polygon_Part *) pTheme_Shape->Get_Part(iPart); if (pPart->Contains(pLinePart->Get_Point(0))) LineBorders[iShape].push_back(0); if (pPart->Contains(pLinePart->Get_Point(pLinePart->Get_Count()))) LineBorders[iShape].push_back(pLine->Get_Length(iLinePart)); for (int iPoint=0; iPointGet_Count();iPoint++) { int iPoint2 = (iPoint!=pPart->Get_Count()-1)?iPoint+1:0; TSG_Point Crossing; double Length=0; for (int iLinePartPoint=0; iLinePartPointGet_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 >::iterator shapeit=LineBorders.begin();shapeit!=LineBorders.end();++shapeit) { //shapeit->second.sort(); bool start=1; for (list::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 ); } saga-2.2.3/src/modules/shapes/shapes_transect/MLB_Interface.cpp0000664000175000017500000001161412565125410025601 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2281 2014-10-09 15:49:41Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Transects" )); case MLB_INFO_Category: return( _TL("Shapes") ); 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 saga-2.2.3/src/modules/shapes/shapes_transect/Makefile.am0000664000175000017500000000121512565125410024533 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1789 2013-08-20 08:28:18Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version -avoid-version pkglib_LTLIBRARIES = libshapes_transect.la libshapes_transect_la_SOURCES =\ Polygon_Transect.h\ MLB_Interface.h\ Polygon_Transect.cpp\ MLB_Interface.cpp libshapes_transect_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/shapes/shapes_transect/MLB_Interface.h0000664000175000017500000000767312565125410025260 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 //--------------------------------------------------------- #ifdef transect_EXPORTS #define transect_EXPORT _SAGA_DLL_EXPORT #else #define transect_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__transect_H saga-2.2.3/src/modules/shapes/shapes_grid/0000775000175000017500000000000012634325746021615 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/shapes/shapes_grid/Grid_To_Contour.h0000664000175000017500000001317312565125410025020 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_To_Contour.h 2483 2015-04-30 15:36:20Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Contour.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_To_Contour_H #define HEADER_INCLUDED__Grid_To_Contour_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_To_Contour : public CSG_Module { public: CGrid_To_Contour(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Vectorization") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool m_bParts; CSG_Grid *m_pGrid, m_Edge; CSG_Shapes *m_pContours, *m_pPolygons; bool is_Edge (int x, int y); void Set_Row (int x, int y, bool bOn); bool Get_Row (int x, int y); void Set_Col (int x, int y, bool bOn); bool Get_Col (int x, int y); bool Get_Contour (double z); bool Get_Contour (double z, int x, int y); bool Get_Contour_Cell (int &Dir, int &x, int &y, bool &bRow); bool Get_Polygons (CSG_Shape_Line *pContour_Lo, CSG_Shape_Line *pContour_Hi); bool Add_Contour (CSG_Shapes &Segments, CSG_Shape_Polygon *pPolygon, CSG_Shape_Line *pContour); bool Add_Edge (CSG_Shapes &Segments, int x, int y); bool Add_Segment (CSG_Shape *pPolygon, int iPart, CSG_Shape *pContour, bool bAscending); CSG_Shape * Get_Segment (const CSG_Shapes &Segments, int &x, int &y, bool &bAscending); bool Split_Polygon_Parts (CSG_Shapes *pPolygons); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_To_Contour_H saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Statistics_AddTo_Polygon.h0000664000175000017500000001170412565125410027637 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Statistics_AddTo_Polygon.h 2443 2015-03-18 19:52:26Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Statistics_AddTo_Polygon.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Statistics_AddTo_Polygon_H #define HEADER_INCLUDED__Grid_Statistics_AddTo_Polygon_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Statistics_AddTo_Polygon : public CSG_Module_Grid { public: CGrid_Statistics_AddTo_Polygon(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Grid Values") ); } protected: virtual bool On_Execute (void); private: CSG_Grid m_Index; bool Get_Statistics (CSG_Grid *pGrid, CSG_Shapes *pPolygons, CSG_Simple_Statistics *Statistics, bool bQuantiles); bool Get_Statistics_Alt (CSG_Grid *pGrid, CSG_Shapes *pPolygons, CSG_Simple_Statistics *Statistics, bool bQuantiles); bool Get_Index (CSG_Shapes *pPolygons); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Statistics_AddTo_Polygon_H saga-2.2.3/src/modules/shapes/shapes_grid/Grid_To_Contour.cpp0000664000175000017500000006240712565125410025357 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_To_Contour.cpp 2487 2015-05-06 12:06:58Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Contour.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_To_Contour.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_To_Contour::CGrid_To_Contour(void) { //----------------------------------------------------- Set_Name (_TL("Contour Lines from Grid")); Set_Author ("O.Conrad (c) 2001"); Set_Description (_TW( "Derive contour lines (isolines) from grid. " )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "CONTOUR" , _TL("Contour"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "VERTEX" , _TL("Vertex Type"), _TL("choose vertex type for resulting contours"), CSG_String::Format("%s|%s|", SG_T("x, y"), SG_T("x, y, z") ), 0 ); Parameters.Add_Value( NULL , "SCALE" , _TL("Interpolation Scale"), _TL("set greater one for line smoothing"), PARAMETER_TYPE_Double, 1.0, 0, true ); Parameters.Add_Value( NULL , "LINE_PARTS" , _TL("Split Parts"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "POLY_PARTS" , _TL("Split Polygon Parts"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "ZMIN" , _TL("Minimum Contour Value"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( NULL , "ZMAX" , _TL("Maximum Contour Value"), _TL(""), PARAMETER_TYPE_Double, 10000.0 ); Parameters.Add_Value( NULL , "ZSTEP" , _TL("Equidistance"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_To_Contour::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "GRID") && pParameter->asGrid() != NULL ) { double zStep = SG_Get_Rounded_To_SignificantFigures(pParameter->asGrid()->Get_ZRange() / 10.0, 1); pParameters->Get_Parameter("ZSTEP")->Set_Value(zStep); pParameters->Set_Enabled("ZMAX", zStep > 0.0); if( zStep > 0.0 ) { pParameters->Get_Parameter("ZMIN")->Set_Value(zStep * floor(pParameter->asGrid()->Get_ZMin() / zStep)); pParameters->Get_Parameter("ZMAX")->Set_Value(zStep * ceil (pParameter->asGrid()->Get_ZMax() / zStep)); } else { pParameters->Get_Parameter("ZMIN")->Set_Value(pParameter->asGrid()->Get_ZMin()); pParameters->Get_Parameter("ZMAX")->Set_Value(pParameter->asGrid()->Get_ZMax()); } } return( 0 ); } //--------------------------------------------------------- int CGrid_To_Contour::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "ZSTEP") ) { pParameters->Set_Enabled("ZMAX", pParameter->asDouble() > 0.0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "POLYGONS") ) { pParameters->Set_Enabled("LINE_PARTS", pParameter->asShapes() == NULL); pParameters->Set_Enabled("POLY_PARTS", pParameter->asShapes() != NULL); } return( 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Contour::On_Execute(void) { CSG_Grid Grid; //----------------------------------------------------- m_pGrid = Parameters("GRID" )->asGrid (); m_pContours = Parameters("CONTOUR" )->asShapes(); m_pPolygons = Parameters("POLYGONS" )->asShapes(); m_bParts = Parameters("LINE_PARTS")->asBool () && !m_pPolygons; // only split parts if polygons are not requested double zMin = Parameters("ZMIN" )->asDouble(); double zMax = Parameters("ZMAX" )->asDouble(); double zStep = Parameters("ZSTEP" )->asDouble(); //----------------------------------------------------- CSG_String Name; if( zStep <= 0 ) // just one contour value (zMin) { zStep = 1; zMax = zMin; Name = Name.Format("%s [%s %s]", m_pGrid->Get_Name(), _TL("Contour" ), SG_Get_String(zMin ).c_str()); } else { if( zMin < m_pGrid->Get_ZMin() ) { zMin += zStep * (int)((m_pGrid->Get_ZMin() - zMin) / zStep); } Name = Name.Format("%s [%s %s]", m_pGrid->Get_Name(), _TL("Interval"), SG_Get_String(zStep).c_str()); } if( zMax > m_pGrid->Get_ZMax() ) { zMax = m_pGrid->Get_ZMax(); } //----------------------------------------------------- m_pContours->Create(SHAPE_TYPE_Line, Name, NULL, Parameters("VERTEX")->asInt() == 0 ? SG_VERTEX_TYPE_XY : SG_VERTEX_TYPE_XYZ); m_pContours->Add_Field("ID", SG_DATATYPE_Int); m_pContours->Add_Field("Z" , SG_DATATYPE_Double); if( m_pPolygons ) { m_pPolygons->Create(SHAPE_TYPE_Polygon, m_pContours->Get_Name(), NULL, Parameters("VERTEX")->asInt() == 0 ? SG_VERTEX_TYPE_XY : SG_VERTEX_TYPE_XYZ ); m_pPolygons->Add_Field("ID" , SG_DATATYPE_Int ); m_pPolygons->Add_Field("MIN" , SG_DATATYPE_Double); m_pPolygons->Add_Field("MAX" , SG_DATATYPE_Double); m_pPolygons->Add_Field("RANGE", SG_DATATYPE_String); } //----------------------------------------------------- double Scale = Parameters("SCALE")->asDouble(); if( Scale > 0.0 && Scale != 1.0 ) { if( !Grid.Create(CSG_Grid_System(m_pGrid->Get_Cellsize() / Scale, m_pGrid->Get_Extent()), m_pGrid->Get_Type()) ) { Error_Set(_TL("could allocate memory for scaled grid")); return( false ); } Grid.Assign(m_pGrid, GRID_INTERPOLATION_BSpline); m_pGrid = &Grid; } //----------------------------------------------------- m_Edge.Create(SG_DATATYPE_Char, m_pGrid->Get_NX() + 1, m_pGrid->Get_NY() + 1, m_pGrid->Get_Cellsize(), m_pGrid->Get_XMin(), m_pGrid->Get_YMin()); for(double z=zMin; z<=zMax && Set_Progress(z - zMin, zMax - zMin); z+=zStep) { if( z >= m_pGrid->Get_ZMin() && z <= m_pGrid->Get_ZMax() ) { Process_Set_Text(CSG_String::Format("%s: %s", _TL("Contour"), SG_Get_String(z, -2).c_str())); Get_Contour(z); } } //----------------------------------------------------- if( m_pPolygons && m_pContours->Get_Count() > 0 && Set_Progress(0)) { Get_Polygons(NULL, (CSG_Shape_Line *)m_pContours->Get_Shape(0)); for(int i=1; iGet_Count() && Set_Progress(i, m_pContours->Get_Count()); i++) { Get_Polygons((CSG_Shape_Line *)m_pContours->Get_Shape(i - 1), (CSG_Shape_Line *)m_pContours->Get_Shape(i)); } if( Set_Progress(100) ) { Get_Polygons((CSG_Shape_Line *)m_pContours->Get_Shape(m_pContours->Get_Count() - 1), NULL); } if( Parameters("POLY_PARTS")->asBool() ) { Split_Polygon_Parts(m_pPolygons); } } m_Edge.Destroy(); //----------------------------------------------------- return( m_pContours->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define EDGE_ROW 0x01 #define EDGE_COL 0x02 //--------------------------------------------------------- inline bool CGrid_To_Contour::is_Edge(int x, int y) { return( m_pGrid->is_InGrid(x , y ) && (!m_pGrid->is_InGrid(x - 1, y - 1) || !m_pGrid->is_InGrid(x , y - 1) || !m_pGrid->is_InGrid(x + 1, y - 1) || !m_pGrid->is_InGrid(x + 1, y ) || !m_pGrid->is_InGrid(x + 1, y + 1) || !m_pGrid->is_InGrid(x , y + 1) || !m_pGrid->is_InGrid(x - 1, y + 1) || !m_pGrid->is_InGrid(x - 1, y ) ) ); } //--------------------------------------------------------- inline void CGrid_To_Contour::Set_Row(int x, int y, bool bOn) { int Edge = m_Edge.asInt(x, y); m_Edge.Set_Value(x, y, bOn ? (Edge | EDGE_ROW) : (Edge & EDGE_COL)); } inline bool CGrid_To_Contour::Get_Row(int x, int y) { return( (m_Edge.asInt(x, y) & EDGE_ROW) != 0 ); } //--------------------------------------------------------- inline void CGrid_To_Contour::Set_Col(int x, int y, bool bOn) { int Edge = m_Edge.asInt(x, y); m_Edge.Set_Value(x, y, bOn ? (Edge | EDGE_COL) : (Edge & EDGE_ROW)); } inline bool CGrid_To_Contour::Get_Col(int x, int y) { return( (m_Edge.asInt(x, y) & EDGE_COL) != 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Contour::Get_Contour(double z) { int x, y; //----------------------------------------------------- #pragma omp parallel for private(x, y) for(y=0; yGet_NY(); y++) // Find Border Cells { for(x=0; xGet_NX(); x++) { if( !m_pGrid->is_NoData(x, y) ) { if( m_pGrid->asDouble(x, y) >= z ) { if( m_pGrid->is_InGrid(x + 1, y ) && m_pGrid->asDouble(x + 1, y ) < z ) Set_Row(x, y, true); if( m_pGrid->is_InGrid(x , y + 1) && m_pGrid->asDouble(x , y + 1) < z ) Set_Col(x, y, true); } else // if( m_pGrid->asDouble(x, y) < z ) { if( m_pGrid->is_InGrid(x + 1, y ) && m_pGrid->asDouble(x + 1, y ) >= z ) Set_Row(x, y, true); if( m_pGrid->is_InGrid(x , y + 1) && m_pGrid->asDouble(x , y + 1) >= z ) Set_Col(x, y, true); } } } } //----------------------------------------------------- if( m_bParts == false ) { CSG_Shape *pContour = m_pContours->Add_Shape(); pContour->Set_Value(0, m_pContours->Get_Count()); pContour->Set_Value(1, z); } for(y=0; yGet_NY(); y++) // find unclosed contours first so that these start/end at edges and not somewhere else { for(x=0; xGet_NX(); x++) { if( m_Edge.asInt(x, y) && is_Edge(x, y) ) { Get_Contour(z, x, y); } } } for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { while( Get_Contour(z, x, y) ); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Contour::Get_Contour(double z, int x, int y) { //----------------------------------------------------- bool bRow; if( Get_Row(x, y) ) { bRow = true; } else if( Get_Col(x, y) ) { bRow = false; } else { return( false ); } //----------------------------------------------------- int iPart; CSG_Shape *pContour; if( m_bParts == false ) { pContour = m_pContours->Get_Shape(m_pContours->Get_Count() - 1); iPart = pContour->Get_Part_Count(); } else { pContour = m_pContours->Add_Shape(); iPart = 0; pContour->Set_Value(0, m_pContours->Get_Count()); pContour->Set_Value(1, z); } //----------------------------------------------------- for(int Dir=0, x0=x, y0=y, bRow0=bRow?1:0; Dir>=0; ) { int zx = bRow ? x + 1 : x; int zy = bRow ? y : y + 1; double d = m_pGrid->asDouble(x, y); d = (d - z) / (d - m_pGrid->asDouble(zx, zy)); pContour->Add_Point( m_pGrid->Get_XMin() + m_pGrid->Get_Cellsize() * (x + d * (zx - x)), m_pGrid->Get_YMin() + m_pGrid->Get_Cellsize() * (y + d * (zy - y)), iPart ); if( pContour->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pContour->Set_Z(z, pContour->Get_Point_Count(iPart) - 1, iPart); } if( Get_Contour_Cell(Dir, x, y, bRow) || Get_Contour_Cell(Dir, x, y, bRow) ) { if( bRow ) { Set_Row(x , y , false); } else { Set_Col(x , y , false); } } else { if( bRow0 ) { Set_Row(x0, y0, false); } else { Set_Col(x0, y0, false); } Dir = -1; } } //----------------------------------------------------- return( pContour->Get_Point_Count(iPart) > 1 ); } //--------------------------------------------------------- inline bool CGrid_To_Contour::Get_Contour_Cell(int &Dir, int &x, int &y, bool &bRow) { if( bRow ) { switch( Dir ) { case 0: if( Get_Row(x , y + 1) ) { Dir = 5; y++; return( true ); } // Norden case 1: if( Get_Col(x + 1, y ) ) { Dir = 6; bRow = false; x++; return( true ); } // Nord-Ost case 2: // Osten ist nicht... case 3: if( y - 1 >= 0 && Get_Col(x + 1, y - 1) ) { Dir = 0; bRow = false; x++; y--; return( true ); } // Sued-Ost case 4: if( y - 1 >= 0 && Get_Row(x , y - 1) ) { Dir = 1; y--; return( true ); } // Sueden case 5: if( y - 1 >= 0 && Get_Col(x , y - 1) ) { Dir = 2; bRow = false; y--; return( true ); } // Sued-West case 6: // Westen ist nicht... case 7: if( Get_Col(x , y ) ) { Dir = 4; bRow = false; return( true ); } // Nord-West default: Dir = 0; } } else { switch( Dir ) { case 0: // Norden ist nicht... case 1: if( Get_Row(x , y + 1) ) { Dir = 6; bRow = true; y++; return( true ); } // Nord-Ost case 2: if( Get_Col(x + 1, y ) ) { Dir = 7; x++; return( true ); } // Osten case 3: if( Get_Row(x , y ) ) { Dir = 0; bRow = true; return( true ); } // Sued-Ost case 4: // Sueden ist nicht... case 5: if( x - 1 >= 0 && Get_Row(x - 1, y ) ) { Dir = 2; bRow = true; x--; return( true ); } // Sued-West case 6: if( x - 1 >= 0 && Get_Col(x - 1, y ) ) { Dir = 3; x--; return( true ); } // Westen case 7: if( x - 1 >= 0 && Get_Row(x - 1, y + 1) ) { Dir = 5; bRow = true; x--; y++; return( true ); } // Nord-West default: Dir = 0; } } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define EDGE_LINE 1 #define EDGE_NODE_ONE 2 #define EDGE_NODE_TWO 3 //--------------------------------------------------------- bool CGrid_To_Contour::Get_Polygons(CSG_Shape_Line *pContour_Lo, CSG_Shape_Line *pContour_Hi) { int x, y; //----------------------------------------------------- double zMin = pContour_Lo ? pContour_Lo->asDouble(1) : m_pGrid->Get_ZMin(); double zMax = pContour_Hi ? pContour_Hi->asDouble(1) : m_pGrid->Get_ZMax(); #pragma omp parallel for private(x, y) for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { m_Edge.Set_Value(x, y, is_Edge(x, y) && zMin <= m_pGrid->asDouble(x, y) && m_pGrid->asDouble(x, y) <= zMax ? EDGE_LINE : 0); } } //----------------------------------------------------- CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)m_pPolygons->Add_Shape(); pPolygon->Set_Value(0, m_pPolygons->Get_Count()); pPolygon->Set_Value(1, zMin); pPolygon->Set_Value(2, zMax); pPolygon->Set_Value(3, SG_Get_String(zMin) + " - " + SG_Get_String(zMax)); //----------------------------------------------------- CSG_Shapes Segments(SHAPE_TYPE_Line); Segments.Add_Field("x0", SG_DATATYPE_Int); Segments.Add_Field("y0", SG_DATATYPE_Int); Segments.Add_Field("x1", SG_DATATYPE_Int); Segments.Add_Field("y1", SG_DATATYPE_Int); if( pContour_Lo ) { Add_Contour(Segments, pPolygon, pContour_Lo); } if( pContour_Hi ) { Add_Contour(Segments, pPolygon, pContour_Hi); } //----------------------------------------------------- if( Segments.Get_Count() == 0 ) // no edge crossing line { for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { if( m_Edge.asInt(x, y) == EDGE_LINE ) // add outer ring { Add_Edge(Segments, x, y); if( Segments.Get_Count() ) { pPolygon->Add_Part(((CSG_Shape_Polygon *)Segments.Get_Shape(0))->Get_Part(0)); Segments.Del_Shapes(); } } } } return( true ); } //----------------------------------------------------- // { CSG_Grid *pGrid = SG_Create_Grid(m_Edge); pGrid->Set_NoData_Value(0); DataObject_Add(pGrid); } for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { if( m_Edge.asInt(x, y) == EDGE_NODE_ONE ) { Add_Edge(Segments, x, y); } } } // DataObject_Add(SG_Create_Shapes(Segments)); //----------------------------------------------------- while( Segments.Get_Count() > 0 ) { int iPart = pPolygon->Get_Part_Count(); CSG_Shape *pSegment = Segments.Get_Shape(0); int x = pSegment->asInt(2); int y = pSegment->asInt(3); bool bAscending = true; do { Add_Segment(pPolygon, iPart, pSegment, bAscending); } while( (pSegment = Get_Segment(Segments, x, y, bAscending)) != NULL ); if( pPolygon->Get_Point_Count(iPart) < 3 ) { pPolygon->Del_Part(iPart); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGrid_To_Contour::Add_Contour(CSG_Shapes &Segments, CSG_Shape_Polygon *pPolygon, CSG_Shape_Line *pContour) { //----------------------------------------------------- for(int iPart=0; iPartGet_Part_Count(); iPart++) { CSG_Shape_Part *pPart = pContour->Get_Part(iPart); if( !CSG_Point(pPart->Get_Point(0, true)).is_Equal(pPart->Get_Point(0, false)) ) // island { CSG_Shape *pSegment = Segments.Add_Shape(); pSegment->Add_Part(pPart); int x, y; m_Edge.Get_System().Get_World_to_Grid(x, y, pPart->Get_Point(0, true)); m_Edge.Set_Value(x, y, m_Edge.asInt(x, y) == EDGE_NODE_ONE ? EDGE_NODE_TWO : EDGE_NODE_ONE); pSegment->Set_Value(0, x); pSegment->Set_Value(1, y); m_Edge.Get_System().Get_World_to_Grid(x, y, pPart->Get_Point(0, false)); m_Edge.Set_Value(x, y, m_Edge.asInt(x, y) == EDGE_NODE_ONE ? EDGE_NODE_TWO : EDGE_NODE_ONE); pSegment->Set_Value(2, x); pSegment->Set_Value(3, y); } else if( pPart->Get_Count() >= 3 ) { pPolygon->Add_Part(pPart); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGrid_To_Contour::Add_Edge(CSG_Shapes &Segments, int x, int y) { int i; //----------------------------------------------------- CSG_Shape *pSegment = NULL; for(i=0; i<8 && !pSegment; i+=2) { int ix = CSG_Grid_System::Get_xTo(i, x); int iy = CSG_Grid_System::Get_yTo(i, y); if( m_Edge.is_InGrid(ix, iy) && m_Edge.asInt(ix, iy) == EDGE_LINE ) { pSegment = Segments.Add_Shape(); pSegment->Set_Value(0, x); pSegment->Set_Value(1, y); x = ix; y = iy; } } if( !pSegment ) { for(i=0; i<8 && !pSegment; i+=2) { int ix = CSG_Grid_System::Get_xTo(i, x); int iy = CSG_Grid_System::Get_yTo(i, y); if( m_Edge.is_InGrid(ix, iy) && m_Edge.asInt(ix, iy) == EDGE_NODE_ONE ) { pSegment = Segments.Add_Shape(); pSegment->Set_Value(0, x); pSegment->Set_Value(1, y); pSegment->Set_Value(2, ix); pSegment->Set_Value(3, iy); } } return( pSegment != NULL ); } //----------------------------------------------------- int iLast = -1; for(bool bNext=true; bNext; ) { bNext = false; m_Edge.Set_Value(x, y, 0); for(i=0; i<8 && !bNext; i+=2) { int ix = CSG_Grid_System::Get_xTo(i, x); int iy = CSG_Grid_System::Get_yTo(i, y); if( m_Edge.is_InGrid(ix, iy) && m_Edge.asInt(ix, iy) == EDGE_LINE ) { bNext = true; if( i != iLast ) { iLast = i; pSegment->Add_Point(m_Edge.Get_System().Get_Grid_to_World(x, y)); } x = ix; y = iy; } } } //----------------------------------------------------- pSegment->Add_Point(m_Edge.Get_System().Get_Grid_to_World(x, y)); for(int i=0; i<8; i+=2) { int ix = CSG_Grid_System::Get_xTo(i, x); int iy = CSG_Grid_System::Get_yTo(i, y); if( m_Edge.is_InGrid(ix, iy) && m_Edge.asInt(ix, iy) != 0 ) { pSegment->Set_Value(2, ix); pSegment->Set_Value(3, iy); return( true ); } } pSegment->Set_Value(2, x); pSegment->Set_Value(3, y); return( false ); } //--------------------------------------------------------- CSG_Shape * CGrid_To_Contour::Get_Segment(const CSG_Shapes &Segments, int &x, int &y, bool &bAscending) { for(int i=0; iGet_Point_Count(0); i++) { pPolygon->Add_Point(pSegment->Get_Point(i, 0, bAscending), iPart); } ((CSG_Shapes *)pSegment->Get_Table())->Del_Shape(pSegment); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Contour::Split_Polygon_Parts(CSG_Shapes *pPolygons) { CSG_Shapes Polygons(*pPolygons); pPolygons->Del_Shapes(); //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Part_Count() && Process_Get_Okay(); iPart++) { if( !pPolygon->is_Lake(iPart) ) { CSG_Shape_Polygon *pPart = (CSG_Shape_Polygon *)pPolygons->Add_Shape(pPolygon, SHAPE_COPY_ATTR); pPart->Add_Part(pPolygon->Get_Part(iPart)); for(int jPart=0; jPartGet_Part_Count(); jPart++) { if( pPolygon->is_Lake(jPart) && pPart->Contains(pPolygon->Get_Point(0, jPart)) ) { pPart->Add_Part(pPolygon->Get_Part(jPart)); } } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Statistics_For_Points.cpp0000664000175000017500000003122512565125410027552 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Statistics_For_Points.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Statistics_For_Points.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Statistics_For_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Statistics_For_Points::CGrid_Statistics_For_Points(void) { //----------------------------------------------------- Set_Name (_TL("Grid Statistics for Points")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "For each given point statistics based on all grid cells in the defined neighbourhood will be calculated." )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "KERNEL_TYPE" , _TL("Kernel Type"), _TL(""), CSG_String::Format("%s|%s|", _TL("square"), _TL("circle") ), 0 ); Parameters.Add_Value( NULL , "KERNEL_SIZE" , _TL("Kernel Size"), _TL("kernel size defined as radius number of cells"), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Choice( NULL , "NAMING" , _TL("Field Naming"), _TL(""), CSG_String::Format("%s|%s|", _TL("grid number"), _TL("grid name") ), 1 ); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "RESULT" , _TL("Statistics"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Value(pNode, "COUNT" , _TL("Number of Cells" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MIN" , _TL("Minimum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MAX" , _TL("Maximum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "RANGE" , _TL("Range" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "SUM" , _TL("Sum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MEAN" , _TL("Mean" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "VAR" , _TL("Variance" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "STDDEV" , _TL("Standard Deviation"), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "QUANTILE", _TL("Quantile" ), _TL("Calculate distribution quantiles. Value specifies interval (median=50, quartiles=25, deciles=10, ...). Set to zero to omit quantile calculation."), PARAMETER_TYPE_Int, 0, 0, true, 50, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Statistics_For_Points::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS")->asShapes(); if( pPoints->Get_Count() <= 0 ) { Error_Set(_TL("no points in input layer")); return( false ); } //----------------------------------------------------- CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); if( pGrids->Get_Count() < 1 ) { Error_Set(_TL("no grids in selection")); return( false ); } if( !Get_System()->Get_Extent().Intersects(pPoints->Get_Extent()) ) { Error_Set(_TL("no spatial intersection between grid(s) and points layer")); return( false ); } //----------------------------------------------------- if( !m_Kernel.Set_Radius(Parameters("KERNEL_SIZE")->asInt(), Parameters("KERNEL_TYPE")->asInt() == 0) ) { Error_Set(_TL("could not initialize kernel")); return( false ); } //----------------------------------------------------- int Quantile = Parameters("QUANTILE")->asInt(); int nFields = 0, offField; int fCOUNT = Parameters("COUNT" )->asBool() ? nFields++ : -1; int fMIN = Parameters("MIN" )->asBool() ? nFields++ : -1; int fMAX = Parameters("MAX" )->asBool() ? nFields++ : -1; int fRANGE = Parameters("RANGE" )->asBool() ? nFields++ : -1; int fSUM = Parameters("SUM" )->asBool() ? nFields++ : -1; int fMEAN = Parameters("MEAN" )->asBool() ? nFields++ : -1; int fVAR = Parameters("VAR" )->asBool() ? nFields++ : -1; int fSTDDEV = Parameters("STDDEV" )->asBool() ? nFields++ : -1; int fQUANTILE = Quantile > 0 ? nFields++ : -1; if( nFields == 0 ) { Error_Set(_TL("no output parameter in selection")); return( false ); } //----------------------------------------------------- if( Parameters("RESULT")->asShapes() != NULL && Parameters("RESULT")->asShapes() != pPoints ) { pPoints = Parameters("RESULT")->asShapes(); pPoints ->Assign(Parameters("POINTS")->asShapes()); pPoints ->Set_Name(CSG_String::Format("%s [%s]", Parameters("POINTS")->asShapes()->Get_Name(), _TL("Grid Statistics"))); } //----------------------------------------------------- { #define GET_FIELD_NAME(VAR) Naming == 0 ? CSG_String::Format(SG_T("G%02d_%s"), iGrid + 1, VAR) : CSG_String::Format(SG_T("%s [%s]"), pGrids->asGrid(iGrid)->Get_Name(), VAR) int Naming = Parameters("NAMING")->asInt(); offField = pPoints->Get_Field_Count(); for(int iGrid=0; iGridGet_Count(); iGrid++) { int iField = pPoints->Get_Field_Count(); if( fCOUNT >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("CELLS" )), SG_DATATYPE_Int ); if( fMIN >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("MIN" )), SG_DATATYPE_Double); if( fMAX >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("MAX" )), SG_DATATYPE_Double); if( fRANGE >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("RANGE" )), SG_DATATYPE_Double); if( fSUM >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("SUM" )), SG_DATATYPE_Double); if( fMEAN >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("MEAN" )), SG_DATATYPE_Double); if( fVAR >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("VARIANCE")), SG_DATATYPE_Double); if( fSTDDEV >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("STDDEV" )), SG_DATATYPE_Double); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile; iQuantile<100; iQuantile+=Quantile) { pPoints->Add_Field(GET_FIELD_NAME(CSG_String::Format(SG_T("Q%02d"), iQuantile).c_str()), SG_DATATYPE_Double); if( iGrid == 0 && iQuantile > Quantile ) { nFields++; } } } } } //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); for(int iGrid=0; iGridGet_Count(); iGrid++) { CSG_Simple_Statistics Statistics(Quantile >= 0); int iField = offField + iGrid * nFields; if( !Get_Statistics(pPoint->Get_Point(0), pGrids->asGrid(iGrid), Statistics) ) { if( fCOUNT >= 0 ) pPoint->Set_NoData(iField + fCOUNT ); if( fMIN >= 0 ) pPoint->Set_NoData(iField + fMIN ); if( fMAX >= 0 ) pPoint->Set_NoData(iField + fMAX ); if( fRANGE >= 0 ) pPoint->Set_NoData(iField + fRANGE ); if( fSUM >= 0 ) pPoint->Set_NoData(iField + fSUM ); if( fMEAN >= 0 ) pPoint->Set_NoData(iField + fMEAN ); if( fVAR >= 0 ) pPoint->Set_NoData(iField + fVAR ); if( fSTDDEV >= 0 ) pPoint->Set_NoData(iField + fSTDDEV); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile; iQuantile<100; iQuantile+=Quantile, iField++) { pPoint->Set_NoData(iField + fQUANTILE); } } } else { if( fCOUNT >= 0 ) pPoint->Set_Value(iField + fCOUNT , Statistics.Get_Count ()); if( fMIN >= 0 ) pPoint->Set_Value(iField + fMIN , Statistics.Get_Minimum ()); if( fMAX >= 0 ) pPoint->Set_Value(iField + fMAX , Statistics.Get_Maximum ()); if( fRANGE >= 0 ) pPoint->Set_Value(iField + fRANGE , Statistics.Get_Range ()); if( fSUM >= 0 ) pPoint->Set_Value(iField + fSUM , Statistics.Get_Sum ()); if( fMEAN >= 0 ) pPoint->Set_Value(iField + fMEAN , Statistics.Get_Mean ()); if( fVAR >= 0 ) pPoint->Set_Value(iField + fVAR , Statistics.Get_Variance()); if( fSTDDEV >= 0 ) pPoint->Set_Value(iField + fSTDDEV, Statistics.Get_StdDev ()); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile; iQuantile<100; iQuantile+=Quantile, iField++) { pPoint->Set_Value(iField + fQUANTILE, Statistics.Get_Quantile(iQuantile)); } } } } } //----------------------------------------------------- DataObject_Update(pPoints); m_Kernel.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Statistics_For_Points::Get_Statistics(const TSG_Point &Point, CSG_Grid *pGrid, CSG_Simple_Statistics &Statistics) { int x = Get_System()->Get_xWorld_to_Grid(Point.x); int y = Get_System()->Get_yWorld_to_Grid(Point.y); for(int i=0; iis_InGrid(ix, iy) ) { Statistics += pGrid->asDouble(ix, iy); } } return( Statistics.Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_grid/grid_rectangle_clip.cpp0000664000175000017500000001712312565125410026272 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_rectangle_clip.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_rectangle_clip.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_rectangle_clip.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Rectangle_Clip::CGrid_Rectangle_Clip(void) { //----------------------------------------------------- Set_Name (_TL("Clip Grid with Rectangle")); Set_Author (_TL("V. Wichmann (c) 2013")); Set_Description (_TW( "Clips the input grid with the (rectangular) extent of a shapefile. " "The clipped grid will have the extent of the shapefile.\n" "Select shapes from the shapefile prior to module execution " "in case you like to use only a subset from the shapefile " "for clipping.\n\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "INPUT" , _TL("Input"), _TL("The grid to clip."), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Extent"), _TL("The shapefile to use for clipping."), PARAMETER_INPUT ); Parameters.Add_Choice( NULL , "BORDER" , _TL("Border"), _TL("Set grid extent to grid cells (pixel as area), to grid nodes (pixel as point) or align to grid system."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("grid cells"), _TL("grid nodes"), _TL("align to grid system") ), 0 ); Parameters.Add_Grid_Output( NULL , "OUTPUT" , _TL("Output"), _TL("The clipped grid.") ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Rectangle_Clip::On_Execute(void) { CSG_Grid *pGrid_in, *pGrid_out; CSG_Shapes *pShapes; int iMethod; //----------------------------------------------------- pGrid_in = Parameters("INPUT") ->asGrid(); pShapes = Parameters("SHAPES") ->asShapes(); iMethod = Parameters("BORDER") ->asInt(); //----------------------------------------------------- CSG_Rect Extent; if( pShapes->Get_Selection_Count() > 0 ) { bool bFirst = true; for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { if( pShapes->Get_Shape(iShape)->is_Selected() ) { if( bFirst ) { Extent = pShapes->Get_Shape(iShape)->Get_Extent(); bFirst = false; } else { Extent.Union(pShapes->Get_Shape(iShape)->Get_Extent()); } } } } else Extent = pShapes->Get_Extent(); //----------------------------------------------------- if( iMethod == 0 ) { Extent.Deflate(0.5 * pGrid_in->Get_Cellsize(), 0.5 * pGrid_in->Get_Cellsize(), false); } else if( iMethod == 2 ) { double d, minX, minY; d = Extent.Get_XMin() - pGrid_in->Get_XMin(true); minX = pGrid_in->Get_XMin(true) + floor(d / pGrid_in->Get_Cellsize()) * pGrid_in->Get_Cellsize() + 0.5 * pGrid_in->Get_Cellsize(); d = Extent.Get_YMin() - pGrid_in->Get_YMin(true); minY = pGrid_in->Get_YMin(true) + floor(d / pGrid_in->Get_Cellsize()) * pGrid_in->Get_Cellsize() + 0.5 * pGrid_in->Get_Cellsize(); Extent.Set_BottomLeft(minX, minY); } CSG_Grid_System GridSystem(pGrid_in->Get_Cellsize(), Extent); pGrid_out = SG_Create_Grid(GridSystem, pGrid_in->Get_Type()); pGrid_out->Set_NoData_Value(pGrid_in->Get_NoData_Value()); pGrid_out->Set_Name(CSG_String::Format(SG_T("%s_clip"), pGrid_in->Get_Name())); pGrid_out->Assign_NoData(); //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, pGrid_out->Get_NY()); y++) { #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double xWorld = GridSystem.Get_xGrid_to_World(x); double yWorld = GridSystem.Get_yGrid_to_World(y); int xGrid, yGrid; pGrid_in->Get_System().Get_World_to_Grid(xGrid, yGrid, xWorld, yWorld); if (pGrid_in->is_InGrid(xGrid, yGrid)) pGrid_out->Set_Value(x, y, pGrid_in->asDouble(xGrid, yGrid)); } } //----------------------------------------------------- Parameters("OUTPUT")->Set_Value(pGrid_out); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Values_AddTo_Points.cpp0000664000175000017500000001543112565125410027125 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Values_AddTo_Points.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Values_AddTo_Points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Values_AddTo_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Values_AddTo_Points::CGrid_Values_AddTo_Points(void) { //----------------------------------------------------- Set_Name (_TL("Add Grid Values to Points")); Set_Author (SG_T("O.Conrad (c) 2003")); Set_Description (_TW( "Spatial Join: Retrieves information from the selected grids at the positions " "of the points of the selected points layer and adds it to the resulting layer." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Points"), _TL(""), PARAMETER_INPUT , SHAPE_TYPE_Point ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT , false ); Parameters.Add_Shapes( NULL , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "INTERPOL" , _TL("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 CGrid_Values_AddTo_Points::On_Execute(void) { int iShape, iGrid, iField, Offset, Interpolation; double Value; CSG_Shapes *pShapes; CSG_Parameter_Grid_List *pGrids; //----------------------------------------------------- pShapes = Parameters("RESULT") ->asShapes(); pGrids = Parameters("GRIDS" ) ->asGridList(); Interpolation = Parameters("INTERPOL") ->asInt(); //----------------------------------------------------- if( pGrids->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- if( pShapes == NULL ) { pShapes = Parameters("SHAPES")->asShapes(); } else if( pShapes != Parameters("SHAPES")->asShapes() ) { pShapes->Create(*Parameters("SHAPES")->asShapes()); } Offset = pShapes->Get_Field_Count(); //----------------------------------------------------- for(iGrid=0; iGridGet_Count(); iGrid++) { pShapes->Add_Field(pGrids->asGrid(iGrid)->Get_Name(), SG_DATATYPE_Double); } //----------------------------------------------------- for(iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(iGrid=0, iField=Offset; iGridGet_Count(); iGrid++, iField++) { CSG_Grid *pGrid = pGrids->asGrid(iGrid); if( pGrid->Get_Value(pShape->Get_Point(0), Value, Interpolation) ) { pShape->Set_Value(iField, Value); } else { pShape->Set_NoData(iField); } } } //----------------------------------------------------- if( pShapes == Parameters("SHAPES")->asShapes() ) { DataObject_Update(pShapes); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_grid/Grid_To_Points.h0000664000175000017500000001103212565125410024633 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_To_Points.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_To_Points_H #define HEADER_INCLUDED__Grid_To_Points_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_To_Points : public CSG_Module_Grid { public: CGrid_To_Points(void); virtual ~CGrid_To_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Vectorization") ); } protected: virtual bool On_Execute (void); private: bool is_Contained (double x, double y, CSG_Shapes *pPolygons); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_To_Points_H saga-2.2.3/src/modules/shapes/shapes_grid/Makefile.in0000664000175000017500000006014112622651170023652 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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_grid DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_grid_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_grid_la_OBJECTS = Grid_Classes_To_Shapes.lo \ grid_extent.lo grid_local_extremes_to_points.lo \ Grid_Polygon_Clip.lo grid_rectangle_clip.lo \ Grid_Statistics_AddTo_Polygon.lo Grid_Statistics_For_Points.lo \ Grid_To_Contour.lo Grid_To_Gradient.lo Grid_To_Points.lo \ Grid_To_Points_Random.lo Grid_Values_AddTo_Points.lo \ Grid_Values_AddTo_Shapes.lo MLB_Interface.lo libshapes_grid_la_OBJECTS = $(am_libshapes_grid_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_grid_la_SOURCES) DIST_SOURCES = $(libshapes_grid_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 2443 2015-03-18 19:52:26Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_grid.la libshapes_grid_la_SOURCES = \ Grid_Classes_To_Shapes.cpp\ grid_extent.cpp\ grid_local_extremes_to_points.cpp\ Grid_Polygon_Clip.cpp\ grid_rectangle_clip.cpp\ Grid_Statistics_AddTo_Polygon.cpp\ Grid_Statistics_For_Points.cpp\ Grid_To_Contour.cpp\ Grid_To_Gradient.cpp\ Grid_To_Points.cpp\ Grid_To_Points_Random.cpp\ Grid_Values_AddTo_Points.cpp\ Grid_Values_AddTo_Shapes.cpp\ MLB_Interface.cpp\ Grid_Classes_To_Shapes.h\ grid_extent.h\ grid_local_extremes_to_points.h\ Grid_Polygon_Clip.h\ grid_rectangle_clip.h\ Grid_Statistics_AddTo_Polygon.h\ Grid_Statistics_For_Points.h\ Grid_To_Contour.h\ Grid_To_Gradient.h\ Grid_To_Points.h\ Grid_To_Points_Random.h\ Grid_Values_AddTo_Points.h\ Grid_Values_AddTo_Shapes.h\ MLB_Interface.h libshapes_grid_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) --foreign src/modules/shapes/shapes_grid/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_grid/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_grid.la: $(libshapes_grid_la_OBJECTS) $(libshapes_grid_la_DEPENDENCIES) $(EXTRA_libshapes_grid_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_grid_la_OBJECTS) $(libshapes_grid_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Classes_To_Shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Polygon_Clip.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Statistics_AddTo_Polygon.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Statistics_For_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_To_Contour.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_To_Gradient.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_To_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_To_Points_Random.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Values_AddTo_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Values_AddTo_Shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_extent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_local_extremes_to_points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_rectangle_clip.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/shapes/shapes_grid/Grid_To_Gradient.cpp0000664000175000017500000002776712565125410025475 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_To_Gradient.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Gradient.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_To_Gradient.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_To_Gradient::CGrid_To_Gradient(int Method) { m_Method = Method; Set_Author (SG_T("O.Conrad (c) 2006")); //----------------------------------------------------- switch( m_Method ) { case 0: // surface Set_Name (_TL("Gradient Vectors from Surface")); Set_Description (_TW( "Create lines indicating the gradient. " )); Parameters.Add_Grid( NULL , "SURFACE" , _TL("Surface"), _TL(""), PARAMETER_INPUT ); break; case 1: // direction and length Set_Name (_TL("Gradient Vectors from Direction and Length")); Set_Description (_TW( "Create lines indicating the gradient. " )); Parameters.Add_Grid( NULL , "DIR" , _TL("Direction"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "LEN" , _TL("Length"), _TL(""), PARAMETER_INPUT ); break; case 2: // directional components Set_Name (_TL("Gradient Vectors from Directional Components")); Set_Description (_TW( "Create lines indicating the gradient. " )); Parameters.Add_Grid( NULL , "X" , _TL("X Component"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "Y" , _TL("Y Component"), _TL(""), PARAMETER_INPUT ); break; } //----------------------------------------------------- Parameters.Add_Shapes( NULL , "VECTORS" , _TL("Gradient Vectors"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "STEP" , _TL("Step"), _TL(""), PARAMETER_TYPE_Int , 1.0, 1.0, true ); Parameters.Add_Range( NULL , "SIZE" , _TL("Size Range"), _TL("size range as percentage of step"), 25.0, 100.0, 0.0, true ); Parameters.Add_Choice( NULL , "AGGR" , _TL("Aggregation"), _TL("how to request values if step size is more than one cell"), CSG_String::Format(SG_T("%s|%s|"), _TL("nearest neighbour"), _TL("mean value") ), 1 ); Parameters.Add_Choice( NULL , "STYLE" , _TL("Style"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("simple line"), _TL("arrow"), _TL("arrow (centered to cell)") ), 2 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Gradient::On_Execute(void) { int x, y, Step; double sMin, sRange, ex, ey, d; TSG_Point p; TSG_Grid_Interpolation Interpolation; CSG_Grid_System System; CSG_Grid EX, EY, D; CSG_Shapes *pVectors; //----------------------------------------------------- pVectors = Parameters("VECTORS") ->asShapes(); Step = Parameters("STEP") ->asInt(); m_Style = Parameters("STYLE") ->asInt(); sMin = Parameters("SIZE") ->asRange()->Get_LoVal() * Step * Get_Cellsize() / 100.0; sRange = Parameters("SIZE") ->asRange()->Get_HiVal() * Step * Get_Cellsize() / 100.0 - sMin; Interpolation = Parameters("AGGR") ->asInt() == 0 ? GRID_INTERPOLATION_NearestNeighbour : GRID_INTERPOLATION_Mean_Cells; //----------------------------------------------------- if( Step > Get_NX() || Step > Get_NY() ) { Error_Set(_TL("step size should not exceed number of cells in x or y direction")); return( false ); } //----------------------------------------------------- // System.Assign(Step * Get_Cellsize(), Get_XMin(), Get_YMin(), Get_NX() / Step, Get_NY() / Step); System.Assign(Step * Get_Cellsize(), Get_XMin(), Get_YMin(), Get_System()->Get_XMax(), Get_System()->Get_YMax()); EX.Create(System); EY.Create(System); D .Create(System); D .Assign_NoData(); switch( m_Method ) { //----------------------------------------------------- case 0: // surface { CSG_Grid Surface(System), *pSurface = Parameters("SURFACE")->asGrid(); Surface.Assign(pSurface, Interpolation); pVectors->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s]"), pSurface->Get_Name(), _TL("Gradient"))); for(y=0; yasGrid(), _X(*Get_System()); CSG_Grid *pLen = Parameters("LEN")->asGrid(), _Y(*Get_System()); for(y=0; yis_NoData(x, y) && !pLen->is_NoData(x, y) ) { _X.Set_Value(x, y, pLen->asDouble(x, y) * sin(pDir->asDouble(x, y))); _Y.Set_Value(x, y, pLen->asDouble(x, y) * cos(pDir->asDouble(x, y))); } else { _X.Set_NoData(x, y); _Y.Set_NoData(x, y); } } } CSG_Grid X(System); X.Assign(&_X, Interpolation); CSG_Grid Y(System); Y.Assign(&_Y, Interpolation); pVectors->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s|%s]"), _TL("Gradient"), pDir->Get_Name(), pLen->Get_Name())); for(y=0; y 0.0 ) { EX.Set_Value(x, y, X.asDouble(x, y) / d); EY.Set_Value(x, y, Y.asDouble(x, y) / d); D .Set_Value(x, y, d); } } } } break; //----------------------------------------------------- case 2: // directional components { CSG_Grid X(System), *pX = Parameters("X")->asGrid(); X.Assign(pX, Interpolation); CSG_Grid Y(System), *pY = Parameters("Y")->asGrid(); Y.Assign(pY, Interpolation); pVectors->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s|%s]"), _TL("Gradient"), pX->Get_Name(), pY->Get_Name())); for(y=0; y 0.0 ) { EX.Set_Value(x, y, X.asDouble(x, y) / d); EY.Set_Value(x, y, Y.asDouble(x, y) / d); D .Set_Value(x, y, d); } } } } break; } //----------------------------------------------------- pVectors->Add_Field("EX" , SG_DATATYPE_Double); pVectors->Add_Field("EY" , SG_DATATYPE_Double); pVectors->Add_Field("LEN" , SG_DATATYPE_Double); pVectors->Add_Field("DIR" , SG_DATATYPE_Double); if( D.Get_ZRange() > 0.0 ) { sRange = sRange / D.Get_ZRange(); } //----------------------------------------------------- for(y=0, p.y=System.Get_YMin(); yAdd_Shape(); ex = EX.asDouble(x, y); ey = EY.asDouble(x, y); d = D .asDouble(x, y); pVector->Set_Value(0, ex); pVector->Set_Value(1, ey); pVector->Set_Value(2, d); pVector->Set_Value(3, atan2(ex, ey) * M_RAD_TO_DEG); if( (d = sMin + sRange * (d - D.Get_ZMin())) > 0.0 ) { Set_Vector(pVector, p, d * ex, d * ey); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define ADD_TO_VECTOR(I, X, Y) (pVector->Add_Point(Point.x + ((X) * dy + (Y) * dx), Point.y + ((Y) * dy - (X) * dx), I)) //--------------------------------------------------------- inline void CGrid_To_Gradient::Set_Vector(CSG_Shape *pVector, const TSG_Point &Point, double dx, double dy) { switch( m_Style ) { case 0: ADD_TO_VECTOR(0, 0.00, 0.00); ADD_TO_VECTOR(0, 0.00, 1.00); break; case 1: ADD_TO_VECTOR(0, 0.00, 0.00); ADD_TO_VECTOR(0, 0.00, 1.00); ADD_TO_VECTOR(1, 0.20, 0.75); ADD_TO_VECTOR(1, 0.00, 1.00); ADD_TO_VECTOR(1, -0.20, 0.75); break; case 2: ADD_TO_VECTOR(0, 0.00, -0.50); ADD_TO_VECTOR(0, 0.00, 0.50); ADD_TO_VECTOR(1, 0.20, 0.25); ADD_TO_VECTOR(1, 0.00, 0.50); ADD_TO_VECTOR(1, -0.20, 0.25); break; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Classes_To_Shapes.cpp0000664000175000017500000004713212565125410026624 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Classes_To_Shapes.cpp 2241 2014-09-22 11:04:27Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 , "POLYGONS" , _TL("Polygons"), _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") ), 0 ); Parameters.Add_Value( NULL , "ALLVERTICES" , _TL("Keep Vertices on Straight Lines"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::On_Execute(void) { //----------------------------------------------------- if( !Get_Classes() || !Get_Edges() ) { m_Classes.Destroy(); return( false ); } //----------------------------------------------------- if( Parameters("SPLIT")->asInt() == 1 ) { Split_Polygons(); } m_Classes.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::Get_Classes(void) { sLong i; int id, x, y; double Value; CSG_Grid *pGrid; //----------------------------------------------------- pGrid = Parameters("GRID") ->asGrid(); m_pPolygons = Parameters("POLYGONS") ->asShapes(); m_pPolygons->Create(SHAPE_TYPE_Polygon); m_pPolygons->Add_Field(pGrid->Get_Name(), SG_DATATYPE_Double); m_pPolygons->Add_Field(SG_T("ID") , SG_DATATYPE_Int); m_pPolygons->Add_Field(SG_T("NAME") , SG_DATATYPE_String); DataObject_Set_Parameter(m_pPolygons, DataObject_Get_Parameter(pGrid, "LUT")); // Lookup Table DataObject_Set_Parameter(m_pPolygons, DataObject_Get_Parameter(pGrid, "COLORS_TYPE")); // Color Classification Type: Lookup Table DataObject_Set_Parameter(m_pPolygons, "LUT_ATTRIB", 0); // Color Attribute m_pPolygons->Set_Name(pGrid->Get_Name()); //----------------------------------------------------- Process_Set_Text(_TL("class identification")); m_Classes.Create(pGrid->Get_System(), SG_DATATYPE_Int); m_Classes.Set_NoData_Value(-1); m_Classes.Assign_NoData(); //----------------------------------------------------- if( Parameters("CLASS_ALL")->asInt() == 1 ) { if( !pGrid->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } for(i=0, id=-1; iGet_Sorted(i, x, y, false) ) { if( m_pPolygons->Get_Count() == 0 || Value != pGrid->asDouble(x, y) ) { CSG_Shape *pPolygon = m_pPolygons->Add_Shape(); pPolygon->Set_Value(0, Value = pGrid->asDouble(x, y)); pPolygon->Set_Value(1, 1 + id++); pPolygon->Set_Value(2, CSG_String::Format(SG_T("%d"), m_pPolygons->Get_Count())); } m_Classes.Set_Value(x, y, id); } } } //----------------------------------------------------- else { CSG_Shape *pPolygon = m_pPolygons->Add_Shape(); pPolygon->Set_Value(0, Value = Parameters("CLASS_ID")->asDouble()); pPolygon->Set_Value(1, m_pPolygons->Get_Count()); pPolygon->Set_Value(2, CSG_String::Format(SG_T("%d"), m_pPolygons->Get_Count())); for(y=0; yasDouble(x, y) == Value ) { m_Classes.Set_Value(x, y, 0); } } } } //----------------------------------------------------- return( m_pPolygons->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::Get_Edges(void) { /////////////////////////////////////////////////////// //----------------------------------------------------- Process_Set_Text(_TL("edge detection")); int y, nEdges = 0; m_Edges.Create(SG_DATATYPE_Int, 2 * Get_NX() + 1, 2 * Get_NY() + 1, 0.5 * Get_Cellsize(), Get_XMin() - 0.5 * Get_Cellsize(), Get_YMin() - 0.5 * Get_Cellsize()); m_Edges.Set_NoData_Value(-2); m_Edges.Assign_NoData(); m_bAllVertices = Parameters("ALLVERTICES")->asBool(); //----------------------------------------------------- for(y=0; y= 0 ) { for(int i=0; i<8; i+=2) { if( m_Edges.asInt(Get_xTo(i, x), Get_yTo(i, y)) == -1 ) { Get_Edge(Get_xTo(i, x), Get_yTo(i, y), i + 2, m_Edges.asInt(x, y)); break; } } } } } /////////////////////////////////////////////////////// //----------------------------------------------------- m_Edges.Destroy(); return( true ); } //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::Get_Edge(int x, int y, int i, int Class) { CSG_Shape *pPolygon = m_pPolygons->Get_Shape(Class); if( !pPolygon ) { return( false ); } //----------------------------------------------------- int xFirst, yFirst, ix, iy, iPart; xFirst = x; yFirst = y; iPart = pPolygon->Get_Part_Count(); pPolygon->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), iPart); //----------------------------------------------------- do { ix = Get_xTo(i + 2, x); iy = Get_yTo(i + 2, y); if( m_Edges.is_InGrid(ix, iy) && m_Edges.asInt(ix, iy) == -1 ) // go right ? { pPolygon->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), iPart); i = (i + 2) % 8; } else { if( m_Edges.asInt(ix, iy) == Class ) { m_Edges.Set_NoData(ix, iy); // erase class id in right cells } ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( m_Edges.is_InGrid(ix, iy) && m_Edges.asInt(ix, iy) == -1 ) // go ahead ? { if( m_bAllVertices ) { pPolygon->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), iPart); } } else { ix = Get_xTo(i + 6, x); iy = Get_yTo(i + 6, y); if( m_Edges.is_InGrid(ix, iy) && m_Edges.asInt(ix, iy) == -1 ) // go left ? { pPolygon->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), iPart); i = (i + 6) % 8; } else { return( false ); } } } x = ix; y = iy; } while( x != xFirst || y != yFirst ); pPolygon->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), iPart); if( pPolygon->Get_Point_Count(iPart) < 4 ) { pPolygon->Del_Part(iPart); return( false ); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::Split_Polygons(void) { Process_Set_Text(_TL("splitting polygon parts")); CSG_Shapes Polygons(*m_pPolygons); m_pPolygons->Del_Records(); for(int iPolygon=0; iPolygonGet_Part_Count() && Process_Get_Okay(); iPart++) { if( !pPolygon->is_Lake(iPart) ) { CSG_Shape *pShape = m_pPolygons->Add_Shape(pPolygon, SHAPE_COPY_ATTR); for(iPoint=0, jPart=0; iPointGet_Point_Count(iPart); iPoint++) { pShape->Add_Point(pPolygon->Get_Point(iPoint, iPart), jPart); } for(int kPart=0; kPartGet_Part_Count(); kPart++) { if( pPolygon->is_Lake(kPart) && pPolygon->Contains(pPolygon->Get_Point(0, kPart), iPart) ) { jPart++; for(iPoint=0; iPointGet_Point_Count(kPart); iPoint++) { pShape->Add_Point(pPolygon->Get_Point(iPoint, kPart), jPart); } } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// /*/--------------------------------------------------------- class CSG_Vector_Topology { public: CSG_Vector_Topology(void) { m_Nodes.Create(SHAPE_TYPE_Point, SG_T("NODES")); m_Nodes.Add_Field(SG_T("ID") , SG_DATATYPE_Int); m_Edges.Create(SHAPE_TYPE_Line , SG_T("EDGES")); m_Edges.Add_Field(SG_T("ID") , SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("NODE_FROM") , SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("NODE_TO") , SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("FACE_LEFT") , SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("FACE_RIGHT"), SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("PROCESSED") , SG_DATATYPE_Int); } virtual ~CSG_Vector_Topology(void) { Destroy(); } bool Destroy (void) { m_Nodes.Del_Records(); m_Edges.Del_Records(); return( true ); } bool Add_Node (int ID, double x, double y) { CSG_Shape *pNode = m_Nodes.Add_Shape(); pNode->Set_Point(x, y, 0); pNode->Set_Value(0, ID); return( true ); } bool Add_Node (int ID, const TSG_Point &Point) { return( Add_Node(ID, Point.x, Point.y) ); } CSG_Shapes m_Nodes, m_Edges; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::Get_Edges(void) { /////////////////////////////////////////////////////// //----------------------------------------------------- Process_Set_Text(_TL("edge detection")); int y, nEdges = 0; m_Topology.Destroy(); m_Edges.Create(SG_DATATYPE_Int, 2 * Get_NX() + 1, 2 * Get_NY() + 1, 0.5 * Get_Cellsize(), Get_XMin() - 0.5 * Get_Cellsize(), Get_YMin() - 0.5 * Get_Cellsize()); m_Edges.Set_NoData_Value(-2); m_Edges.Assign_NoData(); //----------------------------------------------------- for(y=0; y 2 ) { m_Topology.Add_Node(nNodes, m_Edges.Get_System().Get_Grid_to_World(x, y)); m_Edges.Set_Value(x, y, nNodes++); } } else { m_Edges.Set_Value(x, y, -2); } } } /////////////////////////////////////////////////////// //----------------------------------------------------- Process_Set_Text(_TL("edge collection")); //----------------------------------------------------- for(y=0; y= 0 ) // node { for(int i=0; i<8; i+=2) { if( m_Edges.is_InGrid(Get_xTo(i, x), Get_yTo(i, y)) ) { Get_Edge(x, y, i); } } } } } //----------------------------------------------------- for(y=0; yAdd_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), 0); pEdge->Set_Value(0, m_Topology.m_Edges.Get_Count() - 1); // edge id pEdge->Set_Value(1, m_Edges.asInt(x, y)); // from node int ix, iy; ix = Get_xTo(i - 1, x) / 2; iy = Get_yTo(i - 1, y) / 2; pEdge->Set_Value(3, m_Classes.is_InGrid(ix, iy) ? m_Classes.asInt(ix, iy) : -1); // left face ix = Get_xTo(i + 1, x) / 2; iy = Get_yTo(i + 1, y) / 2; pEdge->Set_Value(4, m_Classes.is_InGrid(ix, iy) ? m_Classes.asInt(ix, iy) : -1); // right face //----------------------------------------------------- do { x = Get_xTo(i, x); y = Get_yTo(i, y); if( m_Edges.asInt(x, y) >= 0 ) // node { pEdge->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), 0); pEdge->Set_Value(2, m_Edges.asInt(x, y)); // to node return( true ); } m_Edges.Set_NoData(x, y); //------------------------------------------------- if( !m_Edges.is_InGrid(Get_xTo(i, x), Get_yTo(i, y)) ) // do not go ahead ? { pEdge->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), 0); if( m_Edges.is_InGrid(Get_xTo(i + 2, x), Get_yTo(i + 2, y)) ) // go right ? { i = (i + 2) % 8; } else if( m_Edges.is_InGrid(Get_xTo(i + 6, x), Get_yTo(i + 6, y)) ) // go left ? { i = (i + 6) % 8; } else { i = -1; } } } while( i >= 0 ); //----------------------------------------------------- m_Topology.m_Edges.Del_Record(m_Topology.m_Edges.Get_Count() - 1); return( false ); }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Values_AddTo_Shapes.cpp0000664000175000017500000002621212565125410027073 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Values_AddTo_Shapes.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Values_AddTo_Shapes.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Values_AddTo_Shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Values_AddTo_Shapes::CGrid_Values_AddTo_Shapes(void) { //----------------------------------------------------- Set_Name (_TL("Add Grid Values to Shapes")); Set_Author (SG_T("O.Conrad (c) 2003")); Set_Description (_TW( "Spatial Join: Retrieves information from the selected grids at the positions " "of the shapes of the selected shapes layer and adds it to the resulting shapes layer. " "For points this is similar to 'Add Grid Values to Points' module. " "For lines and polygons average values will be calculated from interfering grid cells. " "For polygons the 'Grid Statistics for Polygons' module offers more advanced options. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT, false ); Parameters.Add_Shapes( NULL , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "INTERPOL" , _TL("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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_Values_AddTo_Shapes::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SHAPES")) ) { pParameters->Get_Parameter("INTERPOL")->Set_Enabled(pParameter->asShapes() && ( pParameter->asShapes()->Get_Type() == SHAPE_TYPE_Point || pParameter->asShapes()->Get_Type() == SHAPE_TYPE_Points || pParameter->asShapes()->Get_Type() == SHAPE_TYPE_Line )); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Values_AddTo_Shapes::On_Execute(void) { CSG_Parameter_Grid_List *pGrids; CSG_Shapes *pShapes; //----------------------------------------------------- pShapes = Parameters("RESULT" )->asShapes(); pGrids = Parameters("GRIDS" )->asGridList(); m_Interpolation = Parameters("INTERPOL")->asInt(); //----------------------------------------------------- if( pGrids->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- if( pShapes == NULL ) { pShapes = Parameters("SHAPES")->asShapes(); } else if( pShapes != Parameters("SHAPES")->asShapes() ) { pShapes->Create(*Parameters("SHAPES")->asShapes()); } //----------------------------------------------------- for(int iGrid=0; iGridGet_Count(); iGrid++) { CSG_Grid *pGrid = pGrids->asGrid(iGrid); int Field = pShapes->Get_Field_Count(); pShapes->Add_Field(pGrid->Get_Name(), SG_DATATYPE_Double); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Simple_Statistics Statistics; CSG_Shape *pShape = pShapes->Get_Shape(iShape); if( pShape->Get_Extent().Intersects(pGrid->Get_Extent()) ) { switch( pShapes->Get_Type() ) { case SHAPE_TYPE_Point: default: case SHAPE_TYPE_Points: Get_Data_Point (Statistics, pShape, pGrid); break; case SHAPE_TYPE_Line: Get_Data_Line (Statistics, pShape, pGrid); break; case SHAPE_TYPE_Polygon: Get_Data_Polygon(Statistics, pShape, pGrid); break; } } if( Statistics.Get_Count() > 0 ) { pShape->Set_Value(Field, Statistics.Get_Mean()); } else { pShape->Set_NoData(Field); } } } //----------------------------------------------------- if( pShapes == Parameters("SHAPES")->asShapes() ) { DataObject_Update(pShapes); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CGrid_Values_AddTo_Shapes::Get_Data_Point(CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { double Value; if( pGrid->Get_Value(pShape->Get_Point(iPoint, iPart), Value, m_Interpolation) ) { Statistics += Value; } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CGrid_Values_AddTo_Shapes::Get_Data_Line(CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid) { double dStep = pGrid->Get_Cellsize(); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pShape->Get_Point_Count(iPart) > 0 ) { double Value; TSG_Point B, A = pShape->Get_Point(0, iPart); if( pGrid->Get_Value(A, Value, m_Interpolation) ) { Statistics += Value; } for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { B = A; A = pShape->Get_Point(iPoint, iPart); //----------------------------------------- double Distance = SG_Get_Distance(A, B); if( Distance > 0.0 ) { double dx = (B.x - A.x) * dStep / Distance; double dy = (B.y - A.y) * dStep / Distance; TSG_Point C = A; for(double d=0.0; dGet_Value(C, Value, m_Interpolation) ) { Statistics += Value; } } } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CGrid_Values_AddTo_Shapes::Get_Data_Polygon(CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid) { int xMin = pGrid->Get_System().Get_xWorld_to_Grid(pShape->Get_Extent().Get_XMin()); int xMax = pGrid->Get_System().Get_xWorld_to_Grid(pShape->Get_Extent().Get_XMax()); int yMin = pGrid->Get_System().Get_yWorld_to_Grid(pShape->Get_Extent().Get_YMin()); int yMax = pGrid->Get_System().Get_yWorld_to_Grid(pShape->Get_Extent().Get_YMax()); if( xMin < 0 ) xMin = 0; else if( xMin >= pGrid->Get_NX() ) xMin = pGrid->Get_NX() - 1; if( xMax < 0 ) xMax = 0; else if( xMax >= pGrid->Get_NX() ) xMax = pGrid->Get_NX() - 1; if( yMin < 0 ) yMin = 0; else if( yMin >= pGrid->Get_NY() ) yMin = pGrid->Get_NY() - 1; if( yMax < 0 ) yMax = 0; else if( yMax >= pGrid->Get_NY() ) yMax = pGrid->Get_NY() - 1; //----------------------------------------------------- for(int y=yMin; y<=yMax; y++) { double p_y = pGrid->Get_System().Get_yGrid_to_World(y); for(int x=xMin; x<=xMax; x++) { double p_x = pGrid->Get_System().Get_xGrid_to_World(x); if( !pGrid->is_NoData(x, y) && ((CSG_Shape_Polygon *)pShape)->Contains(p_x, p_y) ) { Statistics += pGrid->asDouble(x, y); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Classes_To_Shapes.h0000664000175000017500000001104212565125410026260 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Classes_To_Shapes.h 2159 2014-06-12 16:07:02Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Classes_To_Shapes.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Classes_To_Shapes_H #define HEADER_INCLUDED__Grid_Classes_To_Shapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Classes_To_Shapes : public CSG_Module_Grid { public: CGrid_Classes_To_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Vectorization") ); } protected: virtual bool On_Execute (void); private: bool m_bAllVertices; CSG_Grid m_Classes, m_Edges; CSG_Shapes *m_pPolygons; bool Get_Classes (void); bool Get_Edges (void); bool Get_Edge (int x, int y, int i, int Class); bool Split_Polygons (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Classes_To_Shapes_H saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Values_AddTo_Shapes.h0000664000175000017500000001135112565125410026536 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Values_AddTo_Shapes.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Values_AddTo_Shapes.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Values_AddTo_Shapes_H #define HEADER_INCLUDED__Grid_Values_AddTo_Shapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Values_AddTo_Shapes : public CSG_Module { public: CGrid_Values_AddTo_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Grid Values") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_Interpolation; void Get_Data_Point (CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid); void Get_Data_Line (CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid); void Get_Data_Polygon (CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Values_AddTo_Shapes_H saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Polygon_Clip.h0000664000175000017500000001060712565125410025322 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Polygon_Clip.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Polygon_Clip.h // // // // Copyright (C) 2006 by // // Stefan Liersch // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stliersch@freenet.de // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Polygon_Clip_H #define HEADER_INCLUDED__Grid_Polygon_Clip_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Polygon_Clip : public CSG_Module_Grid { public: // constructor CGrid_Polygon_Clip(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Spatial Extent") ); } protected: // execute module virtual bool On_Execute (void); private: bool m_bNoData; // estimates the Extent of the new grid bool Get_Extent (int &xMin, int &xCount, int &yMin, int &yCount, CSG_Grid *pMask, CSG_Parameter_Grid_List *pGrids); bool is_InGrid (int x, int y, CSG_Grid *pMask, CSG_Parameter_Grid_List *pGrids); // This function has been copied from Module: 'Grid_Statistics_AddTo_Polygon' // Function: Get_ShapeIDs // copyright by Olaf Conrad bool Get_Mask (CSG_Shapes *pShapes, CSG_Grid *pMask); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Polygon_Clip_H saga-2.2.3/src/modules/shapes/shapes_grid/grid_local_extremes_to_points.cpp0000664000175000017500000001532212565125410030422 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_local_extremes_to_points.cpp 2185 2014-07-14 11:49:08Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_local_extremes_to_points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_local_extremes_to_points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Local_Extremes_to_Points::CGrid_Local_Extremes_to_Points(void) { Set_Name (_TL("Local Minima and Maxima")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "Extracts local grid value minima and maxima of to vector points." )); Parameters.Add_Grid( NULL, "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL, "MINIMA" , _TL("Minima"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL, "MAXIMA" , _TL("Maxima"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Local_Extremes_to_Points::On_Execute(void) { CSG_Grid *pGrid = Parameters("GRID")->asGrid(); //----------------------------------------------------- CSG_Shapes *pMinima = Parameters("MINIMA")->asShapes(); pMinima->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pGrid->Get_Name(), _TL("Local Minima"))); pMinima->Add_Field(SG_T("GRID_X"), SG_DATATYPE_Int); pMinima->Add_Field(SG_T("GRID_Y"), SG_DATATYPE_Int); pMinima->Add_Field(SG_T("X" ), SG_DATATYPE_Double); pMinima->Add_Field(SG_T("Y" ), SG_DATATYPE_Double); pMinima->Add_Field(SG_T("Z" ), SG_DATATYPE_Double); //----------------------------------------------------- CSG_Shapes *pMaxima = Parameters("MAXIMA")->asShapes(); pMaxima->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pGrid->Get_Name(), _TL("Local Maxima"))); pMaxima->Add_Field(SG_T("GRID_X"), SG_DATATYPE_Int); pMaxima->Add_Field(SG_T("GRID_Y"), SG_DATATYPE_Int); pMaxima->Add_Field(SG_T("X" ), SG_DATATYPE_Double); pMaxima->Add_Field(SG_T("Y" ), SG_DATATYPE_Double); pMaxima->Add_Field(SG_T("Z" ), SG_DATATYPE_Double); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { double z = pGrid->asDouble(x, y); bool bMinimum = true; bool bMaximum = true; for(int i=0; i<8 && (bMinimum || bMaximum); i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( !pGrid->is_InGrid(ix, iy) ) { bMinimum = bMaximum = false; } else { double iz = pGrid->asDouble(ix, iy); if( iz <= z ) { bMinimum = false; } else if( iz >= z ) { bMaximum = false; } } } //----------------------------------------- CSG_Shape *pPoint = bMinimum ? pMinima->Add_Shape() : bMaximum ? pMaxima->Add_Shape() : NULL; if( pPoint ) { TSG_Point p = Get_System()->Get_Grid_to_World(x, y); pPoint->Set_Point(p, 0); pPoint->Set_Value(0, x); pPoint->Set_Value(1, y); pPoint->Set_Value(2, p.x); pPoint->Set_Value(3, p.y); pPoint->Set_Value(4, z); } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_grid/grid_extent.h0000664000175000017500000001040312565125410024265 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_extent.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_extent.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_extent_H #define HEADER_INCLUDED__grid_extent_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Extent : public CSG_Module_Grid { public: CGrid_Extent(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Spatial Extent") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_extent_H saga-2.2.3/src/modules/shapes/shapes_grid/Grid_To_Gradient.h0000664000175000017500000001072412565125410025123 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_To_Gradient.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Gradient.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_To_Gradient_H #define HEADER_INCLUDED__Grid_To_Gradient_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_To_Gradient : public CSG_Module_Grid { public: CGrid_To_Gradient(int Method); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Vectorization") ); } protected: virtual bool On_Execute (void); bool Initialize (void); private: int m_Method, m_Style; void Set_Vector (CSG_Shape *pVector, const TSG_Point &Point, double dx, double dy); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_To_Gradient_H saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Statistics_For_Points.h0000664000175000017500000001121412565125410027213 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Statistics_For_Points.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Statistics_For_Points.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Statistics_For_Points_H #define HEADER_INCLUDED__Grid_Statistics_For_Points_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Statistics_For_Points : public CSG_Module_Grid { public: CGrid_Statistics_For_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Grid Values") ); } protected: virtual bool On_Execute (void); private: CSG_Grid_Cell_Addressor m_Kernel; bool Get_Statistics (const TSG_Point &Point, CSG_Grid *pGrid, CSG_Simple_Statistics &Statistics); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Statistics_For_Points_H saga-2.2.3/src/modules/shapes/shapes_grid/Grid_To_Points_Random.cpp0000664000175000017500000001250112565125410026470 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_To_Points_Random.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Points_Random.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "Grid_To_Points_Random.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_To_Points_Random::CGrid_To_Points_Random() { Set_Name (_TL("Grid Values to Points (randomly)")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Extract randomly points from gridded data." )); Parameters.Add_Grid( NULL, "GRID" , _TL("Grid") , _TL(""), PARAMETER_INPUT); Parameters.Add_Value( NULL, "FREQ" , _TL("Frequency") , _TL("One per x"), PARAMETER_TYPE_Int, 100, 1, true); Parameters.Add_Shapes( NULL, "POINTS" , _TL("Points") , _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point); } //--------------------------------------------------------- CGrid_To_Points_Random::~CGrid_To_Points_Random() {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Points_Random::On_Execute(void) { int x, y, n; double frequency; CSG_Grid *pGrid; CSG_Shape *pShape; CSG_Shapes *pShapes; pGrid = Parameters("GRID")->asGrid(); frequency = 1.0 / Parameters("FREQ")->asDouble(); pShapes = Parameters("POINTS")->asShapes(); pShapes->Create(SHAPE_TYPE_Point, pGrid->Get_Name()); pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("VALUE" , SG_DATATYPE_Double); srand((unsigned)time(NULL)); for(n=0, y=0; yAdd_Shape(); pShape->Add_Point( pGrid->Get_XMin() + x * Get_Cellsize(), pGrid->Get_YMin() + y * Get_Cellsize() ); pShape->Set_Value(0, ++n); pShape->Set_Value(1, pGrid->asDouble(x, y)); } } } return( true ); } saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Polygon_Clip.cpp0000664000175000017500000002756212565125410025665 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Polygon_Clip.cpp 2346 2014-11-28 11:39:34Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Polygon_Clip.cpp // // // // Copyright (C) 2006 by // // Stefan Liersch // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stliersch@freenet.de // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Polygon_Clip.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define MASK_OFF -1 #define MASK_ON 1 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // constructor //--------------------------------------------------------- CGrid_Polygon_Clip::CGrid_Polygon_Clip(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Clip Grid with Polygon")); Set_Author (_TL("copyrights (c) 2006 Stefan Liersch")); Set_Description (_TW( "Clips the input grid with a polygon shapefile. Select " "polygons from the shapefile prior to module execution " "in case you like to use only a subset from the shapefile " "for clipping." )); //----------------------------------------------------- // Parameters list... Parameters.Add_Grid_List( NULL, "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT, false ); Parameters.Add_Grid_List( NULL, "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL, "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL, "NODATA" , _TL("Exclude No-Data Area"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // This function is executed if the user is pressing the OK button //--------------------------------------------------------- bool CGrid_Polygon_Clip::On_Execute(void) { int x, y, ix, iy, ax, ay, nx, ny; CSG_Parameter_Grid_List *pGrids_in, *pGrids_out; CSG_Grid *pGrid_in, *pGrid_out, Mask; CSG_Shapes *pShapes; //----------------------------------------------------- pGrids_in = Parameters("INPUT" )->asGridList(); pGrids_out = Parameters("OUTPUT" )->asGridList(); pShapes = Parameters("POLYGONS")->asShapes(); m_bNoData = Parameters("NODATA" )->asBool(); //----------------------------------------------------- if( pShapes->Get_Type() == SHAPE_TYPE_Polygon && pShapes->Get_Count() > 0 && Get_System()->Get_Extent().Intersects(pShapes->Get_Extent()) ) { // create temporary grid. // Cells within the shapefile get the value +1 // Cells outside the shapefile get the value -1 Mask.Create(*Get_System(), SG_DATATYPE_Byte); //------------------------------------------------- // Get_Mask assignes +1 values to gridcells within the shapefile // The function has been copied from Module: 'Grid_Statistics_AddTo_Polygon' // Function: Get_ShapeIDs(...) // and check extent of valid values in Mask to // calculate GridSystem parameters pGrid_out if( Get_Mask(pShapes, &Mask) && Get_Extent(ax, nx, ay, ny, &Mask, pGrids_in) ) { for(int iGrid=0; iGridGet_Count(); iGrid++) { pGrid_in = pGrids_in->asGrid(iGrid); pGrid_out = SG_Create_Grid( // creating the output grid GridSystem pGrid_in->Get_Type(), nx, ny, Get_Cellsize(), Get_XMin() + ax * Get_Cellsize(), Get_YMin() + ay * Get_Cellsize() ); pGrid_out ->Set_Name(pGrid_in->Get_Name()); pGrid_out ->Set_NoData_Value(pGrid_in->Get_NoData_Value()); pGrids_out ->Add_Item(pGrid_out); // Assign valid values from input grid to the cells of the // output grid that are within the borders of the shapefile // Assign NoData values to the cells outside the shapefile borders for(y=0, iy=ay; ySet_Value(x, y, pGrid_in->asDouble(ix, iy)); } else { pGrid_out->Set_NoData(x, y); } } } } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// //--------------------------------------------------------- // This function modifies the incoming integer variables!!! //--------------------------------------------------------- bool CGrid_Polygon_Clip::Get_Extent(int &xMin, int &xCount, int &yMin, int &yCount, CSG_Grid *pMask, CSG_Parameter_Grid_List *pGrids) { bool bFound; for(yMin=0, bFound=false; yMin=yMin && !bFound && Process_Get_Okay(true); yMax--) { for(int x=0; x=xMin && !bFound && Process_Get_Okay(true); xMax--) { for(int y=yMin; y 0 && yCount > 0 ); } return( false ); } //--------------------------------------------------------- bool CGrid_Polygon_Clip::is_InGrid(int x, int y, CSG_Grid *pMask, CSG_Parameter_Grid_List *pGrids) { if( pMask->asInt(x, y) == MASK_ON ) { if( !m_bNoData ) { return( true ); } for(int i=0; iGet_Count(); i++) { if( !pGrids->asGrid(i)->is_NoData(x, y) ) { return( true ); } } } return( false ); } /////////////////////////////////////////////////////////// //--------------------------------------------------------- // This function has been copied from Module: 'Grid_Statistics_AddTo_Polygon' // Function: Get_ShapeIDs(...) // copyright by Olaf Conrad // // added support to clip only with selected polygons (Volker Wichmann) //--------------------------------------------------------- bool CGrid_Polygon_Clip::Get_Mask(CSG_Shapes *pShapes, CSG_Grid *pMask) { bool bFill, *bCrossing; bool bOnlySelected = false; int x, y, ix, xStart, xStop, iShape, iPart, iPoint; double yPos; TSG_Point pLeft, pRight, pa, pb, p; TSG_Rect Extent; CSG_Shape *pShape; //----------------------------------------------------- pMask->Assign(MASK_OFF); bCrossing = (bool *)SG_Malloc(pMask->Get_NX() * sizeof(bool)); if (pShapes->Get_Selection_Count() > 0) bOnlySelected = true; //----------------------------------------------------- for(iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { if (bOnlySelected && !pShapes->Get_Shape(iShape)->is_Selected()) continue; pShape = pShapes->Get_Shape(iShape); Extent = pShape->Get_Extent().m_rect; xStart = Get_System()->Get_xWorld_to_Grid(Extent.xMin) - 1; if( xStart < 0 ) xStart = 0; xStop = Get_System()->Get_xWorld_to_Grid(Extent.xMax) + 1; if( xStop >= Get_NX() ) xStop = Get_NX() - 1; pLeft.x = pMask->Get_XMin() - 1.0; pRight.x = pMask->Get_XMax() + 1.0; //------------------------------------------------- for(y=0, yPos=pMask->Get_YMin(); yGet_NY(); y++, yPos+=pMask->Get_Cellsize()) { if( yPos >= Extent.yMin && yPos <= Extent.yMax ) { memset(bCrossing, 0, pMask->Get_NX() * sizeof(bool)); pLeft.y = pRight.y = yPos; //----------------------------------------- for(iPart=0; iPartGet_Part_Count(); iPart++) { pb = pShape->Get_Point(pShape->Get_Point_Count(iPart) - 1, iPart); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pa = pb; pb = pShape->Get_Point(iPoint, iPart); if( ( (pa.y <= yPos && yPos < pb.y) || (pa.y > yPos && yPos >= pb.y) ) ) { SG_Get_Crossing(p, pa, pb, pLeft, pRight, false); ix = (int)((p.x - pMask->Get_XMin()) / pMask->Get_Cellsize() + 1.0); if( ix < 0) { ix = 0; } else if( ix >= pMask->Get_NX() ) { continue; } bCrossing[ix] = !bCrossing[ix]; } } } //----------------------------------------- for(x=xStart, bFill=false; x<=xStop; x++) { if( bCrossing[x] ) { bFill = !bFill; } if( bFill ) { pMask->Set_Value(x, y, MASK_ON); } } } } } //----------------------------------------------------- SG_Free(bCrossing); return( true ); } saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Values_AddTo_Points.h0000664000175000017500000001045412565125410026572 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Values_AddTo_Points.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Values_AddTo_Points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Values_AddTo_Points_H #define HEADER_INCLUDED__Grid_Values_AddTo_Points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Values_AddTo_Points : public CSG_Module { public: CGrid_Values_AddTo_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Grid Values") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Values_AddTo_Points_H saga-2.2.3/src/modules/shapes/shapes_grid/MLB_Interface.cpp0000664000175000017500000001337012565125410024704 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2443 2015-03-18 19:52:26Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Grid Tools") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V.Wichmann (c) 2002-13") ); case MLB_INFO_Description: return( _TL("Tools related to gridded and vector data (conversions, combinations, etc.).") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Grid") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Grid_Values_AddTo_Points.h" #include "Grid_Values_AddTo_Shapes.h" #include "Grid_Statistics_AddTo_Polygon.h" #include "Grid_Statistics_For_Points.h" #include "Grid_To_Points.h" #include "Grid_To_Points_Random.h" #include "Grid_To_Contour.h" #include "Grid_Classes_To_Shapes.h" #include "Grid_Polygon_Clip.h" #include "Grid_To_Gradient.h" #include "grid_local_extremes_to_points.h" #include "grid_extent.h" #include "grid_rectangle_clip.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CGrid_Values_AddTo_Points ); case 1: return( new CGrid_Values_AddTo_Shapes ); case 2: return( new CGrid_Statistics_AddTo_Polygon ); case 8: return( new CGrid_Statistics_For_Points ); case 3: return( new CGrid_To_Points ); case 4: return( new CGrid_To_Points_Random ); case 5: return( new CGrid_To_Contour ); case 6: return( new CGrid_Classes_To_Shapes ); case 7: return( new CGrid_Polygon_Clip ); case 9: return( new CGrid_Local_Extremes_to_Points ); case 10: return( new CGrid_Extent ); case 11: return( new CGrid_Rectangle_Clip ); case 15: return( new CGrid_To_Gradient(0) ); case 16: return( new CGrid_To_Gradient(1) ); case 17: return( new CGrid_To_Gradient(2) ); case 20: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/shapes/shapes_grid/Makefile.am0000664000175000017500000000235312565125410023641 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 2443 2015-03-18 19:52:26Z oconrad $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_grid.la libshapes_grid_la_SOURCES =\ Grid_Classes_To_Shapes.cpp\ grid_extent.cpp\ grid_local_extremes_to_points.cpp\ Grid_Polygon_Clip.cpp\ grid_rectangle_clip.cpp\ Grid_Statistics_AddTo_Polygon.cpp\ Grid_Statistics_For_Points.cpp\ Grid_To_Contour.cpp\ Grid_To_Gradient.cpp\ Grid_To_Points.cpp\ Grid_To_Points_Random.cpp\ Grid_Values_AddTo_Points.cpp\ Grid_Values_AddTo_Shapes.cpp\ MLB_Interface.cpp\ Grid_Classes_To_Shapes.h\ grid_extent.h\ grid_local_extremes_to_points.h\ Grid_Polygon_Clip.h\ grid_rectangle_clip.h\ Grid_Statistics_AddTo_Polygon.h\ Grid_Statistics_For_Points.h\ Grid_To_Contour.h\ Grid_To_Gradient.h\ Grid_To_Points.h\ Grid_To_Points_Random.h\ Grid_Values_AddTo_Points.h\ Grid_Values_AddTo_Shapes.h\ MLB_Interface.h libshapes_grid_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) saga-2.2.3/src/modules/shapes/shapes_grid/MLB_Interface.h0000664000175000017500000000771512565125410024357 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__shapes_grid_H #define HEADER_INCLUDED__shapes_grid_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef shapes_grid_EXPORTS #define shapes_grid_EXPORT _SAGA_DLL_EXPORT #else #define shapes_grid_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_grid_H saga-2.2.3/src/modules/shapes/shapes_grid/Grid_To_Points.cpp0000664000175000017500000002014212565125410025170 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_To_Points.cpp 2208 2014-08-27 16:00:51Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_To_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_To_Points::CGrid_To_Points(void) { //----------------------------------------------------- Set_Name (_TL("Grid Values to Points")); Set_Author (SG_T("O.Conrad (c) 2001")); Set_Description (_TW( "This module saves grid values to point (grid nodes) or polygon (grid cells) shapes. Optionally only points " "can be saved, which are contained by polygons of the specified shapes layer. " "In addition, it is possible to exclude all cells that are coded NoData in the " "first grid of the grid list." )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "NODATA" , _TL("Exclude NoData Cells"), _TL(""), PARAMETER_TYPE_Bool , true ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("nodes"), _TL("cells") ) ); } //--------------------------------------------------------- CGrid_To_Points::~CGrid_To_Points(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Points::On_Execute(void) { bool bNoNoData; int x, y, iGrid, iPoint, Type; double xPos, yPos; CSG_Grid *pGrid; CSG_Parameter_Grid_List *pGrids; CSG_Shape *pShape; CSG_Shapes *pShapes, *pPolygons; //----------------------------------------------------- pGrids = Parameters("GRIDS") ->asGridList(); pPolygons = Parameters("POLYGONS")->asShapes(); pShapes = Parameters("SHAPES") ->asShapes(); bNoNoData = Parameters("NODATA") ->asBool(); Type = Parameters("TYPE") ->asInt(); //----------------------------------------------------- if( pGrids->Get_Count() > 0 ) { switch( Type ) { case 0: pShapes->Create(SHAPE_TYPE_Point , _TL("Grid Values [Nodes]")); break; case 1: pShapes->Create(SHAPE_TYPE_Polygon, _TL("Grid Values [Cells]")); break; } pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("X" , SG_DATATYPE_Double); pShapes->Add_Field("Y" , SG_DATATYPE_Double); for(iGrid=0; iGridGet_Count(); iGrid++) { pShapes->Add_Field(CSG_String::Format(SG_T("%s"),pGrids->asGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.')).c_str(), SG_DATATYPE_Double); } //------------------------------------------------- for(y=0, yPos=Get_YMin() - (Type ? 0.5 * Get_Cellsize() : 0.0), iPoint=0; yasGrid(0)->is_NoData(x, y))) && (!pPolygons || is_Contained(xPos, yPos, pPolygons)) ) { pShape = pShapes->Add_Shape(); switch( Type ) { case 0: pShape->Add_Point(xPos, yPos); break; case 1: pShape->Add_Point(xPos , yPos ); pShape->Add_Point(xPos + Get_Cellsize(), yPos ); pShape->Add_Point(xPos + Get_Cellsize(), yPos + Get_Cellsize()); pShape->Add_Point(xPos , yPos + Get_Cellsize()); break; } pShape->Set_Value(0, ++iPoint); pShape->Set_Value(1, xPos); pShape->Set_Value(2, yPos); for(iGrid=0; iGridGet_Count(); iGrid++) { pGrid = pGrids->asGrid(iGrid); pShape->Set_Value(iGrid + 3, pGrid->is_NoData(x, y) ? -99999 : pGrid->asDouble(x, y)); } } } } return( pShapes->Get_Count() > 0 ); } return( false ); } //--------------------------------------------------------- inline bool CGrid_To_Points::is_Contained(double x, double y, CSG_Shapes *pPolygons) { if( pPolygons && pPolygons->Get_Type() == SHAPE_TYPE_Polygon ) { for(int iPolygon=0; iPolygonGet_Count(); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); if( pPolygon->Contains(x, y) ) { return( true ); } } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_grid/grid_local_extremes_to_points.h0000664000175000017500000001025512565125410030067 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_local_extremes_to_points.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_local_extremes_to_points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_local_extremes_to_points_H #define HEADER_INCLUDED__grid_local_extremes_to_points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Local_Extremes_to_Points : public CSG_Module_Grid { public: CGrid_Local_Extremes_to_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Grid Values") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_local_extremes_to_points_H saga-2.2.3/src/modules/shapes/shapes_grid/grid_rectangle_clip.h0000664000175000017500000001055212565125410025736 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_rectangle_clip.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_rectangle_clip.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_rectangle_clip_H #define HEADER_INCLUDED__grid_rectangle_clip_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Rectangle_Clip : public CSG_Module { public: CGrid_Rectangle_Clip(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Spatial Extent") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_rectangle_clip_H saga-2.2.3/src/modules/shapes/shapes_grid/grid_extent.cpp0000664000175000017500000001344612565125410024632 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_extent.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_extent.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_extent.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Extent::CGrid_Extent(void) { //----------------------------------------------------- Set_Name (_TL("Grid System Extent")); Set_Author (_TL("O. Conrad (c) 2011")); Set_Description (_TW( "Creates a polygon (rectangle) from a grid system's extent." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "CELLS" , _TL("Border"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("grid cells"), _TL("grid nodes") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Extent::On_Execute(void) { bool bCells; CSG_Grid_System *pSystem; CSG_Shapes *pShapes; //----------------------------------------------------- pSystem = Get_System(); pShapes = Parameters("SHAPES") ->asShapes(); bCells = Parameters("CELLS") ->asInt() == 0; //----------------------------------------------------- if( pSystem == NULL || !pSystem->is_Valid() ) { Error_Set(_TL("invalid grid system")); return( false ); } //----------------------------------------------------- pShapes->Create(SHAPE_TYPE_Polygon, _TL("Grid System Extent")); pShapes->Add_Field(_TL("NX") , SG_DATATYPE_Int); pShapes->Add_Field(_TL("NY") , SG_DATATYPE_Int); pShapes->Add_Field(_TL("CELLSIZE") , SG_DATATYPE_Double); CSG_Shape *pExtent = pShapes->Add_Shape(); pExtent->Set_Value(0, pSystem->Get_NX()); pExtent->Set_Value(1, pSystem->Get_NY()); pExtent->Set_Value(2, pSystem->Get_Cellsize()); pExtent->Add_Point(pSystem->Get_XMin(bCells), pSystem->Get_YMin(bCells)); pExtent->Add_Point(pSystem->Get_XMin(bCells), pSystem->Get_YMax(bCells)); pExtent->Add_Point(pSystem->Get_XMax(bCells), pSystem->Get_YMax(bCells)); pExtent->Add_Point(pSystem->Get_XMax(bCells), pSystem->Get_YMin(bCells)); pExtent->Add_Point(pSystem->Get_XMin(bCells), pSystem->Get_YMin(bCells)); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_grid/Grid_To_Points_Random.h0000664000175000017500000001044112565125410026136 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_To_Points_Random.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Points_Random.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_To_Points_Random_H #define HEADER_INCLUDED__Grid_To_Points_Random_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_To_Points_Random : public CSG_Module_Grid { public: CGrid_To_Points_Random(void); virtual ~CGrid_To_Points_Random(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Vectorization") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_To_Points_Random_H saga-2.2.3/src/modules/shapes/shapes_grid/Grid_Statistics_AddTo_Polygon.cpp0000664000175000017500000004212112565125410030167 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Statistics_AddTo_Polygon.cpp 2443 2015-03-18 19:52:26Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Statistics_AddTo_Polygon.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // // quantile calculation: // // Copyright (C) 2007 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Statistics_AddTo_Polygon.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Statistics_AddTo_Polygon::CGrid_Statistics_AddTo_Polygon(void) { //----------------------------------------------------- Set_Name (_TL("Grid Statistics for Polygons")); Set_Author ("O.Conrad (c) 2003, Quantile Calculation (c) 2007 by Johan Van de Wauw"); Set_Description (_TW( "Zonal grid statistics. For each polygon statistics based on all covered grid cells will be calculated." )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format("%s|%s|", _TL("standard"), _TL("shape wise, supports overlapping polygons") ), 0 ); Parameters.Add_Choice( NULL , "NAMING" , _TL("Field Naming"), _TL(""), CSG_String::Format("%s|%s|", _TL("grid number"), _TL("grid name") ), 1 ); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "RESULT" , _TL("Statistics"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value(pNode, "COUNT" , _TL("Number of Cells" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MIN" , _TL("Minimum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MAX" , _TL("Maximum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "RANGE" , _TL("Range" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "SUM" , _TL("Sum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MEAN" , _TL("Mean" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "VAR" , _TL("Variance" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "STDDEV" , _TL("Standard Deviation"), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "QUANTILE", _TL("Quantile" ), _TL("Calculate distribution quantiles. Value specifies interval (median=50, quartiles=25, deciles=10, ...). Set to zero to omit quantile calculation."), PARAMETER_TYPE_Int, 0, 0, true, 50, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_FIELD_NAME(VAR) Naming == 0 ? CSG_String::Format("G%02d_%s", iGrid + 1, VAR) : CSG_String::Format("%s [%s]", pGrids->asGrid(iGrid)->Get_Name(), VAR) //--------------------------------------------------------- bool CGrid_Statistics_AddTo_Polygon::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( pPolygons->Get_Count() <= 0 ) { Error_Set(_TL("no polygons in input layer")); return( false ); } //----------------------------------------------------- CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); if( pGrids->Get_Count() < 1 ) { Error_Set(_TL("no grids in selection")); return( false ); } if( !Get_System()->Get_Extent().Intersects(pPolygons->Get_Extent()) ) { Error_Set(_TL("no spatial intersection between grid(s) and polygon layer")); return( false ); } //----------------------------------------------------- int Quantile = Parameters("QUANTILE")->asInt(); int nFields = 0; int fCOUNT = Parameters("COUNT" )->asBool() ? nFields++ : -1; int fMIN = Parameters("MIN" )->asBool() ? nFields++ : -1; int fMAX = Parameters("MAX" )->asBool() ? nFields++ : -1; int fRANGE = Parameters("RANGE" )->asBool() ? nFields++ : -1; int fSUM = Parameters("SUM" )->asBool() ? nFields++ : -1; int fMEAN = Parameters("MEAN" )->asBool() ? nFields++ : -1; int fVAR = Parameters("VAR" )->asBool() ? nFields++ : -1; int fSTDDEV = Parameters("STDDEV" )->asBool() ? nFields++ : -1; int fQUANTILE = Quantile > 0 ? nFields++ : -1; if( nFields == 0 ) { Error_Set(_TL("no output parameter in selection")); return( false ); } //----------------------------------------------------- int Naming = Parameters("NAMING")->asInt(); int Method = Parameters("METHOD")->asInt(); if( Method == 0 && !Get_Index(pPolygons) ) { Error_Set(_TL("no grids in selection")); return( false ); } //----------------------------------------------------- if( Parameters("RESULT")->asShapes() != NULL && Parameters("RESULT")->asShapes() != pPolygons ) { pPolygons = Parameters("RESULT")->asShapes(); pPolygons ->Assign(Parameters("POLYGONS")->asShapes()); pPolygons ->Set_Name(CSG_String::Format("%s [%s]", Parameters("POLYGONS")->asShapes()->Get_Name(), _TL("Grid Statistics"))); } CSG_Simple_Statistics *Statistics = new CSG_Simple_Statistics[pPolygons->Get_Count()]; //----------------------------------------------------- for(int iGrid=0; iGridGet_Count() && Process_Get_Okay(); iGrid++) { Process_Set_Text(CSG_String::Format("[%d/%d] %s", 1 + iGrid, pGrids->Get_Count(), pGrids->asGrid(iGrid)->Get_Name())); if( (Method == 0 && Get_Statistics (pGrids->asGrid(iGrid), pPolygons, Statistics, Quantile > 0)) || (Method == 1 && Get_Statistics_Alt(pGrids->asGrid(iGrid), pPolygons, Statistics, Quantile > 0)) ) { nFields = pPolygons->Get_Field_Count(); if( fCOUNT >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("CELLS" )), SG_DATATYPE_Int ); if( fMIN >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("MIN" )), SG_DATATYPE_Double); if( fMAX >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("MAX" )), SG_DATATYPE_Double); if( fRANGE >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("RANGE" )), SG_DATATYPE_Double); if( fSUM >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("SUM" )), SG_DATATYPE_Double); if( fMEAN >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("MEAN" )), SG_DATATYPE_Double); if( fVAR >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("VARIANCE")), SG_DATATYPE_Double); if( fSTDDEV >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("STDDEV" )), SG_DATATYPE_Double); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile; iQuantile<100; iQuantile+=Quantile) { pPolygons->Add_Field(GET_FIELD_NAME(CSG_String::Format("Q%02d", iQuantile).c_str()), SG_DATATYPE_Double); } } //--------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pPolygons->Get_Count()); i++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(i); if( Statistics[i].Get_Count() == 0 ) { if( fCOUNT >= 0 ) pPolygon->Set_NoData(nFields + fCOUNT ); if( fMIN >= 0 ) pPolygon->Set_NoData(nFields + fMIN ); if( fMAX >= 0 ) pPolygon->Set_NoData(nFields + fMAX ); if( fRANGE >= 0 ) pPolygon->Set_NoData(nFields + fRANGE ); if( fSUM >= 0 ) pPolygon->Set_NoData(nFields + fSUM ); if( fMEAN >= 0 ) pPolygon->Set_NoData(nFields + fMEAN ); if( fVAR >= 0 ) pPolygon->Set_NoData(nFields + fVAR ); if( fSTDDEV >= 0 ) pPolygon->Set_NoData(nFields + fSTDDEV); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile, iField=nFields + fQUANTILE; iQuantile<100; iQuantile+=Quantile, iField++) { pPolygon->Set_NoData(iField); } } } else { if( fCOUNT >= 0 ) pPolygon->Set_Value(nFields + fCOUNT , Statistics[i].Get_Count ()); if( fMIN >= 0 ) pPolygon->Set_Value(nFields + fMIN , Statistics[i].Get_Minimum ()); if( fMAX >= 0 ) pPolygon->Set_Value(nFields + fMAX , Statistics[i].Get_Maximum ()); if( fRANGE >= 0 ) pPolygon->Set_Value(nFields + fRANGE , Statistics[i].Get_Range ()); if( fSUM >= 0 ) pPolygon->Set_Value(nFields + fSUM , Statistics[i].Get_Sum ()); if( fMEAN >= 0 ) pPolygon->Set_Value(nFields + fMEAN , Statistics[i].Get_Mean ()); if( fVAR >= 0 ) pPolygon->Set_Value(nFields + fVAR , Statistics[i].Get_Variance()); if( fSTDDEV >= 0 ) pPolygon->Set_Value(nFields + fSTDDEV, Statistics[i].Get_StdDev ()); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile, iField=nFields + fQUANTILE; iQuantile<100; iQuantile+=Quantile, iField++) { pPolygon->Set_Value(iField, Statistics[i].Get_Quantile(iQuantile)); } } } } } } //----------------------------------------------------- delete[](Statistics); DataObject_Update(pPolygons); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Statistics_AddTo_Polygon::Get_Statistics(CSG_Grid *pGrid, CSG_Shapes *pPolygons, CSG_Simple_Statistics *Statistics, bool bQuantiles) { int i; for(i=0; iGet_Count(); i++) { Statistics[i].Create(bQuantiles); } for(int y=0; y= 0 && i < pPolygons->Get_Count() ) { Statistics[i] += pGrid->asDouble(x, y); } } } return( true ); } //--------------------------------------------------------- bool CGrid_Statistics_AddTo_Polygon::Get_Statistics_Alt(CSG_Grid *pGrid, CSG_Shapes *pPolygons, CSG_Simple_Statistics *Statistics, bool bQuantiles) { for(int i=0; iGet_Count() && Set_Progress(i, pPolygons->Get_Count()); i++) { Statistics[i].Create(bQuantiles); CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(i); int ax = Get_System()->Get_xWorld_to_Grid(pPolygons->Get_Extent().Get_XMin()) - 1; if( ax < 0 ) ax = 0; int bx = Get_System()->Get_xWorld_to_Grid(pPolygons->Get_Extent().Get_XMax()) + 1; if( bx >= Get_NX() ) bx = Get_NX() - 1; int ay = Get_System()->Get_yWorld_to_Grid(pPolygons->Get_Extent().Get_YMin()) - 1; if( ay < 0 ) ay = 0; int by = Get_System()->Get_yWorld_to_Grid(pPolygons->Get_Extent().Get_YMax()) + 1; if( by >= Get_NY() ) by = Get_NY() - 1; double py = Get_System()->Get_yGrid_to_World(ay); for(int y=ay; y<=by; y++, py+=Get_Cellsize()) { double px = Get_System()->Get_xGrid_to_World(ax); for(int x=ax; x<=bx; x++, px+=Get_Cellsize()) { if( !pGrid->is_NoData(x, y) && pPolygon->Contains(px, py) ) { Statistics[i] += pGrid->asDouble(x, y); } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Statistics_AddTo_Polygon::Get_Index(CSG_Shapes *pPolygons) { bool bFill, *bCrossing; int x, y, ix, xStart, xStop, iShape, iPart, iPoint; double yPos; TSG_Point pLeft, pRight, pa, pb, p; TSG_Rect Extent; CSG_Shape *pPolygon; //----------------------------------------------------- m_Index.Create(*Get_System(), pPolygons->Get_Count() < 32767 ? SG_DATATYPE_Short : SG_DATATYPE_Int); m_Index.Assign(-1.0); bCrossing = (bool *)SG_Malloc(Get_NX() * sizeof(bool)); //----------------------------------------------------- for(iShape=0; iShapeGet_Count() && Set_Progress(iShape, pPolygons->Get_Count()); iShape++) { pPolygon = pPolygons->Get_Shape(iShape); Extent = pPolygon->Get_Extent().m_rect; xStart = Get_System()->Get_xWorld_to_Grid(Extent.xMin) - 1; if( xStart < 0 ) xStart = 0; xStop = Get_System()->Get_xWorld_to_Grid(Extent.xMax) + 1; if( xStop >= Get_NX() ) xStop = Get_NX() - 1; pLeft.x = Get_XMin() - 1.0; pRight.x = Get_XMax() + 1.0; //------------------------------------------------- for(y=0, yPos=Get_YMin(); y= Extent.yMin && yPos <= Extent.yMax ) { memset(bCrossing, 0, Get_NX() * sizeof(bool)); pLeft.y = pRight.y = yPos; //----------------------------------------- for(iPart=0; iPartGet_Part_Count(); iPart++) { pb = pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pa = pb; pb = pPolygon->Get_Point(iPoint, iPart); if( ( (pa.y <= yPos && yPos < pb.y) || (pa.y > yPos && yPos >= pb.y) ) ) { SG_Get_Crossing(p, pa, pb, pLeft, pRight, false); ix = (int)((p.x - Get_XMin()) / Get_Cellsize() + 1.0); if( ix < 0) { ix = 0; } else if( ix >= Get_NX() ) { continue; } bCrossing[ix] = !bCrossing[ix]; } } } //----------------------------------------- for(x=xStart, bFill=false; x<=xStop; x++) { if( bCrossing[x] ) { bFill = !bFill; } if( bFill ) { m_Index.Set_Value(x, y, iShape); } } } } } //----------------------------------------------------- SG_Free(bCrossing); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/0000775000175000017500000000000012634325745022027 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/shapes/shapes_tools/SelectByTheme.h0000664000175000017500000000424612565125410024671 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SelectByTheme.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* SelectByTheme.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelect_Location : public CSG_Module { public: CSelect_Location(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); private: CSG_Shapes *m_pShapes, *m_pLocations; bool Do_Select (CSG_Shape *pShape, int Condition); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/GraticuleBuilder.cpp0000664000175000017500000002133212614213767025760 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GraticuleBuilder.cpp 2661 2015-10-28 09:40:58Z oconrad $ *********************************************************/ /******************************************************************************* GraticuleBuilder.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "GraticuleBuilder.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGraticuleBuilder::CGraticuleBuilder(void) { Set_Name (_TL("Create Graticule")); Set_Author ("V.Olaya (c) 2004"); Set_Description (_TW( "(c) 2004 by Victor Olaya. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "GRATICULE_LINE" , _TL("Graticule"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "GRATICULE_RECT" , _TL("Graticule"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Type"), _TL(""), CSG_String::Format("%s|%s|", _TL("Lines"), _TL("Rectangles") ), 0 ); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Range( NULL , "EXTENT_X" , _TL("Width"), _TL(""), -180.0, 180.0 ); Parameters.Add_Range( NULL , "EXTENT_Y" , _TL("Height"), _TL(""), -90.0, 90.0 ); Parameters.Add_Value( NULL , "DIVISION_X" , _TL("Division Width"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Value( NULL , "DIVISION_Y" , _TL("Division Height"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Choice( NULL , "ALIGNMENT" , _TL("Alignment"), _TL("Determines how the graticule is aligned to the extent, if division sizes do not fit."), CSG_String::Format("%s|%s|%s|%s|%s|", _TL("bottom-left"), _TL("top-left"), _TL("bottom-right"), _TL("top-right"), _TL("centered") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGraticuleBuilder::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( CSG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CGraticuleBuilder::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TYPE") ) { pParameters->Set_Enabled("GRATICULE_LINE", pParameter->asInt() == 0); pParameters->Set_Enabled("GRATICULE_RECT", pParameter->asInt() != 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "EXTENT") ) { pParameters->Set_Enabled("EXTENT_X", pParameter->asShapes() == NULL); pParameters->Set_Enabled("EXTENT_Y", pParameter->asShapes() == NULL); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGraticuleBuilder::On_Execute(void) { //----------------------------------------------------- TSG_Rect Extent; if( Parameters("EXTENT")->asShapes() ) { Extent = Parameters("EXTENT")->asShapes()->Get_Extent(); } else { Extent.xMin = Parameters("EXTENT_X")->asRange()->Get_LoVal(); Extent.yMin = Parameters("EXTENT_Y")->asRange()->Get_LoVal(); Extent.xMax = Parameters("EXTENT_X")->asRange()->Get_HiVal(); Extent.yMax = Parameters("EXTENT_Y")->asRange()->Get_HiVal(); } if( Extent.xMin >= Extent.xMax || Extent.yMin >= Extent.yMax ) { Error_Set(_TL("invalid extent")); return( false ); } //----------------------------------------------------- double dx = Parameters("DIVISION_X")->asDouble(); double dy = Parameters("DIVISION_Y")->asDouble(); if( dx <= 0.0 || dy <= 0.0 ) { Error_Set(_TL("invalid division size")); return( false ); } //----------------------------------------------------- int nx = (int)ceil((Extent.xMax - Extent.xMin) / dx); int ny = (int)ceil((Extent.yMax - Extent.yMin) / dy); switch( Parameters("ALIGNMENT")->asInt() ) { default: // bottom-left // Extent.xMax = Extent.xMin + nx * dx; // Extent.yMax = Extent.yMin + ny * dy; break; case 1: // top-left // Extent.xMax = Extent.xMin + nx * dx; Extent.yMin = Extent.yMax - ny * dy; break; case 2: // bottom-right Extent.xMin = Extent.xMax - nx * dx; // Extent.yMax = Extent.yMin + ny * dy; break; case 3: // top-right Extent.xMin = Extent.xMax - nx * dx; Extent.yMin = Extent.yMax - ny * dy; break; case 4: // centered { double cx = Extent.xMin + (Extent.xMax - Extent.xMin) / 2.0; double cy = Extent.yMin + (Extent.yMax - Extent.yMin) / 2.0; Extent.xMin = cx - nx * dx / 2.0; Extent.yMin = cy - ny * dy / 2.0; // Extent.xMax = cx + nx * dx / 2.0; // Extent.yMax = cy + ny * dy / 2.0; } break; } //----------------------------------------------------- CSG_Shapes *pGraticule = Parameters("TYPE")->asInt() == 0 ? Parameters("GRATICULE_LINE")->asShapes() : Parameters("GRATICULE_RECT")->asShapes(); int x, y; TSG_Point p; switch( Parameters("TYPE")->asInt() ) { //----------------------------------------------------- case 0: // Lines { pGraticule->Create(SHAPE_TYPE_Line, _TL("Graticule")); pGraticule->Add_Field("ID", SG_DATATYPE_Int); for(x=0, p.x=Extent.xMin; x<=nx; x++, p.x+=dx) { CSG_Shape *pLine = pGraticule->Add_Shape(); pLine->Set_Value(0, pGraticule->Get_Count()); for(y=0, p.y=Extent.yMin; y<=ny; y++, p.y+=dy) { pLine->Add_Point(p.x, p.y); } } for(y=0, p.y=Extent.yMin; y<=ny; y++, p.y+=dy) { CSG_Shape *pLine = pGraticule->Add_Shape(); pLine->Set_Value(0, pGraticule->Get_Count()); for(x=0, p.x=Extent.xMin; x<=nx; x++, p.x+=dx) { pLine->Add_Point(p.x, p.y); } } } break; //----------------------------------------------------- case 1: // Rectangles { pGraticule->Create(SHAPE_TYPE_Polygon, _TL("Graticule")); pGraticule->Add_Field("ID" , SG_DATATYPE_Int); pGraticule->Add_Field("ROW", SG_DATATYPE_Int); pGraticule->Add_Field("COL", SG_DATATYPE_Int); for(y=0, p.y=Extent.yMin; yAdd_Shape(); pRect->Set_Value(0, pGraticule->Get_Count()); pRect->Set_Value(1, 1 + y); pRect->Set_Value(2, 1 + x); pRect->Add_Point(p.x , p.y ); pRect->Add_Point(p.x , p.y + dy); pRect->Add_Point(p.x + dx, p.y + dy); pRect->Add_Point(p.x + dx, p.y ); pRect->Add_Point(p.x , p.y ); } } } break; //----------------------------------------------------- } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/shapes_extents.h0000664000175000017500000001024312565125410025223 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_extents.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Extents.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Extents_H #define HEADER_INCLUDED__Shapes_Extents_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Extents : public CSG_Module { public: CShapes_Extents(void); virtual ~CShapes_Extents(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Extents_H saga-2.2.3/src/modules/shapes/shapes_tools/shapes_split.h0000664000175000017500000001024412565125410024665 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_split.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Split.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Split_H #define HEADER_INCLUDED__Shapes_Split_H //--------------------------------------------------------- #include "shapes_cut.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Split : public CSG_Module { public: CShapes_Split(void); virtual ~CShapes_Split(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Split_H saga-2.2.3/src/modules/shapes/shapes_tools/shapes_split_randomly.h0000664000175000017500000001042712605526014026575 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_split_randomly.h 2642 2015-10-08 11:57:54Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Split_Randomly.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Split_Randomly_H #define HEADER_INCLUDED__Shapes_Split_Randomly_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Split_Randomly : public CSG_Module { public: CShapes_Split_Randomly(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual bool On_Execute (void); private: void Split (CSG_Shapes *pShapes, CSG_Shapes *pSplit[2], double Percent); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Split_Randomly_H saga-2.2.3/src/modules/shapes/shapes_tools/shapes_cut.cpp0000664000175000017500000003650112565125410024664 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_cut.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Cut.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "shapes_cut.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool Cut_Shapes(CSG_Shapes *pPolygons, int Method, CSG_Shapes *pShapes, CSG_Shapes *pCut) { if( pCut && pShapes && pShapes->is_Valid() && pPolygons && pPolygons->is_Valid() && pPolygons->Get_Extent().Intersects(pShapes->Get_Extent()) ) { pCut->Create( pShapes->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Cut")), pShapes ); for(int iShape=0; iShapeGet_Count() && SG_UI_Process_Set_Progress(iShape, pShapes->Get_Count()); iShape++) { bool bAdd; CSG_Shape *pShape = pShapes->Get_Shape(iShape); if( Method == 2 ) // center { bAdd = false; TSG_Point Center; if( pShapes->Get_Type() == SHAPE_TYPE_Polygon ) Center = ((CSG_Shape_Polygon *)pShape)->Get_Centroid(); else Center = pShape->Get_Extent().Get_Center(); if( pPolygons->Select(Center) ) { bAdd = true; } } else if( Method == 1 ) // intersects { bAdd = false; for(int iPart=0; iPartGet_Part_Count() && !bAdd; iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart) && !bAdd; iPoint++) { if( pPolygons->Select(pShape->Get_Point(iPoint, iPart)) ) { bAdd = true; } } } } else // completely contained { bAdd = true; for(int iPart=0; iPartGet_Part_Count() && bAdd; iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart) && bAdd; iPoint++) { if( pPolygons->Select(pShape->Get_Point(iPoint, iPart)) == false ) { bAdd = false; } } } } if( bAdd ) { pCut->Add_Shape(pShape); } } return( pCut->Get_Count() > 0 ); } return( false ); } //--------------------------------------------------------- bool Cut_Shapes(CSG_Rect Extent, int Method, CSG_Shapes *pShapes, CSG_Shapes *pCut) { if( pCut && pShapes && pShapes->is_Valid() && Extent.Intersects(pShapes->Get_Extent()) ) { pCut->Create( pShapes->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Cut")), pShapes ); for(int iShape=0; iShapeGet_Count() && SG_UI_Process_Set_Progress(iShape, pShapes->Get_Count()); iShape++) { bool bAdd; CSG_Shape *pShape = pShapes->Get_Shape(iShape); if( Method == 2 ) // center { bAdd = pShapes->Get_Type() == SHAPE_TYPE_Polygon ? Extent.Contains(((CSG_Shape_Polygon *)pShape)->Get_Centroid()) : Extent.Contains(pShape->Get_Extent().Get_Center()); } else // completely contained, intersects { switch( pShape->Intersects(Extent) ) { case INTERSECTION_Identical: case INTERSECTION_Contained: bAdd = true; break; case INTERSECTION_Overlaps: case INTERSECTION_Contains: bAdd = Method == 1; break; default: bAdd = false; break; } } if( bAdd ) { pCut->Add_Shape(pShape); } } return( pCut->Get_Count() > 0 ); } return( false ); } //--------------------------------------------------------- CSG_Shapes * Cut_Shapes(CSG_Shapes *pPolygons, int Method, CSG_Shapes *pShapes) { CSG_Shapes *pCut = SG_Create_Shapes(); if( Cut_Shapes(pPolygons, Method, pShapes, pCut) ) { return( pCut ); } delete(pCut); return( NULL ); } CSG_Shapes * Cut_Shapes(CSG_Rect Extent, int Method, CSG_Shapes *pShapes) { CSG_Shapes *pCut = SG_Create_Shapes(); if( Cut_Shapes(Extent, Method, pShapes, pCut) ) { return( pCut ); } delete(pCut); return( NULL ); } //--------------------------------------------------------- CSG_String Cut_Methods_Str(void) { return( CSG_String::Format(SG_T("%s|%s|%s|"), _TL("completely contained"), _TL("intersects"), _TL("center")) ); } //--------------------------------------------------------- bool Cut_Set_Extent(CSG_Rect Extent, CSG_Shapes *pExtent, bool bClear) { if( pExtent ) { if( bClear ) { pExtent->Create(SHAPE_TYPE_Polygon, _TL("Extent [Cut]")); pExtent->Add_Field("ID", SG_DATATYPE_Int); } if( pExtent->Get_Type() == SHAPE_TYPE_Polygon ) { CSG_Shape *pShape = pExtent->Add_Shape(); pShape->Set_Value(SG_T("ID"), pExtent->Get_Count()); pShape->Add_Point(Extent.Get_XMin(), Extent.Get_YMin()); pShape->Add_Point(Extent.Get_XMin(), Extent.Get_YMax()); pShape->Add_Point(Extent.Get_XMax(), Extent.Get_YMax()); pShape->Add_Point(Extent.Get_XMax(), Extent.Get_YMin()); pShape->Add_Point(Extent.Get_XMin(), Extent.Get_YMin()); return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Cut::CShapes_Cut(void) { Set_Name (_TL("Cut Shapes Layer")); Set_Author (SG_T("O. Conrad (c) 2006")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes_List( NULL , "CUT" , _TL("Cut"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), Cut_Methods_Str(), 0 ); Parameters.Add_Choice( NULL , "TARGET" , _TL("Extent"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("user defined"), _TL("grid project"), _TL("shapes layer extent"), _TL("polygons") ), 0 ); //----------------------------------------------------- CSG_Parameters *pParameters; pParameters = Add_Parameters("CUT", _TL("Extent"), _TL("")); pParameters->Add_Value( NULL, "AX" , _TL("Left") , _TL(""), PARAMETER_TYPE_Double ); pParameters->Add_Value( NULL, "BX" , _TL("Right") , _TL(""), PARAMETER_TYPE_Double ); pParameters->Add_Value( NULL, "AY" , _TL("Bottom") , _TL(""), PARAMETER_TYPE_Double ); pParameters->Add_Value( NULL, "BY" , _TL("Top") , _TL(""), PARAMETER_TYPE_Double ); pParameters->Add_Value( NULL, "DX" , _TL("Horizontal Range") , _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); pParameters->Add_Value( NULL, "DY" , _TL("Vertical Range") , _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); pParameters = Add_Parameters("GRID", _TL("Extent"), _TL("")); pParameters->Add_Grid_System( NULL, "GRID", _TL("Grid Project") , _TL("") ); pParameters = Add_Parameters("SHAPES", _TL("Extent"), _TL("")); pParameters->Add_Shapes( NULL, "SHAPES", _TL("Shapes") , _TL(""), PARAMETER_INPUT ); pParameters = Add_Parameters("POLYGONS", _TL("Polygons"), _TL("")); pParameters->Add_Shapes( NULL, "POLYGONS", _TL("Polygons") , _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Cut::On_Execute(void) { int Method; CSG_Shapes *pExtent, *pCut; CSG_Parameter_Shapes_List *pShapes, *pCuts; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapesList(); pCuts = Parameters("CUT") ->asShapesList(); pExtent = Parameters("EXTENT") ->asShapes(); Method = Parameters("METHOD") ->asInt(); //----------------------------------------------------- if( pShapes->Get_Count() > 0 ) { int iLayer; CSG_Rect r(pShapes->asShapes(0)->Get_Extent()); for(iLayer=1; iLayerGet_Count(); iLayer++) { r.Union(pShapes->asShapes(iLayer)->Get_Extent()); } if( Get_Extent(r) ) { pCuts->Del_Items(); Cut_Set_Extent(r, pExtent, true); for(iLayer=0; iLayerGet_Count(); iLayer++) { if( m_pPolygons ) { if( Cut_Shapes(m_pPolygons, Method, pShapes->asShapes(iLayer), pCut = SG_Create_Shapes()) ) pCuts->Add_Item(pCut); else delete(pCut); } else { if( Cut_Shapes(r, Method, pShapes->asShapes(iLayer), pCut = SG_Create_Shapes()) ) pCuts->Add_Item(pCut); else delete(pCut); } } return( pCuts->Get_Count() > 0 ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Cut::Get_Extent(CSG_Rect &r) { m_pPolygons = NULL; switch( Parameters("TARGET")->asInt() ) { //----------------------------------------------------- case 0: // user defined Get_Parameters("CUT")->Get_Parameter("AX")->Set_Value(r.Get_XMin()); Get_Parameters("CUT")->Get_Parameter("AY")->Set_Value(r.Get_YMin()); Get_Parameters("CUT")->Get_Parameter("BX")->Set_Value(r.Get_XMax()); Get_Parameters("CUT")->Get_Parameter("BY")->Set_Value(r.Get_YMax()); Get_Parameters("CUT")->Get_Parameter("DX")->Set_Value(r.Get_XRange()); Get_Parameters("CUT")->Get_Parameter("DY")->Set_Value(r.Get_YRange()); if( Dlg_Parameters("CUT") ) { r.Assign( Get_Parameters("CUT")->Get_Parameter("AX")->asDouble(), Get_Parameters("CUT")->Get_Parameter("AY")->asDouble(), Get_Parameters("CUT")->Get_Parameter("BX")->asDouble(), Get_Parameters("CUT")->Get_Parameter("BY")->asDouble() ); return( true ); } break; //----------------------------------------------------- case 1: // grid project if( Dlg_Parameters("GRID") ) { r.Assign(Get_Parameters("GRID")->Get_Parameter("GRID")->asGrid_System()->Get_Extent()); return( true ); } break; //----------------------------------------------------- case 2: // shapes extent if( Dlg_Parameters("SHAPES") ) { r.Assign(Get_Parameters("SHAPES")->Get_Parameter("SHAPES")->asShapes()->Get_Extent()); return( true ); } break; //----------------------------------------------------- case 3: // polygons if( Dlg_Parameters("POLYGONS") ) { r.Assign(Get_Parameters("POLYGONS")->Get_Parameter("POLYGONS")->asShapes()->Get_Extent()); m_pPolygons = Get_Parameters("POLYGONS")->Get_Parameter("POLYGONS")->asShapes(); return( true ); } break; } return( false ); } //--------------------------------------------------------- int CShapes_Cut::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameters->Get_Identifier(), SG_T("CUT")) ) { double ax, ay, bx, by, dx, dy, d; ax = pParameters->Get_Parameter("AX")->asDouble(); ay = pParameters->Get_Parameter("AY")->asDouble(); bx = pParameters->Get_Parameter("BX")->asDouble(); by = pParameters->Get_Parameter("BY")->asDouble(); dx = pParameters->Get_Parameter("DX")->asDouble(); dy = pParameters->Get_Parameter("DY")->asDouble(); if( ax > bx ) { d = ax; ax = bx; bx = d; } if( ay > by ) { d = ay; ay = by; by = d; } if ( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("DX")) ) { bx = ax + dx; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("AX")) || !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("BX")) ) { dx = bx - ax; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("DY")) ) { by = ay + dy; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("AY")) || !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("BY")) ) { dy = by - ay; } pParameters->Get_Parameter("AX")->Set_Value(ax); pParameters->Get_Parameter("AY")->Set_Value(ay); pParameters->Get_Parameter("BX")->Set_Value(bx); pParameters->Get_Parameter("BY")->Set_Value(by); pParameters->Get_Parameter("DX")->Set_Value(dx); pParameters->Get_Parameter("DY")->Set_Value(dy); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/SearchInTable.cpp0000664000175000017500000001411212565125410025164 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SearchInTable.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* SearchInTable.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SearchInTable.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelect_String::CSelect_String(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Select by Attributes... (String Expression)")); Set_Author (SG_T("V.Olaya (c) 2004, O.Conrad (c) 2011")); Set_Description (_TW( "Searches for an character string expression in the attributes table and selects records where the expression is found." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("attribute to be searched; if not set all attributes will be searched"), true ); Parameters.Add_String( NULL , "EXPRESSION" , _TL("Expression"), _TL(""), SG_T("") ); Parameters.Add_Value( NULL , "CASE" , _TL("Case Sensitive"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( NULL , "COMPARE" , _TL("Select if..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("attribute is identical with search expression"), _TL("attribute contains search expression"), _TL("attribute is contained in search expression") ), 1 ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("new selection"), _TL("add to current selection"), _TL("select from current selection"), _TL("remove from current selection") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_String::On_Execute(void) { int Method; CSG_Shapes *pShapes; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); m_Field = Parameters("FIELD") ->asInt(); m_Expression = Parameters("EXPRESSION") ->asString(); m_Case = Parameters("CASE") ->asBool(); m_Compare = Parameters("COMPARE") ->asInt(); Method = Parameters("METHOD") ->asInt(); //----------------------------------------------------- if( m_Case == false ) { m_Expression.Make_Upper(); } //----------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { CSG_Shape *pShape = pShapes->Get_Shape(i); switch( Method ) { case 0: // New selection if( ( pShape->is_Selected() && !Do_Select(pShape)) || (!pShape->is_Selected() && Do_Select(pShape)) ) { pShapes->Select(i, true); } break; case 1: // Add to current selection if( !pShape->is_Selected() && Do_Select(pShape) ) { pShapes->Select(i, true); } break; case 2: // Select from current selection if( pShape->is_Selected() && !Do_Select(pShape) ) { pShapes->Select(i, true); } break; case 3: // Remove from current selection if( pShape->is_Selected() && Do_Select(pShape) ) { pShapes->Select(i, true); } break; } } //----------------------------------------------------- Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("selected shapes"), pShapes->Get_Selection_Count())); DataObject_Update(pShapes); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CSelect_String::Do_Compare(const SG_Char *Value) { CSG_String s(Value); if( m_Case == false ) { s.Make_Upper(); } switch( m_Compare ) { case 0: // identical return( m_Expression.Cmp(s) == 0 ); case 1: // contains return( s.Find(m_Expression) >= 0 ); case 2: // contained return( m_Expression.Find(s) >= 0 ); } return( false ); } //--------------------------------------------------------- inline bool CSelect_String::Do_Select(CSG_Shape *pShape) { if( m_Field >= 0 && m_Field < pShape->Get_Table()->Get_Field_Count() ) { return( Do_Compare(pShape->asString(m_Field)) ); } for(int i=0; iGet_Table()->Get_Field_Count(); i++) { if( Do_Compare(pShape->asString(i)) ) { return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/SearchInTable.h0000664000175000017500000000435112565125410024635 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SearchInTable.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* SearchInTable.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelect_String : public CSG_Module { public: CSelect_String(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); private: bool m_Case; int m_Field, m_Compare; CSG_String m_Expression; bool Do_Compare (const SG_Char *Value); bool Do_Select (CSG_Shape *pShape); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/CreateChartLayer.cpp0000664000175000017500000002242512565125410025710 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CreateChartLayer.cpp 2447 2015-03-19 14:43:42Z oconrad $ *********************************************************/ /******************************************************************************* CCreateChartLayer.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "CreateChartLayer.h" #include #define TYPE_PIE 0 #define TYPE_BARS 0 #define PI2 6.283185 CCreateChartLayer::CCreateChartLayer(void){ CSG_Parameter *pNode; Parameters.Set_Name(_TL("Create Chart Layer (bars/sectors)")); Parameters.Set_Description(_TW( "(c) 2004 by Victor Olaya. ")); pNode = Parameters.Add_Shapes(NULL, "INPUT", _TL("Shapes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Table_Field(pNode, "SIZE", _TL("Size field"), _TL("")); Parameters.Add_Value(NULL, "MAXSIZE", _TL("Maximum size"), _TL(""), PARAMETER_TYPE_Double, 100, 0, true); Parameters.Add_Value(NULL, "MINSIZE", _TL("Minimum size"), _TL(""), PARAMETER_TYPE_Double, 10, 0, true); Parameters.Add_Choice(NULL, "TYPE", _TL("Type"), _TL(""), _TW("Sectors|" "Bars|"), 0); m_pExtraParameters = Add_Parameters("EXTRA", _TL("Fields for diagram"), _TL("")); }//constructor CCreateChartLayer::~CCreateChartLayer(void) {} bool CCreateChartLayer::On_Execute(void){ CSG_Shapes *pInput; int i=0; int iType; int iSizeField; if (GetExtraParameters()){ iSizeField = Parameters("SIZE")->asInt(); m_fMaxSize = (double) Parameters("MAXSIZE")->asDouble(); m_fMinSize = (double) Parameters("MINSIZE")->asDouble(); if (m_fMinSize > m_fMaxSize){ m_fMinSize = m_fMaxSize; }//if iType = Parameters("TYPE")->asInt(); pInput = Parameters("INPUT")->asShapes(); m_fMaxValue = pInput->Get_Maximum(iSizeField); m_fMinValue = pInput->Get_Minimum(iSizeField); if (iType == TYPE_PIE){ m_pOutput = SG_Create_Shapes(SHAPE_TYPE_Polygon, _TL("Chart (sectors):")); }//if else{ m_pOutput = SG_Create_Shapes(SHAPE_TYPE_Polygon, _TL("Chart (bars):")); }//else m_pOutput->Add_Field(_TL("Field (ID)"), SG_DATATYPE_Int); m_pOutput->Add_Field(_TL("Field (Name)"), SG_DATATYPE_String); for (i = 0; i < pInput->Get_Count(); i++){ if (iType == TYPE_PIE){ // AddPieChart(pInput->Get_Shape(i),m_pOutput->Get_Type()); AddPieChart(pInput->Get_Shape(i),pInput->Get_Type()); }//if else{ // AddBarChart(pInput->Get_Shape(i),m_pOutput->Get_Type()); AddBarChart(pInput->Get_Shape(i),pInput->Get_Type()); }//else }//for DataObject_Add(m_pOutput, false); delete [] m_bIncludeParam; return true; }//if delete [] m_bIncludeParam; return false; }//method bool CCreateChartLayer::GetExtraParameters(){ int i; CSG_Shapes *pInput; CSG_Parameter *pParam; CSG_String sName; bool bIsValidSelection = false; pInput = Parameters("INPUT")->asShapes(); 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 < 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(); bIsValidSelection = true; }//try else{ m_bIncludeParam[i] = false; }//else }//for m_pExtraParameters->Destroy(); return bIsValidSelection; }//if m_pExtraParameters->Destroy(); return false; }//method void CCreateChartLayer::AddPieChart(CSG_Shape* pShape, int iType){ int i,j; int iSteps; int iSizeField; int iField; double fSum = 0; double fPartialSum = 0; double fSize; double fSectorSize; double dX, dY; CSG_Shape *pSector; CSG_Table_Record *pRecord; TSG_Point Point; iSizeField = Parameters("SIZE")->asInt(); pRecord = pShape; for (i = 0; i < pRecord->Get_Table()->Get_Field_Count(); i++){ if (m_bIncludeParam[i]){ fSum += pRecord->asFloat(i); }//if }//for fSize = pRecord->asFloat(iSizeField); fSize = m_fMinSize + (m_fMaxSize - m_fMinSize)/(m_fMaxValue - m_fMinValue) * (fSize - m_fMinValue); switch (iType){ case SHAPE_TYPE_Polygon: Point = ((CSG_Shape_Polygon*) pShape)->Get_Centroid(); break; case SHAPE_TYPE_Line: Point = GetLineMidPoint((CSG_Shape_Line*)pShape); break; case SHAPE_TYPE_Point: Point = pShape->Get_Point(0); break; default: break; }//switch dX = Point.x; dY = Point.y; fPartialSum = 0; iField = 1; for (i = 0; i < pRecord->Get_Table()->Get_Field_Count(); i++){ if (m_bIncludeParam[i]){ fSectorSize = pRecord->asFloat(i) / fSum; pSector = m_pOutput->Add_Shape(); pSector->Add_Point(dX,dY); iSteps = (int) (fSectorSize * 200.); for (j = 0; j < iSteps; j++){ pSector->Add_Point(dX + fSize * sin((fPartialSum + (double)j / 200.) * PI2), dY + fSize * cos((fPartialSum + (double)j / 200.) * PI2)); }//for fPartialSum +=fSectorSize; pSector->Add_Point(dX + fSize * sin(fPartialSum * PI2), dY + fSize * cos(fPartialSum * PI2)); pSector->Set_Value(0,iField); pSector->Set_Value(1,pRecord->Get_Table()->Get_Field_Name(i)); iField++; }//if }//for }//method void CCreateChartLayer::AddBarChart(CSG_Shape* pShape, int iType){ int i; int iSizeField; int iField; int iValidFields = 0; double fMax; double fMin; double fSize; double fBarHeight, fBarWidth; double dX, dY; CSG_Shape *pSector; CSG_Table_Record *pRecord; TSG_Point Point; iSizeField = Parameters("SIZE")->asInt(); pRecord = pShape; pRecord = pShape; for (i = 0; i < pRecord->Get_Table()->Get_Field_Count(); i++){ if (m_bIncludeParam[i]){ if (!iValidFields){ fMin = fMax = pRecord->asFloat(i); } else{ if (pRecord->asFloat(i) > fMax){ fMax = pRecord->asFloat(i); }//if if (pRecord->asFloat(i) < fMin){ fMin = pRecord->asFloat(i); }//if }//else iValidFields++; }//if }//for if (fMax > 0 && fMin > 0){ fMin = 0; }//if if (fMax < 0 && fMin < 0){ fMax = 0; }//if fSize = pRecord->asFloat(iSizeField); fSize = m_fMinSize + (m_fMaxSize - m_fMinSize)/(m_fMaxValue - m_fMinValue) * (fSize - m_fMinValue); switch (iType){ case SHAPE_TYPE_Polygon: Point = ((CSG_Shape_Polygon*) pShape)->Get_Centroid(); break; case SHAPE_TYPE_Line: Point = GetLineMidPoint((CSG_Shape_Line*)pShape); break; case SHAPE_TYPE_Point: Point = pShape->Get_Point(0); break; default: break; }//switch dX = Point.x; dY = Point.y; fBarWidth = fSize / (double)iValidFields; iField = 1; for (i = 0; i < pRecord->Get_Table()->Get_Field_Count(); i++){ if (m_bIncludeParam[i]){ fBarHeight = pRecord->asFloat(i) / (fMax - fMin) * fSize; pSector = m_pOutput->Add_Shape(); pSector->Add_Point(dX - fSize / 2. + fBarWidth * (iField - 1) , dY); pSector->Add_Point(dX - fSize / 2. + fBarWidth * iField, dY); pSector->Add_Point(dX - fSize / 2. + fBarWidth * iField, dY + fBarHeight); pSector->Add_Point(dX - fSize / 2. + fBarWidth * (iField - 1) , dY + fBarHeight); pSector->Set_Value(0,iField); pSector->Set_Value(1,pRecord->Get_Table()->Get_Field_Name(i)); iField++; }//if }//for }//method TSG_Point CCreateChartLayer::GetLineMidPoint(CSG_Shape_Line *pLine){ int i; double fDist, fAccDist = 0; double fLength = pLine->Get_Length(0) / 2.; TSG_Point Point, Point2, ReturnPoint; for (i = 0; i < pLine->Get_Point_Count(0) - 1; i++){ Point = pLine->Get_Point(i); Point2 = pLine->Get_Point(i+1); fDist = sqrt(pow(Point.x - Point2.x,2.) + pow(Point.y - Point2.y,2.)); if (fAccDist <= fLength && fAccDist + fDist > fLength){ ReturnPoint.x = Point.x + (Point2.x - Point.x) * (fLength - fAccDist) / fDist; ReturnPoint.y = Point.y + (Point2.y - Point.y) * (fLength - fAccDist) / fDist; return ReturnPoint; }//if fAccDist += fDist; }//for return pLine->Get_Point(pLine->Get_Point_Count(0) / 2); }//method saga-2.2.3/src/modules/shapes/shapes_tools/shapes_polar_to_cartes.cpp0000664000175000017500000001613112565125410027246 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_polar_to_cartes.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_polar_to_cartes.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_polar_to_cartes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Polar_to_Cartes::CShapes_Polar_to_Cartes(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Polar to Cartesian Coordinates")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- // 2. Parameters... pNode = Parameters.Add_Shapes( NULL , "POLAR" , _TL("Polar Coordinates"), _TL(""), PARAMETER_INPUT ); pNode = Parameters.Add_Table_Field( pNode , "F_EXAGG" , _TL("Exaggeration"), _TL(""), true ); Parameters.Add_Value( pNode , "D_EXAGG" , _TL("Exaggeration Factor"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Shapes( NULL , "CARTES" , _TL("Cartesion Coordinates"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Radius"), _TL(""), PARAMETER_TYPE_Double, 6371000.0, 0.0, true ); Parameters.Add_Value( NULL , "DEGREE" , _TL("Degree"), _TL("polar coordinates given in degree"), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Polar_to_Cartes::On_Execute(void) { bool bDegree; int fExagg; double Radius, dExagg, Exagg = 0.0; CSG_Shapes *pPolar, *pCartes; //----------------------------------------------------- pPolar = Parameters("POLAR") ->asShapes(); pCartes = Parameters("CARTES") ->asShapes(); Radius = Parameters("RADIUS") ->asDouble(); bDegree = Parameters("DEGREE") ->asBool(); fExagg = Parameters("F_EXAGG") ->asInt(); dExagg = Parameters("D_EXAGG") ->asDouble(); //----------------------------------------------------- if( !pPolar->is_Valid() ) { Error_Set(_TL("invalid input")); return( false ); } //----------------------------------------------------- pCartes->Create(pPolar->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pPolar->Get_Name(), _TL("cartesian")), pPolar, SG_VERTEX_TYPE_XYZ); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pPolar->Get_Count()); iShape++) { CSG_Shape *pShape = pPolar->Get_Shape(iShape); CSG_Shape *pTarget = pCartes->Add_Shape(pShape, SHAPE_COPY_ATTR); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point_Z Point = Get_Cartes(pShape->Get_Point(iPoint, iPart), fExagg < 0 ? Radius : Radius + dExagg * pShape->asDouble(fExagg), bDegree); pTarget->Add_Point(Point.x, Point.y, iPart); pTarget->Set_Z (Point.z, iPoint , iPart); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline TSG_Point_Z CShapes_Polar_to_Cartes::Get_Cartes(TSG_Point Point, double Radius, bool bDegree) { if( bDegree ) { Point.x *= M_DEG_TO_RAD; Point.y *= M_DEG_TO_RAD; } TSG_Point_Z p; p.z = Radius * sin(Point.y); Radius = Radius * cos(Point.y); p.x = Radius * cos(Point.x); p.y = Radius * sin(Point.x); return( p ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/shapes_split.cpp0000664000175000017500000001435312565125410025225 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_split.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Split.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_split.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Split::CShapes_Split(void) { Set_Name (_TL("Split Shapes Layer")); Set_Author (SG_T("(c) 2006 by O.Conrad")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes_List( NULL , "CUTS" , _TL("Tiles"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "NX" , _TL("Number of horizontal tiles"), _TL(""), PARAMETER_TYPE_Int, 2, 1, true ); Parameters.Add_Value( NULL , "NY" , _TL("Number of vertical tiles"), _TL(""), PARAMETER_TYPE_Int, 2, 1, true ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), Cut_Methods_Str(), 0 ); } //--------------------------------------------------------- CShapes_Split::~CShapes_Split(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Split::On_Execute(void) { int x, y, nx, ny, Method; CSG_Shapes *pShapes, *pCut, *pExtent; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); pExtent = Parameters("EXTENT") ->asShapes(); nx = Parameters("NX") ->asInt(); ny = Parameters("NY") ->asInt(); Method = Parameters("METHOD") ->asInt(); Parameters("CUTS")->asShapesList()->Del_Items(); //----------------------------------------------------- if( pShapes->is_Valid() ) { double dx, dy; TSG_Rect r; dx = pShapes->Get_Extent().Get_XRange() / nx; dy = pShapes->Get_Extent().Get_YRange() / ny; for(y=0; yGet_Extent().Get_YMin() + y * dy; r.yMax = r.yMin + dy; for(x=0; xGet_Extent().Get_XMin() + x * dx; r.xMax = r.xMin + dx; Cut_Set_Extent(r, pExtent, y == 0 && x == 0); Process_Set_Text(CSG_String::Format(SG_T("%d/%d"), y * nx + (x + 1), nx * ny)); if( (pCut = Cut_Shapes(r, Method, pShapes)) != NULL ) { pCut->Set_Name(CSG_String::Format(SG_T("%s [%d][%d]"), pShapes->Get_Name(), 1 + x, 1 + y)); Parameters("CUTS")->asShapesList()->Add_Item(pCut); } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/shapes_polar_to_cartes.h0000664000175000017500000001074212565125410026715 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_polar_to_cartes.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_polar_to_cartes.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__shapes_polar_to_cartes__H #define HEADER_INCLUDED__shapes_polar_to_cartes__H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Polar_to_Cartes : public CSG_Module { public: CShapes_Polar_to_Cartes(void); protected: virtual bool On_Execute (void); private: TSG_Point_Z Get_Cartes (TSG_Point Point, double Radius, bool bDegree); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_polar_to_cartes__H saga-2.2.3/src/modules/shapes/shapes_tools/QueryBuilder.h0000664000175000017500000000407312565125410024606 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: QueryBuilder.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* QueryBuilder.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelect_Numeric : public CSG_Module { public: CSelect_Numeric(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/SeparateShapes.h0000664000175000017500000000406412565125410025102 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SeparateShapes.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* SeparateShapes.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSeparateShapes : public CSG_Module { public: CSeparateShapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/shapes_convert_vertex_type.h0000664000175000017500000001105312565125410027647 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_convert_vertex_type.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_convert_vertex_type.h // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Convert_Vertex_Type_H #define HEADER_INCLUDED__Shapes_Convert_Vertex_Type_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Convert_Vertex_Type : public CSG_Module { public: CShapes_Convert_Vertex_Type(void); virtual ~CShapes_Convert_Vertex_Type(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Convert_Vertex_Type_H saga-2.2.3/src/modules/shapes/shapes_tools/SelectByTheme.cpp0000664000175000017500000001541212565125410025221 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SelectByTheme.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* SelectByTheme.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SelectByTheme.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelect_Location::CSelect_Location(void) { //----------------------------------------------------- Set_Name (_TL("Select by Location...")); Set_Author (SG_T("V.Olaya (c) 2004, O.Conrad (c) 2011")); Set_Description (_TW( "Select by location." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes to Select From"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "LOCATIONS" , _TL("Locations"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Choice( NULL , "CONDITION" , _TL("Condition"), _TL("Select shapes that fulfil this condition"), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("intersect"), _TL("are completely within"), _TL("completely contain"), _TL("have their centroid in"), _TL("contain the centeroid of") ), 0 ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("new selection"), _TL("add to current selection"), _TL("select from current selection"), _TL("remove from current selection") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_Location::On_Execute(void) { int Method, Condition; m_pShapes = Parameters("SHAPES") ->asShapes(); m_pLocations = Parameters("LOCATIONS") ->asShapes(); Condition = Parameters("CONDITION") ->asInt(); Method = Parameters("METHOD") ->asInt(); //----------------------------------------------------- switch( Condition ) { case 0: // intersect if( ((m_pShapes ->Get_Type() == SHAPE_TYPE_Point || m_pShapes ->Get_Type() == SHAPE_TYPE_Points) && m_pLocations->Get_Type() != SHAPE_TYPE_Polygon) || ((m_pLocations->Get_Type() == SHAPE_TYPE_Point || m_pLocations->Get_Type() == SHAPE_TYPE_Points) && m_pShapes ->Get_Type() != SHAPE_TYPE_Polygon) ) { Error_Set(_TL("points can only intersect with polygons")); return( false ); } break; case 1: // are completely within case 3: // have their centroid in if( m_pLocations->Get_Type() != SHAPE_TYPE_Polygon ) { Error_Set(_TL("this operation requires locations to be of type polygon")); return( false ); } break; case 2: // completely contain case 4: // contain the centroid of if( m_pShapes->Get_Type() != SHAPE_TYPE_Polygon ) { Error_Set(_TL("this operation requires selectable shapes to be of type polygon")); return( false ); } break; } //----------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, m_pShapes->Get_Count()); i++) { CSG_Shape *pShape = m_pShapes->Get_Shape(i); switch( Method ) { case 0: // New selection if( ( pShape->is_Selected() && !Do_Select(pShape, Condition)) || (!pShape->is_Selected() && Do_Select(pShape, Condition)) ) { m_pShapes->Select(i, true); } break; case 1: // Add to current selection if( !pShape->is_Selected() && Do_Select(pShape, Condition) ) { m_pShapes->Select(i, true); } break; case 2: // Select from current selection if( pShape->is_Selected() && !Do_Select(pShape, Condition) ) { m_pShapes->Select(i, true); } break; case 3: // Remove from current selection if( pShape->is_Selected() && Do_Select(pShape, Condition) ) { m_pShapes->Select(i, true); } break; } } //----------------------------------------------------- Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("selected shapes"), m_pShapes->Get_Selection_Count())); DataObject_Update(m_pShapes); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_Location::Do_Select(CSG_Shape *pShape, int Condition) { for(int i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Shape *pLocation = m_pLocations->Get_Shape(i); if( pShape->Intersects(pLocation->Get_Extent()) ) { switch( Condition ) { case 0: // intersect if( pLocation->Intersects(pShape) ) { return( true ); } break; case 1: // are completely within if( pLocation->Intersects(pShape) == INTERSECTION_Contains ) { return( true ); } break; case 2: // completely contain if( pShape->Intersects(pLocation) == INTERSECTION_Contains ) { return( true ); } break; case 3: // have their centroid in if( ((CSG_Shape_Polygon *)pLocation)->Contains(pShape->Get_Centroid()) ) { return( true ); } break; case 4: // contain the centroid of if( ((CSG_Shape_Polygon *)pShape)->Contains(pLocation->Get_Centroid()) ) { return( true ); } break; } } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/Makefile.in0000664000175000017500000006246312622651171024077 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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_tools DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_tools_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_tools_la_OBJECTS = CreateChartLayer.lo \ GraticuleBuilder.lo LandUse_Scenario.lo MLB_Interface.lo \ NewLayerFromSelectedShapes.lo quadtree_structure.lo \ QueryBuilder.lo SearchInTable.lo SelectByTheme.lo \ SeparateShapes.lo Shapes_Create_Empty.lo Shapes_Merge.lo \ TransformShapes.lo shapes_buffer.lo \ shapes_convert_vertex_type.lo shapes_cut.lo \ shapes_cut_interactive.lo shapes_extents.lo shapes_generate.lo \ shapes_polar_to_cartes.lo shapes_split.lo \ shapes_split_by_attribute.lo shapes_split_randomly.lo libshapes_tools_la_OBJECTS = $(am_libshapes_tools_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_tools_la_SOURCES) DIST_SOURCES = $(libshapes_tools_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 2417 2015-02-19 15:14:52Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_tools.la libshapes_tools_la_SOURCES = \ CreateChartLayer.cpp\ GraticuleBuilder.cpp\ LandUse_Scenario.cpp\ MLB_Interface.cpp\ NewLayerFromSelectedShapes.cpp\ quadtree_structure.cpp\ QueryBuilder.cpp\ SearchInTable.cpp\ SelectByTheme.cpp\ SeparateShapes.cpp\ Shapes_Create_Empty.cpp\ Shapes_Merge.cpp\ TransformShapes.cpp\ shapes_buffer.cpp\ shapes_convert_vertex_type.cpp\ shapes_cut.cpp\ shapes_cut_interactive.cpp\ shapes_extents.cpp\ shapes_generate.cpp\ shapes_polar_to_cartes.cpp\ shapes_split.cpp\ shapes_split_by_attribute.cpp\ shapes_split_randomly.cpp\ CreateChartLayer.h\ GraticuleBuilder.h\ LandUse_Scenario.h\ MLB_Interface.h\ NewLayerFromSelectedShapes.h\ quadtree_structure.h\ QueryBuilder.h\ SearchInTable.h\ SelectByTheme.h\ SeparateShapes.h\ Shapes_Create_Empty.h\ Shapes_Merge.h\ TransformShapes.h\ shapes_buffer.h\ shapes_convert_vertex_type.h\ shapes_cut.h\ shapes_cut_interactive.h\ shapes_extents.h\ shapes_generate.h\ shapes_polar_to_cartes.h\ shapes_split.h\ shapes_split_by_attribute.h\ shapes_split_randomly.h libshapes_tools_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) --foreign src/modules/shapes/shapes_tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_tools/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_tools.la: $(libshapes_tools_la_OBJECTS) $(libshapes_tools_la_DEPENDENCIES) $(EXTRA_libshapes_tools_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_tools_la_OBJECTS) $(libshapes_tools_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CreateChartLayer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GraticuleBuilder.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LandUse_Scenario.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NewLayerFromSelectedShapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QueryBuilder.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SearchInTable.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SelectByTheme.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SeparateShapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Shapes_Create_Empty.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Shapes_Merge.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TransformShapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quadtree_structure.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_buffer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_convert_vertex_type.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_cut.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_cut_interactive.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_extents.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_generate.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_polar_to_cartes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_split.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_split_by_attribute.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_split_randomly.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES #install-exec-hook: # pushd .; cd $(pkglibdir); ln -s libshapes_tools.so shapes_tools.so; popd # 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: saga-2.2.3/src/modules/shapes/shapes_tools/SeparateShapes.cpp0000664000175000017500000000716612565125410025443 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: SeparateShapes.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* SeparateShapes.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SeparateShapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSeparateShapes::CSeparateShapes(void) { CSG_Parameter *pNode; Set_Name (_TL("Split Shapes Layer Completely")); Set_Author (SG_T("Victor Olaya (c) 2005")); Set_Description (_TW( "Copies each shape of given layer to a separate target layer." )); pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("") ); Parameters.Add_Shapes_List( NULL , "LIST" , _TL("Output"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "NAMING" , _TL("Name by..."), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("number of order"), _TL("attribute") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSeparateShapes::On_Execute(void) { int Naming, Field; CSG_Shapes *pShapes; CSG_Parameter_Shapes_List *pList; pShapes = Parameters("SHAPES") ->asShapes(); pList = Parameters("LIST") ->asShapesList(); Naming = Parameters("NAMING") ->asInt(); Field = Parameters("FIELD") ->asInt(); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_String Name; switch( Naming ) { case 0: default: Name.Printf(SG_T("%s [%04d]"), pShapes->Get_Name(), iShape + 1); break; case 1: Name.Printf(SG_T("%s [%s]") , pShapes->Get_Name(), pShapes->Get_Record(iShape)->asString(Field)); break; } CSG_Shapes *pShape = SG_Create_Shapes(pShapes->Get_Type(), Name, pShapes); pList ->Add_Item(pShape); pShape ->Add_Shape(pShapes->Get_Shape(iShape)); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/shapes_generate.cpp0000664000175000017500000002525212565125410025664 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_generate.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_generate.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_generate.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Generate::CShapes_Generate(void) { Set_Name(_TL("Generate Shapes")); Set_Author(_TL("Volker Wichmann (c) 2012, LASERDATA GmbH")); Set_Description (_TW( "The module allows to generate point, line or polygon shapes from " "a table with x and y coordinates and an identifier. The table must " "be sorted in vertex order.\n\n" "The identifier has different meanings:\n\n" "* Point Shapes: The identifier is arbitrary\n\n" "* Line Shapes: The identifier is unique for each line\n\n" "* Polygon Shapes: The identifier is unique for each polygon; " "the first polygon vertex may but must not be duplicated in " "order to close the polygon\n\n") ); //----------------------------------------------------- Parameters.Add_Table( NULL , "INPUT" ,_TL("Input"), _TL("Table with coordinates."), PARAMETER_INPUT ); Parameters.Add_Table_Field( Parameters("INPUT"), "FIELD_ID", _TL("ID"), _TL("Field with identifier.") ); Parameters.Add_Table_Field( Parameters("INPUT"), "FIELD_X", _TL("X"), _TL("Field with x-coordinate.") ); Parameters.Add_Table_Field( Parameters("INPUT"), "FIELD_Y", _TL("Y"), _TL("Field with y-coordinate.") ); /*Parameters.Add_Table_Field( Parameters("INPUT"), "FIELD_Z", _TL("Z"), _TL("Field with z-coordinate."), true );*/ Parameters.Add_Choice( NULL , "SHAPE_TYPE" , _TL("Shape Type"), _TL("Shape type to generate."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Point(s)"), _TL("Line(s)"), _TL("Polygon(s)") ), 0 ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL("Generated Shapefile."), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CShapes_Generate::~CShapes_Generate(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Generate::On_Execute(void) { CSG_Table *pInput; CSG_Shapes *pOutput; int iFieldId, iFieldX, iFieldY; // iFieldZ int iShapeType; CSG_String sName; pInput = Parameters("INPUT")->asTable(); iFieldId = Parameters("FIELD_ID")->asInt(); iFieldX = Parameters("FIELD_X")->asInt(); iFieldY = Parameters("FIELD_Y")->asInt(); //iFieldZ = Parameters("FIELD_Z")->asInt(); iShapeType = Parameters("SHAPE_TYPE")->asInt(); pOutput = Parameters("OUTPUT")->asShapes(); if (pInput->Get_Count() < 1) { SG_UI_Msg_Add_Error(_TL("Input table is empty!")); return (false); } //----------------------------------------------------- // Initialize ... sName = CSG_String::Format(SG_T("Shapes_%s"), pInput->Get_Name()); pOutput->Destroy(); switch (iShapeType) { default: case 0: // point pOutput->Create(SHAPE_TYPE_Point, sName, (CSG_Table*)0, SG_VERTEX_TYPE_XY); break; case 1: // line pOutput->Create(SHAPE_TYPE_Line, sName, (CSG_Table*)0, SG_VERTEX_TYPE_XY); break; case 2: // polygon pOutput->Create(SHAPE_TYPE_Polygon, sName, (CSG_Table*)0, SG_VERTEX_TYPE_XY); break; } pOutput->Add_Field(SG_T("ID"), SG_DATATYPE_Int); //----------------------------------------------------- // Generate ... switch (iShapeType) { default: case 0: // point if (!Generate_Point_Shapes(pInput, pOutput, iFieldId, iFieldX, iFieldY)) return (false); break; case 1: // line if (!Generate_Line_Shapes(pInput, pOutput, iFieldId, iFieldX, iFieldY)) return (false); break; case 2: // polygon if (!Generate_Polygon_Shapes(pInput, pOutput, iFieldId, iFieldX, iFieldY)) return (false); break; } //----------------------------------------------------- return (true); } //--------------------------------------------------------- bool CShapes_Generate::Generate_Point_Shapes(CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY) { for (int i=0; iGet_Count() && Set_Progress(i, pInput->Get_Count()); i++) { CSG_Table_Record *pRecord = pInput->Get_Record(i); CSG_Shape *pShape = pOutput->Add_Shape(); pShape->Add_Point(pRecord->asDouble(iFieldX), pRecord->asDouble(iFieldY)); pShape->Set_Value(0, pRecord->asInt(iFieldId)); } return (true); } //--------------------------------------------------------- bool CShapes_Generate::Generate_Line_Shapes(CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY) { int iVertices = 0; int iID = pInput->Get_Record(0)->asInt(iFieldId); CSG_Shape *pShape = pOutput->Add_Shape(); pShape->Set_Value(0, iID); for (int i=0; iGet_Count() && Set_Progress(i, pInput->Get_Count()); i++) { CSG_Table_Record *pRecord = pInput->Get_Record(i); if (pRecord->asInt(iFieldId) != iID) { if (iVertices < 2) { pOutput->Del_Record(pOutput->Get_Record_Count() - 1); SG_UI_Msg_Add_Error(_TL("Line with less than 2 vertices encountered!")); return (false); } pShape = pOutput->Add_Shape(); iID = pRecord->asInt(iFieldId); pShape->Set_Value(0, iID); iVertices = 0; } pShape->Add_Point(pRecord->asDouble(iFieldX), pRecord->asDouble(iFieldY)); iVertices += 1; iID = pRecord->asInt(iFieldId); } if (iVertices < 2) { pOutput->Del_Record(pOutput->Get_Record_Count() - 1); SG_UI_Msg_Add_Error(_TL("Line with less than 2 vertices encountered!")); return (false); } return (true); } //--------------------------------------------------------- bool CShapes_Generate::Generate_Polygon_Shapes(CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY) { int iVertices = 0; int iID = pInput->Get_Record(0)->asInt(iFieldId); CSG_Shape *pShape = pOutput->Add_Shape(); pShape->Set_Value(0, iID); TSG_Point pointA; pointA.x = pInput->Get_Record(0)->asDouble(iFieldX); pointA.y = pInput->Get_Record(0)->asDouble(iFieldY); for (int i=0; iGet_Count() && Set_Progress(i, pInput->Get_Count()); i++) { CSG_Table_Record *pRecord = pInput->Get_Record(i); if (pRecord->asInt(iFieldId) != iID) { if (iVertices < 3) { pOutput->Del_Record(pOutput->Get_Record_Count() - 1); SG_UI_Msg_Add_Error(_TL("Polygon with less than 3 vertices encountered!")); return (false); } TSG_Point pointB; pointB.x = pInput->Get_Record(i-1)->asDouble(iFieldX); pointB.y = pInput->Get_Record(i-1)->asDouble(iFieldY); if (pointA.x != pointB.x || pointA.y != pointB.y) pShape->Add_Point(pointA); pShape = pOutput->Add_Shape(); iID = pRecord->asInt(iFieldId); pShape->Set_Value(0, iID); pointA.x = pInput->Get_Record(i)->asDouble(iFieldX); pointA.y = pInput->Get_Record(i)->asDouble(iFieldY); iVertices = 0; } pShape->Add_Point(pRecord->asDouble(iFieldX), pRecord->asDouble(iFieldY)); iVertices += 1; iID = pRecord->asInt(iFieldId); } if (iVertices < 3) { pOutput->Del_Record(pOutput->Get_Record_Count() - 1); SG_UI_Msg_Add_Error(_TL("Polygon with less than 3 vertices encountered!")); return (false); } return (true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/Shapes_Create_Empty.h0000664000175000017500000001072412565125410026056 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Create_Empty.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Create_Empty.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Create_Empty_H #define HEADER_INCLUDED__Shapes_Create_Empty_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Create_Empty : public CSG_Module { public: CShapes_Create_Empty(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: void _Set_Field_Count (CSG_Parameters *pAttributes, int nAttributes); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Create_Empty_H saga-2.2.3/src/modules/shapes/shapes_tools/Shapes_Merge.cpp0000664000175000017500000002043512565125410025067 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Merge.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* Shapes_Merge.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Shapes_Merge.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Merge::CShapes_Merge(void) : CTables_Merge() { Parameters.Del_Parameters(); Set_Name (_TL("Merge Layers")); Set_Author ("V.Olaya (c) 2004"); Set_Description (_TW( "Merge vector layers." )); Parameters.Add_Shapes_List( NULL , "INPUT" , _TL("Layers"), _TL("Output will inherit shape type and table structure from the first layer in this list."), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "MERGED" , _TL("Merged Layer"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "SRCINFO" , _TL("Add Source Information"), _TL("Adds a field with the name of the original input data set."), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "MATCH" , _TL("Match Fields by Name"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTables_Merge::CTables_Merge(void) { Set_Name (_TL("Merge Tables")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "Merge tables." )); Parameters.Add_Table_List( NULL , "INPUT" , _TL("Tables"), _TL("The resulting table inherits its field structure from the first table in this list."), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "MERGED" , _TL("Merged Table"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "SRCINFO" , _TL("Add Source Information"), _TL("Adds a field with the name of the original input data set."), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "MATCH" , _TL("Match Fields by Name"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTables_Merge::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_List *pList = Parameters("INPUT")->asList(); if( pList->Get_Type() == PARAMETER_TYPE_Shapes_List ) { int n = pList->Get_Count(); for(int i=n-1; i>0; i--) { if( ((CSG_Shapes *)pList->asDataObject(0))->Get_Type() != ((CSG_Shapes *)pList->asDataObject(i))->Get_Type() ) { pList->Del_Item(i); } } if( n > pList->Get_Count() ) { Message_Add(CSG_String::Format(SG_T("%s [%d]"), _TL("incompatible items have been removed from input list"), n - pList->Get_Count())); } } if( pList->Get_Count() < 2 ) { Error_Set(_TL("Nothing to do! Merging needs more than one input data set.")); return( false ); } //----------------------------------------------------- CSG_Table *pMerged = Parameters("MERGED")->asTable(); if( pList->Get_Type() == PARAMETER_TYPE_Shapes_List ) { CSG_Shapes *pShapesIn = ((CSG_Shapes *)pList->asDataObject(0)); ((CSG_Shapes *)pMerged)->Create(pShapesIn->Get_Type(), pShapesIn->Get_Name(), pShapesIn, pShapesIn->Get_Vertex_Type()); CSG_Shapes *pShapesOut = ((CSG_Shapes *)pMerged); for(int i=0; iGet_Count(); i++) { CSG_Shape *pShape = pShapesIn->Get_Shape(i); pShapesOut->Add_Shape(pShape); if( pShapesIn->Get_Vertex_Type() > SG_VERTEX_TYPE_XY ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pShapesOut->Get_Shape(i)->Set_Z(pShape->Get_Z(iPoint, iPart), iPoint, iPart); if( pShapesIn->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShapesOut->Get_Shape(i)->Set_M(pShape->Get_M(iPoint, iPart), iPoint, iPart); } } } } } } else // if( pList->Get_Type() == PARAMETER_TYPE_Table_List ) { pMerged->Create(*((CSG_Table *)pList->asDataObject(0))); } pMerged->Set_Name(_TL("Merged Layers")); //----------------------------------------------------- bool bInfo = Parameters("SRCINFO")->asBool(); if( bInfo ) { pMerged->Add_Field(_TL("Source"), SG_DATATYPE_String, 0); for(int i=0; iGet_Count(); i++) { pMerged->Set_Value(i, 0, pList->asDataObject(0)->Get_Name()); } } int *Index = NULL; //----------------------------------------------------- for(int iTable=1; iTableGet_Count() && Process_Get_Okay(); iTable++) { CSG_Table *pTable = (CSG_Table *)pList->asDataObject(iTable); //------------------------------------------------- if( Parameters("MATCH")->asBool() ) // see which fields are in both attributes tables { Index = (int *)SG_Realloc(Index, pTable->Get_Field_Count() * sizeof(int)); for(int i=0; iGet_Field_Count(); i++) { CSG_String Name(pTable->Get_Field_Name(i)); Index[i] = -1; for(int j=bInfo?1:0; Index[i]<0 && jGet_Field_Count(); j++) { if( !Name.CmpNoCase(pMerged->Get_Field_Name(j)) ) { Index[i] = j; } } } } //------------------------------------------------- for(int iRecord=0; iRecordGet_Count(); iRecord++) { CSG_Table_Record *pOutput, *pInput = pTable->Get_Record(iRecord); if( pMerged->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ) { CSG_Shape *pShapeOut; pOutput = pShapeOut = ((CSG_Shapes *)pMerged)->Add_Shape(pInput, SHAPE_COPY_GEOM); if( pMerged->asShapes()->Get_Vertex_Type() > SG_VERTEX_TYPE_XY ) { CSG_Shape *pShapeIn = pTable->asShapes()->Get_Shape(iRecord); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pShapeOut->Set_Z(pShapeIn->Get_Z(iPoint, iPart), iPoint, iPart); if( pMerged->asShapes()->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShapeOut->Set_M(pShapeIn->Get_M(iPoint, iPart), iPoint, iPart); } } } } } else // if( pMerged->Get_ObjectType() == DATAOBJECT_TYPE_Table ) { pOutput = pMerged->Add_Record(); } if( bInfo ) { pOutput->Set_Value(0, pTable->Get_Name()); } if( Index ) { for(int i=0; iGet_Field_Count(); i++) { if( Index[i] >= 0 ) { *pOutput->Get_Value(Index[i]) = *pInput->Get_Value(i); } } } else // if( !Index ) { for(int i=0, j=bInfo?1:0; iGet_Field_Count() && jGet_Field_Count(); i++, j++) { *pOutput->Get_Value(j) = *pInput->Get_Value(i); } } } } //----------------------------------------------------- SG_FREE_SAFE(Index); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/GraticuleBuilder.h0000664000175000017500000000511512614213767025426 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GraticuleBuilder.h 2661 2015-10-28 09:40:58Z oconrad $ *********************************************************/ /******************************************************************************* GraticuleBuilder.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGraticuleBuilder : public CSG_Module { public: CGraticuleBuilder(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/Shapes_Create_Empty.cpp0000664000175000017500000002704112565125410026411 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Create_Empty.cpp 2355 2014-12-19 09:55:41Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Create_Empty.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Shapes_Create_Empty.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_NODE(i) CSG_String::Format(SG_T("NODE%03d"), i) #define GET_NAME(i) CSG_String::Format(SG_T("NAME%03d"), i) #define GET_TYPE(i) CSG_String::Format(SG_T("TYPE%03d"), i) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Create_Empty::CShapes_Create_Empty(void) { //----------------------------------------------------- Set_Name (_TL("Create New Shapes Layer")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (CSG_String::Format(_TW( "Creates a new empty shapes layer of given type, " "which might be either point, multipoint, line or polygon.\n\n" "Possible field types for the attributes table are:\n" "- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n"), SG_Data_Type_Get_Name(SG_DATATYPE_String).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Date ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Color ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Byte ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Char ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Word ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Short ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_DWord ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Int ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_ULong ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Long ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Float ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Double).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Binary).c_str() )); //----------------------------------------------------- Parameters.Add_Shapes_Output( NULL , "SHAPES" , _TL("Shapes"), _TL("") ); Parameters.Add_String( NULL , "NAME" , _TL("Name"), _TL(""), _TL("New Shapes Layer") ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Shape Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Point"), _TL("Multipoint"), _TL("Lines"), _TL("Polygon") ) ); Parameters.Add_Choice( NULL , "VERTEX" , _TL("Vertex Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("x, y"), _TL("x, y, z"), _TL("x, y, z, m") ) ); Parameters.Add_Value( NULL , "NFIELDS" , _TL("Number of Attributes"), _TL(""), PARAMETER_TYPE_Int , 2, 1, true ); Parameters.Add_Parameters( NULL , "FIELDS" , _TL("Attributes"), _TL("") ); //----------------------------------------------------- CSG_Parameters *pAttributes = Parameters("FIELDS")->asParameters(); _Set_Field_Count(pAttributes, Parameters("NFIELDS")->asInt()); pAttributes->Get_Parameter(GET_NAME(0))->Set_Value(_TL("ID")); pAttributes->Get_Parameter(GET_TYPE(0))->Set_Value(3); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CShapes_Create_Empty::_Set_Field_Count(CSG_Parameters *pAttributes, int nAttributes) { //----------------------------------------------------- CSG_String Types; Types = CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"), SG_Data_Type_Get_Name(SG_DATATYPE_String).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Date ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Color ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Byte ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Char ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Word ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Short ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_DWord ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Int ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_ULong ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Long ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Float ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Double).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Binary).c_str() ); //----------------------------------------------------- if( pAttributes && nAttributes > 0 ) { int nCurrent = pAttributes->Get_Count() / 3; if( nCurrent < nAttributes ) { for(int i=nCurrent; iAdd_Node( NULL , GET_NODE(i), CSG_String::Format(SG_T("%i. %s"), i + 1, _TL("Attribute")), _TL("") ); pAttributes->Add_String( pNode , GET_NAME(i), _TL("Name"), _TL(""), _TL("Name") ); pAttributes->Add_Choice( pNode , GET_TYPE(i), _TL("Type"), _TL(""), Types ); } } else if( nCurrent > nAttributes ) { CSG_Parameters Tmp; Tmp.Assign(pAttributes); pAttributes->Destroy(); pAttributes->Set_Name(Tmp.Get_Name()); for(int i=0; iAdd_Node( NULL , GET_NODE(i), CSG_String::Format(SG_T("%i. %s"), i + 1, _TL("Attribute")), _TL("") ); pAttributes->Add_String( pNode , GET_NAME(i), _TL("Name"), _TL(""), Tmp(GET_NAME(i)) ? Tmp(GET_NAME(i))->asString() : _TL("Name") ); pAttributes->Add_Choice( pNode , GET_TYPE(i), _TL("Type"), _TL(""), Types, Tmp(GET_TYPE(i)) ? Tmp(GET_TYPE(i))->asInt() : 0 ); } } } } //--------------------------------------------------------- int CShapes_Create_Empty::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("NFIELDS")) ) { _Set_Field_Count(pParameters->Get_Parameter("FIELDS")->asParameters(), pParameter->asInt()); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Create_Empty::On_Execute(void) { TSG_Vertex_Type Vertex; switch( Parameters("VERTEX")->asInt() ) { default: case 0: Vertex = SG_VERTEX_TYPE_XY; break; case 1: Vertex = SG_VERTEX_TYPE_XYZ; break; case 2: Vertex = SG_VERTEX_TYPE_XYZM; break; } //----------------------------------------------------- CSG_Shapes *pShapes; switch( Parameters("TYPE")->asInt() ) { default: return( false ); case 0: pShapes = SG_Create_Shapes(SHAPE_TYPE_Point , Parameters("NAME")->asString(), NULL, Vertex); break; case 1: pShapes = SG_Create_Shapes(SHAPE_TYPE_Points , Parameters("NAME")->asString(), NULL, Vertex); break; case 2: pShapes = SG_Create_Shapes(SHAPE_TYPE_Line , Parameters("NAME")->asString(), NULL, Vertex); break; case 3: pShapes = SG_Create_Shapes(SHAPE_TYPE_Polygon, Parameters("NAME")->asString(), NULL, Vertex); break; } //----------------------------------------------------- int i, n; TSG_Data_Type Type; CSG_Parameters *pAttributes; pAttributes = Parameters("FIELDS")->asParameters(); n = pAttributes->Get_Count() / 3; for(i=0; iGet_Parameter(GET_TYPE(i))->asInt() ) { default: case 0: Type = SG_DATATYPE_String; break; case 1: Type = SG_DATATYPE_Date; break; case 2: Type = SG_DATATYPE_Color; break; case 3: Type = SG_DATATYPE_Byte; break; case 4: Type = SG_DATATYPE_Char; break; case 5: Type = SG_DATATYPE_Word; break; case 6: Type = SG_DATATYPE_Short; break; case 7: Type = SG_DATATYPE_DWord; break; case 8: Type = SG_DATATYPE_Int; break; case 9: Type = SG_DATATYPE_ULong; break; case 10: Type = SG_DATATYPE_Long; break; case 11: Type = SG_DATATYPE_Float; break; case 12: Type = SG_DATATYPE_Double; break; case 13: Type = SG_DATATYPE_Binary; break; } pShapes->Add_Field(pAttributes->Get_Parameter(GET_NAME(i))->asString(), Type); } Parameters("SHAPES")->Set_Value(pShapes); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/Shapes_Merge.h0000664000175000017500000000541412565125410024534 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Merge.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* Shapes_Merge.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Merge_H #define HEADER_INCLUDED__Shapes_Merge_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTables_Merge : public CSG_Module { public: CTables_Merge(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Table|Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Merge : public CTables_Merge { public: CShapes_Merge(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Merge_H saga-2.2.3/src/modules/shapes/shapes_tools/shapes_split_by_attribute.h0000664000175000017500000001032312565125410027440 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_split_by_attribute.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_split_by_attribute.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__shapes_split_by_attribute_H #define HEADER_INCLUDED__shapes_split_by_attribute_H //--------------------------------------------------------- #include "shapes_cut.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Split_by_Attribute : public CSG_Module { public: CShapes_Split_by_Attribute(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_split_by_attribute_H saga-2.2.3/src/modules/shapes/shapes_tools/TransformShapes.cpp0000664000175000017500000002037212565125410025644 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: TransformShapes.cpp 2339 2014-11-17 16:15:58Z reklov_w $ *********************************************************/ /******************************************************************************* TransformShapes.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ //--------------------------------------------------------- #include "TransformShapes.h" //--------------------------------------------------------- CTransformShapes::CTransformShapes(void) { Set_Name (_TL("Transform Shapes")); Set_Author (SG_T("(c) 2004 by Victor Olaya")); Set_Description (_TW( "(c) 2004 by Victor Olaya. Use this module to move, rotate and/or scale shapes." )); CSG_Parameter *pNode_0; //----------------------------------------------------- Parameters.Add_Shapes( NULL , "IN" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "MOVE" , _TL("Move"), _TL("") ); Parameters.Add_Value( pNode_0 , "DX" , _TL("dX"), _TL("dX (Map Units)"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0, "DY" , _TL("dY"), _TL("dY (Map Units)"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0, "DZ" , _TL("dZ"), _TL("dZ (Map Units)"), PARAMETER_TYPE_Double, 0.0 ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "ROTATE" , _TL("Rotate"), _TL("")); Parameters.Add_Value( pNode_0 , "ANGLE" , _TL("Angle"), _TL("Angle in degrees, counting clockwise from north"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0 , "ROTATEX" , _TL("Rotation X"), _TL("Angle in degrees, clockwise around x axis"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0 , "ROTATEY" , _TL("Rotation Y"), _TL("Angle in degrees, clockwise around y axis"), PARAMETER_TYPE_Double, 0.0 ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "SCALE" , _TL("Scale"), _TL("") ); Parameters.Add_Value( pNode_0 , "SCALEX" , _TL("Scale Factor X"), _TL("Scale Factor X"), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Value( pNode_0 , "SCALEY" , _TL("Scale Factor Y"), _TL("Scale Factor Y"), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Value( pNode_0 , "SCALEZ" , _TL("Scale Factor Z"), _TL("Scale Factor Z"), PARAMETER_TYPE_Double, 1.0 ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "ANCHOR" , _TL("Anchor Point"), _TL("") ); Parameters.Add_Value( pNode_0 , "ANCHORX" , _TL("X"), _TL("X"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0 , "ANCHORY" , _TL("Y"), _TL("Y"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0 , "ANCHORZ" , _TL("Z"), _TL("Z"), PARAMETER_TYPE_Double, 0.0 ); }//constructor //--------------------------------------------------------- CTransformShapes::~CTransformShapes(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTransformShapes::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("IN")) && pParameter->asShapes() != NULL ) { pParameters->Set_Enabled("ROTATEX", pParameter->asShapes()->Get_Vertex_Type() != SG_VERTEX_TYPE_XY); pParameters->Set_Enabled("ROTATEY", pParameter->asShapes()->Get_Vertex_Type() != SG_VERTEX_TYPE_XY); pParameters->Set_Enabled("DZ", pParameter->asShapes()->Get_Vertex_Type() != SG_VERTEX_TYPE_XY); pParameters->Set_Enabled("SCALEZ", pParameter->asShapes()->Get_Vertex_Type() != SG_VERTEX_TYPE_XY); pParameters->Set_Enabled("ANCHORZ", pParameter->asShapes()->Get_Vertex_Type() != SG_VERTEX_TYPE_XY); } return( 0 ); } //--------------------------------------------------------- bool CTransformShapes::On_Execute(void) { bool bCopy; double angleX, angleY, angleZ; TSG_Point_Z P, Q, Move, Scale, Anchor; CSG_Shapes *pIn, *pOut; double a11, a12, a13, a21, a22, a23, a31, a32, a33; //----------------------------------------------------- pIn = Parameters("IN") ->asShapes(); pOut = Parameters("OUT") ->asShapes(); Scale.x = Parameters("SCALEX") ->asDouble(); Scale.y = Parameters("SCALEY") ->asDouble(); Scale.z = Parameters("SCALEZ") ->asDouble(); Move.x = Parameters("DX") ->asDouble(); Move.y = Parameters("DY") ->asDouble(); Move.z = Parameters("DZ") ->asDouble(); Anchor.x = Parameters("ANCHORX") ->asDouble(); Anchor.y = Parameters("ANCHORY") ->asDouble(); Anchor.z = Parameters("ANCHORZ") ->asDouble(); angleX = Parameters("ROTATEX") ->asDouble() * -M_DEG_TO_RAD; angleY = Parameters("ROTATEY") ->asDouble() * -M_DEG_TO_RAD; angleZ = Parameters("ANGLE") ->asDouble() * -M_DEG_TO_RAD; if( pIn == pOut ) { bCopy = true; pOut = SG_Create_Shapes(); }//if else { bCopy = false; }//else pOut->Create(pIn->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pIn->Get_Name(), _TL("Transformed")), pIn, pIn->Get_Vertex_Type()); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count(); iShape++) { CSG_Shape *pShape = pOut->Add_Shape(pIn->Get_Shape(iShape)); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { P.x = pShape->Get_Point(iPoint, iPart).x; P.y = pShape->Get_Point(iPoint, iPart).y; if( pIn->Get_Vertex_Type() < SG_VERTEX_TYPE_XYZ ) { // move first, then rotate and scale... P.x += Move.x - Anchor.x; P.y += Move.y - Anchor.y; Q.x = Anchor.x + Scale.x * (P.x * cos(angleZ) - P.y * sin(angleZ)); Q.y = Anchor.y + Scale.y * (P.x * sin(angleZ) + P.y * cos(angleZ)); pShape->Set_Point(Q.x, Q.y, iPoint, iPart); } else { P.z = pIn->Get_Shape(iShape)->Get_Z(iPoint, iPart); //anchor shift P.x -= Anchor.x; P.y -= Anchor.y; P.z -= Anchor.z; // create rotation matrix a11 = cos(angleY) * cos(angleZ); a12 = -cos(angleX) * sin(angleZ) + sin(angleX) * sin(angleY) * cos(angleZ); a13 = sin(angleX) * sin(angleZ) + cos(angleX) * sin(angleY) * cos(angleZ); a21 = cos(angleY) * sin(angleZ); a22 = cos(angleX) * cos(angleZ) + sin(angleX) * sin(angleY) * sin(angleZ); a23 = -sin(angleX) * cos(angleZ) + cos(angleX) * sin(angleY) * sin(angleZ); a31 = -sin(angleY); a32 = sin(angleX) * cos(angleY); a33 = cos(angleX) * cos(angleY); //transform Q.x = (P.x * a11 + P.y * a12 + P.z * a13) * Scale.x; Q.y = (P.x * a21 + P.y * a22 + P.z * a23) * Scale.y; Q.z = (P.x * a31 + P.y * a32 + P.z * a33) * Scale.z; //undo anchor shift and apply move Q.x += Anchor.x + Move.x; Q.y += Anchor.y + Move.y; Q.z += Anchor.z + Move.z; pShape->Set_Point(Q.x, Q.y, iPoint, iPart); pShape->Set_Z(Q.z, iPoint, iPart); if( pIn->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShape->Set_M(pIn->Get_Shape(iShape)->Get_M(iPoint, iPart), iPoint, iPart); } } }//for iPoint }//for iPart }//for iShape //----------------------------------------------------- if( bCopy ) { pIn->Assign(pOut); delete(pOut); }//if return true; }//method saga-2.2.3/src/modules/shapes/shapes_tools/shapes_buffer.h0000664000175000017500000001241312565125410025003 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_buffer.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Buffer.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Buffer_H #define HEADER_INCLUDED__Shapes_Buffer_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Buffer : public CSG_Module { public: CShapes_Buffer(void); protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool m_bPolyInner; double m_dArc; bool Get_Buffers (CSG_Shapes *pShapes, int Field, CSG_Shapes *pBuffers, double Scale, bool bDissolve); bool Get_Buffer (CSG_Shape *pShape , CSG_Shape *pBuffer, double Distance); bool Get_Buffer_Point (CSG_Shape *pPoint , CSG_Shape *pBuffer, double Distance); bool Get_Buffer_Points (CSG_Shape *pPoints , CSG_Shape *pBuffer, double Distance); bool Get_Buffer_Line (CSG_Shape *pLine , CSG_Shape *pBuffer, double Distance); bool Get_Buffer_Polygon (CSG_Shape *pPolygon, CSG_Shape *pBuffer, double Distance); double Get_Direction (const TSG_Point &From, const TSG_Point &To); bool Get_Parallel (const TSG_Point &A, const TSG_Point &B, TSG_Point AB[2], double Distance); void Add_Vertex (CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, double theta); void Add_Arc (CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, double alpha, double beta); void Add_Arc (CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, const TSG_Point &A, const TSG_Point &B); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Buffer_H saga-2.2.3/src/modules/shapes/shapes_tools/shapes_cut_interactive.cpp0000664000175000017500000002224512565125410027261 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_cut_interactive.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Cut_Interactive.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "shapes_cut_interactive.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Cut_Interactive::CShapes_Cut_Interactive(void) { Set_Name (_TL("Cut Shapes Layer")); Set_Author (SG_T("(c) 2006 by O.Conrad")); Set_Description (_TW( "" )); Set_Drag_Mode (MODULE_INTERACTIVE_DRAG_BOX); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "CUT" , _TL("Cut"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), Cut_Methods_Str(), 0 ); //----------------------------------------------------- CSG_Parameters *pParameters = Add_Parameters("CUT", _TL("Extent"), _TL("")); pParameters->Add_Value( NULL, "AX" , _TL("Left") , _TL(""), PARAMETER_TYPE_Double ); pParameters->Add_Value( NULL, "BX" , _TL("Right") , _TL(""), PARAMETER_TYPE_Double ); pParameters->Add_Value( NULL, "AY" , _TL("Bottom") , _TL(""), PARAMETER_TYPE_Double ); pParameters->Add_Value( NULL, "BY" , _TL("Top") , _TL(""), PARAMETER_TYPE_Double ); pParameters->Add_Value( NULL, "DX" , _TL("Horizontal Range") , _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); pParameters->Add_Value( NULL, "DY" , _TL("Vertical Range") , _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); } //--------------------------------------------------------- CShapes_Cut_Interactive::~CShapes_Cut_Interactive(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Cut_Interactive::On_Execute(void) { m_bDown = false; m_pShapes = Parameters("SHAPES") ->asShapes(); m_pCut = Parameters("CUT") ->asShapes(); m_pExtent = Parameters("EXTENT") ->asShapes(); m_Method = Parameters("METHOD") ->asInt(); m_pCut->Create(m_pShapes->Get_Type()); return( true ); } //--------------------------------------------------------- bool CShapes_Cut_Interactive::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { switch( Mode ) { //----------------------------------------------------- case MODULE_INTERACTIVE_LDOWN: if( m_bDown == false ) { m_bDown = true; m_pDown = ptWorld; } return( true ); //----------------------------------------------------- case MODULE_INTERACTIVE_LUP: if( m_bDown == true ) { m_bDown = false; CSG_Rect r(m_pDown, ptWorld); if( Get_Extent(r) ) { if( Cut_Set_Extent(r, m_pExtent, true) ) { DataObject_Update(m_pExtent); } if( Cut_Shapes(r, m_Method, m_pShapes, m_pCut) ) { DataObject_Update(m_pCut); } else { Message_Add(_TL("No shapes in selection")); } } } return( true ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CShapes_Cut_Interactive::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameters->Get_Identifier(), SG_T("CUT")) ) { double ax, ay, bx, by, dx, dy, d; ax = pParameters->Get_Parameter("AX")->asDouble(); ay = pParameters->Get_Parameter("AY")->asDouble(); bx = pParameters->Get_Parameter("BX")->asDouble(); by = pParameters->Get_Parameter("BY")->asDouble(); dx = pParameters->Get_Parameter("DX")->asDouble(); dy = pParameters->Get_Parameter("DY")->asDouble(); if( ax > bx ) { d = ax; ax = bx; bx = d; } if( ay > by ) { d = ay; ay = by; by = d; } if ( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("DX")) ) { bx = ax + dx; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("AX")) || !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("BX")) ) { dx = bx - ax; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("DY")) ) { by = ay + dy; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("AY")) || !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("BY")) ) { dy = by - ay; } pParameters->Get_Parameter("AX")->Set_Value(ax); pParameters->Get_Parameter("AY")->Set_Value(ay); pParameters->Get_Parameter("BX")->Set_Value(bx); pParameters->Get_Parameter("BY")->Set_Value(by); pParameters->Get_Parameter("DX")->Set_Value(dx); pParameters->Get_Parameter("DY")->Set_Value(dy); return( true ); } return( false ); } //--------------------------------------------------------- bool CShapes_Cut_Interactive::Get_Extent(CSG_Rect &r) { CSG_Parameters *pParameters = Get_Parameters("CUT"); pParameters->Get_Parameter("AX")->Set_Value(r.Get_XMin()); pParameters->Get_Parameter("AY")->Set_Value(r.Get_YMin()); pParameters->Get_Parameter("BX")->Set_Value(r.Get_XMax()); pParameters->Get_Parameter("BY")->Set_Value(r.Get_YMax()); pParameters->Get_Parameter("DX")->Set_Value(r.Get_XRange()); pParameters->Get_Parameter("DY")->Set_Value(r.Get_YRange()); if( Dlg_Parameters("CUT") ) { r.Assign( pParameters->Get_Parameter("AX")->asDouble(), pParameters->Get_Parameter("AY")->asDouble(), pParameters->Get_Parameter("BX")->asDouble(), pParameters->Get_Parameter("BY")->asDouble() ); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/quadtree_structure.cpp0000664000175000017500000002173012565125410026456 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: quadtree_structure.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // quadtree_structure.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "quadtree_structure.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CQuadTree_Structure::CQuadTree_Structure(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("QuadTree Structure to Shapes")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ATTRIBUTE" , _TL("Attribute"), _TL(""), true ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Duplicated Points"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); } //--------------------------------------------------------- bool CQuadTree_Structure::On_Execute(void) { CSG_PRQuadTree QT(Parameters("SHAPES")->asShapes(), Parameters("ATTRIBUTE")->asInt()); Get_Shapes(Parameters("POLYGONS")->asShapes(), (CSG_PRQuadTree_Item *)&QT.Get_Root()); Get_Shapes(Parameters("LINES") ->asShapes(), (CSG_PRQuadTree_Item *)&QT.Get_Root()); Get_Shapes(Parameters("POINTS") ->asShapes(), (CSG_PRQuadTree_Item *)&QT.Get_Root()); return( true ); } //--------------------------------------------------------- bool CQuadTree_Structure::Get_Shapes(CSG_Shapes *pShapes, CSG_PRQuadTree_Item *pItem) { CSG_Shape *pShape; if( pShapes && pItem ) { switch( pShapes->Get_Type() ) { default: return( false ); case SHAPE_TYPE_Point: pShapes->Create(SHAPE_TYPE_Point , CSG_String::Format(SG_T("%s [%s, %s]"), Parameters("SHAPES")->asShapes()->Get_Name(), _TL("QuadTree"), _TL("Duplicates"))); pShapes->Add_Field("COUNT", SG_DATATYPE_Int); pShapes->Add_Field("VALUE", SG_DATATYPE_String); break; case SHAPE_TYPE_Line: pShapes->Create(SHAPE_TYPE_Line , CSG_String::Format(SG_T("%s [%s, %s]"), Parameters("SHAPES")->asShapes()->Get_Name(), _TL("QuadTree"), _TL("Squares"))); pShapes->Add_Field("LEVEL", SG_DATATYPE_Int); pShape = pShapes->Add_Shape(); pShape->Set_Value(0, 0.0); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yMin()); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yMax()); pShape->Add_Point(pItem->Get_xMax(), pItem->Get_yMax()); pShape->Add_Point(pItem->Get_xMax(), pItem->Get_yMin()); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yMin()); break; case SHAPE_TYPE_Polygon: pShapes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s, %s]"), Parameters("SHAPES")->asShapes()->Get_Name(), _TL("QuadTree"), _TL("Leafs"))); pShapes->Add_Field("LEVEL", SG_DATATYPE_Int); pShapes->Add_Field("VALUE", SG_DATATYPE_Double); pShapes->Add_Field("COUNT", SG_DATATYPE_Int); break; } Get_Shapes(pShapes, pItem, 1); return( true ); } return( false ); } //--------------------------------------------------------- void CQuadTree_Structure::Get_Shapes(CSG_Shapes *pShapes, CSG_PRQuadTree_Item *pItem, int Level) { if( pItem ) { switch( pShapes->Get_Type() ) { //------------------------------------------------- case SHAPE_TYPE_Point: { if( pItem->is_Leaf() ) { CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Add_Point(pItem->asLeaf()->Get_Point()); if( pItem->has_Statistics() ) { CSG_PRQuadTree_Leaf_List *pList = (CSG_PRQuadTree_Leaf_List *)pItem; pShape->Set_Value(0, pList->Get_Count()); pShape->Set_Value(1, SG_Get_String(pList->Get_Value(0), -2).c_str()); for(int i=1; iGet_Count(); i++) { pShape->Set_Value(1, CSG_String::Format(SG_T("%s|%s"), pShape->asString(1), SG_Get_String(pList->Get_Value(i), -2).c_str() )); } } else { pShape->Set_Value(0, 1); pShape->Set_Value(1, SG_Get_String(pItem->asLeaf()->Get_Z(), -2).c_str()); } } } break; //------------------------------------------------- case SHAPE_TYPE_Line: { if( pItem->is_Node() ) { CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Set_Value(0, Level); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yCenter(), 0); pShape->Add_Point(pItem->Get_xMax(), pItem->Get_yCenter(), 0); pShape->Add_Point(pItem->Get_xCenter(), pItem->Get_yMin(), 1); pShape->Add_Point(pItem->Get_xCenter(), pItem->Get_yMax(), 1); } } break; //------------------------------------------------- case SHAPE_TYPE_Polygon: { if( pItem->is_Leaf() ) { CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Set_Value(0, Level + 1); pShape->Set_Value(1, pItem->asLeaf()->Get_Z()); pShape->Set_Value(2, pItem->has_Statistics() ? ((CSG_PRQuadTree_Leaf_List *)pItem)->Get_Count() : 1); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yMin()); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yMax()); pShape->Add_Point(pItem->Get_xMax(), pItem->Get_yMax()); pShape->Add_Point(pItem->Get_xMax(), pItem->Get_yMin()); } } break; } //------------------------------------------------- if( pItem->is_Node() ) { for(int i=0; i<4; i++) { Get_Shapes(pShapes, pItem->asNode()->Get_Child(i), Level + 1); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/LandUse_Scenario.cpp0000664000175000017500000003251712565125410025707 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: LandUse_Scenario.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics // // // //-------------------------------------------------------// // // // LandUse_Scenario.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "LandUse_Scenario.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define STATISTICS_HEADCOLS 3 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLandUse_Scenario::CLandUse_Scenario(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Land Use Scenario Generator")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "This tool generates land use scenarios for fields under " "agricultural use based on statistics about the amount of " "crop types grown in the investigated area of interest. " )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "FIELDS" , _TL("Fields"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field( pNode , "FIELD_ID" , _TL("Field Identifier"), _TL("") ); pNode = Parameters.Add_Shapes( NULL , "SCENARIO" , _TL("Land Use Scenario"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( pNode , "OUTPUT" , _TL("Output of..."), _TL(""), CSG_String::Format("%s|%s|", _TL("Identifier"), _TL("Name") ), 0 ); //----------------------------------------------------- Parameters.Add_Table( NULL , "STATISTICS" , _TL("Crop Statistics"), _TW("The first column specifies a crop type id. " "The second column provides a human readible name for the crop type (e.g. 'potatoes') ." "The third column must be an integer value, though this value is not yet used by this module. " "The following columns provide the yearly amount of each crop type [%] for a sequence of years. "), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "KNOWN_CROPS" , _TL("Known Crops"), _TW("The first column specifies the field id as given by the 'Fields' layer. " "The following columns specify the crop type for each field and year " "and refer to the crop type identifiers used in the crop statistics table. " "The sequence of years must be identical with that of the crop statistics table."), PARAMETER_INPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLandUse_Scenario::On_Execute(void) { //----------------------------------------------------- CSG_Table *pStatistics = Parameters("STATISTICS")->asTable(); if( pStatistics->Get_Field_Count() <= STATISTICS_HEADCOLS ) { Error_Set(_TL("statistics table is missing required fields")); return( false ); } if( pStatistics->Get_Count() <= 0 ) { Error_Set(_TL("statistics table does not contain any records")); return( false ); } //----------------------------------------------------- CSG_Shapes *pFields = Parameters("FIELDS" )->asShapes(); int Field_ID = Parameters("FIELD_ID")->asInt (); if( pFields->Get_Count() <= 0 ) { Error_Set(_TL("fields layer does not contain any records")); return( false ); } //----------------------------------------------------- int nYears, iYear, iField, iType; //----------------------------------------------------- CSG_Table Types; Types.Add_Field("ID" , SG_DATATYPE_Int); Types.Add_Field("NAME" , SG_DATATYPE_String); Types.Add_Field("RETURN", SG_DATATYPE_Int); Types.Set_Record_Count(pStatistics->Get_Count()); nYears = pStatistics->Get_Field_Count() - STATISTICS_HEADCOLS; CSG_Matrix Crops(nYears, Types.Get_Count()); for(iType=0; iTypeGet_Record(iType); Types[iType][0] = pRecord->asInt (0); Types[iType][1] = pRecord->asString(1); Types[iType][2] = pRecord->asInt (2); for(iYear=0; iYearasDouble(iYear + STATISTICS_HEADCOLS); } } //----------------------------------------------------- CSG_Table Scenario; for(iYear=0; iYearGet_Field_Name(iYear + STATISTICS_HEADCOLS), SG_DATATYPE_Int); } Scenario.Add_Field("ID" , SG_DATATYPE_Int); Scenario.Add_Field("AREA", SG_DATATYPE_Double); Scenario.Set_Record_Count(pFields->Get_Count()); for(iField=0; iFieldGet_Count(); iField++) { CSG_Shape_Polygon *pField = (CSG_Shape_Polygon *)pFields->Get_Shape(iField); Scenario[iField][nYears + 0] = pField->asInt(Field_ID); Scenario[iField][nYears + 1] = pField->Get_Area(); for(iYear=0; iYearasShapes(); bool bID = Parameters("OUTPUT")->asInt() == 0; pScenario->Create(SHAPE_TYPE_Polygon, CSG_String::Format("%s [%s]", pFields->Get_Name(), _TL("Land Use Scenario"))); pScenario->Add_Field("ID", SG_DATATYPE_Int); for(iYear=0; iYearAdd_Field(pStatistics->Get_Field_Name(iYear + STATISTICS_HEADCOLS), bID ? SG_DATATYPE_Int : SG_DATATYPE_String); } //----------------------------------------------------- for(iField=0; iFieldGet_Count(); iField++) { CSG_Shape *pField = pScenario->Add_Shape(pFields->Get_Shape(iField), SHAPE_COPY_GEOM); pField->Set_Value(0, pFields->Get_Shape(iField)->asInt(Field_ID)); for(iYear=0; iYearasTable(); if( !pLandUse_Known || pLandUse_Known->Get_Field_Count() != nYears + 1 ) { return( true ); } for(int iKnown=0; iKnownGet_Count(); iKnown++) { CSG_Table_Record *pKnown = pLandUse_Known->Get_Record(iKnown); for(int iField=0, Field_ID=pKnown->asInt(0); iFieldasInt(iYear + 1); for(int iType=0; iType= 0 ) { iType = Scenario[iField][iYear].asInt(); Area_Left -= Scenario[iField][nYears + 1]; Area_Crop[iType] -= Scenario[iField][nYears + 1]; } } //------------------------------------------------- // 3. fill remaining gaps with randomized scenario... for(iField=0; iField= 0 ) { Area_Left -= Scenario[iField][nYears + 1]; Area_Crop[Type] -= Scenario[iField][nYears + 1]; Scenario[iField][iYear] = Type; } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/LandUse_Scenario.h0000664000175000017500000001100512565125410025341 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: LandUse_Scenario.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics // // // //-------------------------------------------------------// // // // LandUse_Scenario.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__LandUse_Scenario_H #define HEADER_INCLUDED__LandUse_Scenario_H #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLandUse_Scenario : public CSG_Module { public: CLandUse_Scenario(void); protected: virtual bool On_Execute(void); private: bool Get_Known_LandUse (int nYears, CSG_Table &Scenario, const CSG_Table &Types); bool Get_Scenario (int nYears, CSG_Table &Scenario, const CSG_Matrix &Crops); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__LandUse_Scenario_H saga-2.2.3/src/modules/shapes/shapes_tools/shapes_cut.h0000664000175000017500000001177112565125410024333 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_cut.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Cut.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Cut_H #define HEADER_INCLUDED__Shapes_Cut_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shapes * Cut_Shapes (CSG_Shapes *pPolygons, int Method, CSG_Shapes *pShapes); CSG_Shapes * Cut_Shapes (CSG_Rect Extent , int Method, CSG_Shapes *pShapes); bool Cut_Shapes (CSG_Shapes *pPolygons, int Method, CSG_Shapes *pShapes, CSG_Shapes *pCut); bool Cut_Shapes (CSG_Rect Extent , int Method, CSG_Shapes *pShapes, CSG_Shapes *pCut); CSG_String Cut_Methods_Str (void); bool Cut_Set_Extent (CSG_Rect Extent, CSG_Shapes *pExtent, bool bClear); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Cut : public CSG_Module { public: CShapes_Cut(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Shapes *m_pPolygons; bool Get_Extent (CSG_Rect &r); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Cut_H saga-2.2.3/src/modules/shapes/shapes_tools/QueryBuilder.cpp0000664000175000017500000001222212565125410025134 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: QueryBuilder.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* 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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "QueryBuilder.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelect_Numeric::CSelect_Numeric(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Select by Attributes... (Numerical Expression)")); Set_Author (SG_T("V.Olaya (c) 2004, O.Conrad (c) 2011")); Set_Description (_TW( "Selects records for which the expression is true." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("attribute to be searched; if not set all attributes will be searched"), true ); Parameters.Add_String( NULL , "EXPRESSION" , _TL("Expression"), _TL(""), SG_T("a > 0") ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("new selection"), _TL("add to current selection"), _TL("select from current selection"), _TL("remove from current selection") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_Numeric::On_Execute(void) { int Method, Field; CSG_String Expression; CSG_Shapes *pShapes; CSG_Formula Formula; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); Field = Parameters("FIELD") ->asInt(); Expression = Parameters("EXPRESSION") ->asString(); Method = Parameters("METHOD") ->asInt(); //----------------------------------------------------- if( !Formula.Set_Formula(Expression) ) { CSG_String Message; if( Formula.Get_Error(Message) ) { Error_Set(Message); } return( false ); } //----------------------------------------------------- double *Values = new double[pShapes->Get_Field_Count()]; for(int i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { CSG_Shape *pShape = pShapes->Get_Shape(i); if( Field >= pShapes->Get_Field_Count() ) { for(int j=0; jGet_Field_Count(); j++) { Values[j] = pShape->asDouble(j); } } else { Values[0] = pShape->asDouble(Field); } switch( Method ) { case 0: // New selection if( ( pShape->is_Selected() && !Formula.Get_Value(Values, pShapes->Get_Field_Count())) || (!pShape->is_Selected() && Formula.Get_Value(Values, pShapes->Get_Field_Count())) ) { pShapes->Select(i, true); } break; case 1: // Add to current selection if( !pShape->is_Selected() && Formula.Get_Value(Values, pShapes->Get_Field_Count()) ) { pShapes->Select(i, true); } break; case 2: // Select from current selection if( pShape->is_Selected() && !Formula.Get_Value(Values, pShapes->Get_Field_Count()) ) { pShapes->Select(i, true); } break; case 3: // Remove from current selection if( pShape->is_Selected() && Formula.Get_Value(Values, pShapes->Get_Field_Count()) ) { pShapes->Select(i, true); } break; } } delete[](Values); //----------------------------------------------------- Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("selected shapes"), pShapes->Get_Selection_Count())); DataObject_Update(pShapes); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/shapes_split_by_attribute.cpp0000664000175000017500000001351212565125410027776 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_split_by_attribute.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_split_by_attribute.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_split_by_attribute.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Split_by_Attribute::CShapes_Split_by_Attribute(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Split Table/Shapes by Attribute")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table / Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL(""), false ); Parameters.Add_Table_List( NULL , "CUTS" , _TL("Cuts"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Split_by_Attribute::On_Execute(void) { int iField; CSG_Table *pTable; //----------------------------------------------------- pTable = Parameters("TABLE") ->asTable(); iField = Parameters("FIELD") ->asInt(); Parameters("CUTS")->asTableList()->Del_Items(); //----------------------------------------------------- if( pTable->is_Valid() && pTable->Set_Index(iField, TABLE_INDEX_Ascending) ) { CSG_String sValue; CSG_Table *pCut = NULL; for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record_byIndex(iRecord); if( !pCut || sValue.Cmp(pRecord->asString(iField)) ) { pCut = pTable->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ? SG_Create_Shapes(((CSG_Shapes *)pTable)->Get_Type(), SG_T(""), pTable) : SG_Create_Table(pTable); pCut->Set_Name(CSG_String::Format(SG_T("%s [%s = %s]"), pTable->Get_Name(), pTable->Get_Field_Name(iField), pRecord->asString(iField) )); Parameters("CUTS")->asTableList()->Add_Item(pCut); sValue = pRecord->asString(iField); } pCut->Add_Record(pRecord); } return( pCut != NULL ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/MLB_Interface.cpp0000664000175000017500000001446712565125410025127 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2417 2015-02-19 15:14:52Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Tools") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Olaya, V. Wichmann (c) 2002-2013") ); case MLB_INFO_Description: return( _TL("Tools for the manipulation of vector data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Tools") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Shapes_Create_Empty.h" #include "Shapes_Merge.h" #include "QueryBuilder.h" #include "SearchInTable.h" #include "SelectByTheme.h" #include "NewLayerFromSelectedShapes.h" #include "SeparateShapes.h" #include "TransformShapes.h" #include "CreateChartLayer.h" #include "GraticuleBuilder.h" #include "shapes_cut.h" #include "shapes_cut_interactive.h" #include "shapes_split.h" #include "shapes_split_randomly.h" #include "shapes_split_by_attribute.h" #include "shapes_buffer.h" #include "shapes_extents.h" #include "quadtree_structure.h" #include "shapes_polar_to_cartes.h" #include "shapes_generate.h" #include "shapes_convert_vertex_type.h" #include "LandUse_Scenario.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CShapes_Create_Empty ); case 2: return( new CShapes_Merge ); case 24: return( new CTables_Merge ); case 3: return( new CSelect_Numeric ); case 4: return( new CSelect_String ); case 5: return( new CSelect_Location ); case 6: return( new CSelection_Copy ); case 7: return( new CSelection_Delete ); case 8: return( new CSelection_Invert ); case 9: return( new CSeparateShapes ); case 10: return( new CTransformShapes ); case 11: return( new CCreateChartLayer ); case 12: return( new CGraticuleBuilder ); case 13: return( new CShapes_Cut ); case 14: return( new CShapes_Cut_Interactive ); case 15: return( new CShapes_Split ); case 16: return( new CShapes_Split_Randomly ); case 17: return( new CShapes_Split_by_Attribute ); case 18: return( new CShapes_Buffer ); case 19: return( new CShapes_Extents ); case 20: return( new CQuadTree_Structure ); case 21: return( new CShapes_Polar_to_Cartes ); case 22: return( new CShapes_Generate ); case 23: return( new CShapes_Convert_Vertex_Type ); case 25: return( new CLandUse_Scenario ); case 30: return( NULL ); } return( MLB_INTERFACE_SKIP_MODULE ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/shapes/shapes_tools/Makefile.am0000664000175000017500000000315112565125410024051 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 2417 2015-02-19 15:14:52Z oconrad $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_tools.la libshapes_tools_la_SOURCES =\ CreateChartLayer.cpp\ GraticuleBuilder.cpp\ LandUse_Scenario.cpp\ MLB_Interface.cpp\ NewLayerFromSelectedShapes.cpp\ quadtree_structure.cpp\ QueryBuilder.cpp\ SearchInTable.cpp\ SelectByTheme.cpp\ SeparateShapes.cpp\ Shapes_Create_Empty.cpp\ Shapes_Merge.cpp\ TransformShapes.cpp\ shapes_buffer.cpp\ shapes_convert_vertex_type.cpp\ shapes_cut.cpp\ shapes_cut_interactive.cpp\ shapes_extents.cpp\ shapes_generate.cpp\ shapes_polar_to_cartes.cpp\ shapes_split.cpp\ shapes_split_by_attribute.cpp\ shapes_split_randomly.cpp\ CreateChartLayer.h\ GraticuleBuilder.h\ LandUse_Scenario.h\ MLB_Interface.h\ NewLayerFromSelectedShapes.h\ quadtree_structure.h\ QueryBuilder.h\ SearchInTable.h\ SelectByTheme.h\ SeparateShapes.h\ Shapes_Create_Empty.h\ Shapes_Merge.h\ TransformShapes.h\ shapes_buffer.h\ shapes_convert_vertex_type.h\ shapes_cut.h\ shapes_cut_interactive.h\ shapes_extents.h\ shapes_generate.h\ shapes_polar_to_cartes.h\ shapes_split.h\ shapes_split_by_attribute.h\ shapes_split_randomly.h libshapes_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la #install-exec-hook: # pushd .; cd $(pkglibdir); ln -s libshapes_tools.so shapes_tools.so; popd saga-2.2.3/src/modules/shapes/shapes_tools/MLB_Interface.h0000664000175000017500000000772312565125410024571 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__shapes_tools_H #define HEADER_INCLUDED__shapes_tools_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef shapes_tools_EXPORTS #define shapes_tools_EXPORT _SAGA_DLL_EXPORT #else #define shapes_tools_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_tools_H saga-2.2.3/src/modules/shapes/shapes_tools/shapes_convert_vertex_type.cpp0000664000175000017500000002025212565125410030203 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_convert_vertex_type.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_convert_vertex_type.cpp // // // // Copyright (C) 2013 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_convert_vertex_type.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Convert_Vertex_Type::CShapes_Convert_Vertex_Type(void) { Set_Name(_TL("Convert Vertex Type (2D/3D)")); Set_Author(_TL("Volker Wichmann (c) 2013, LASERDATA GmbH")); Set_Description (_TW( "The module allows to convert the vertex type of shapes from " "'XY' (2D) to 'XYZ/M' (3D) and vice versa. The conversion from " "3D to 2D is not lossless for lines and polygons, as only the " "Z/M value of one vertex can be retained (currently that of the " "last vertex).\n\n") ); //----------------------------------------------------- CSG_Parameter *pNode; pNode = Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL("The shapefile to convert."), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD_Z" , _TL("Z"), _TL("Field with z-coordinate information."), true ); Parameters.Add_Table_Field( pNode , "FIELD_M" , _TL("M"), _TL("Field with measure information."), true ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL("The converted shapefile."), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CShapes_Convert_Vertex_Type::~CShapes_Convert_Vertex_Type(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Convert_Vertex_Type::On_Execute(void) { CSG_Shapes *pInput, *pOutput; int iFieldZ, iFieldM; pInput = Parameters("INPUT")->asShapes(); iFieldZ = Parameters("FIELD_Z")->asInt(); iFieldM = Parameters("FIELD_M")->asInt(); pOutput = Parameters("OUTPUT")->asShapes(); if( pInput->Get_Count() < 1 ) { SG_UI_Msg_Add_Error(_TL("Input shape is empty!")); return (false); } //----------------------------------------------------- if( pInput->Get_Vertex_Type() == SG_VERTEX_TYPE_XY ) { if( iFieldZ < 0 ) { SG_UI_Msg_Add_Error(_TL("Please provide an attribute field with z-information!")); return( false ); } if( iFieldM < 0 ) { pOutput->Create(pInput->Get_Type(), CSG_String::Format(SG_T("%s_Z"), pInput->Get_Name()), pInput, SG_VERTEX_TYPE_XYZ); } else { pOutput->Create(pInput->Get_Type(), CSG_String::Format(SG_T("%s_ZM"), pInput->Get_Name()), pInput, SG_VERTEX_TYPE_XYZM); } } else { pOutput->Create(pInput->Get_Type(), CSG_String::Format(SG_T("%s_XY"), pInput->Get_Name()), pInput, SG_VERTEX_TYPE_XY); pOutput->Add_Field(SG_T("Z"), SG_DATATYPE_Double); if( pInput->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pOutput->Add_Field(SG_T("M"), SG_DATATYPE_Double); } } //----------------------------------------------------- for(int iShape=0; iShapeGet_Count(); iShape++) { CSG_Shape *pShapeIn = pInput ->Get_Shape(iShape); CSG_Shape *pShapeOut = pOutput ->Add_Shape(pShapeIn, SHAPE_COPY_ATTR); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pShapeOut->Add_Point(pShapeIn->Get_Point(iPoint, iPart), iPart); if( pInput->Get_Vertex_Type() == SG_VERTEX_TYPE_XY ) { pShapeOut->Set_Z(pShapeIn->asDouble(iFieldZ), iPoint, iPart); if( pOutput->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShapeOut->Set_M(pShapeIn->asDouble(iFieldM), iPoint, iPart); } } else { if( pInput->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShapeOut->Set_Value(pOutput->Get_Field_Count() - 1, pShapeIn->Get_M(iPoint, iPart)); pShapeOut->Set_Value(pOutput->Get_Field_Count() - 2, pShapeIn->Get_Z(iPoint, iPart)); } else { pShapeOut->Set_Value(pOutput->Get_Field_Count() - 1, pShapeIn->Get_Z(iPoint, iPart)); } } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- int CShapes_Convert_Vertex_Type::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("INPUT")) && pParameter->asShapes() != NULL ) { pParameters->Get_Parameter("FIELD_Z")->Set_Enabled(pParameters->Get_Parameter("INPUT")->asShapes()->Get_Vertex_Type() == SG_VERTEX_TYPE_XY); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FIELD_Z")) ) { pParameters->Get_Parameter("FIELD_M")->Set_Enabled(pParameter->asInt() >= 0); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/shapes_extents.cpp0000664000175000017500000001574212565125410025567 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_extents.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Extents.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_extents.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Extents::CShapes_Extents(void) { //----------------------------------------------------- Set_Name (_TL("Get Shapes Extents")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "EXTENTS" , _TL("Extents"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Get Extent for ..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("all shapes"), _TL("each shape"), _TL("each shape's part") ), 1 ); } //--------------------------------------------------------- CShapes_Extents::~CShapes_Extents(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Extents::On_Execute(void) { CSG_Shapes *pShapes = Parameters("SHAPES" )->asShapes(); CSG_Shapes *pExtents = Parameters("EXTENTS")->asShapes(); //----------------------------------------------------- if( !pShapes->is_Valid() ) { Message_Add(_TL("invalid input")); return( false ); } //----------------------------------------------------- int iOutput = Parameters("OUTPUT")->asInt(); if( iOutput == 0 ) // all shapes { pExtents->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Extent"))); pExtents->Add_Field(SG_T("OID"), SG_DATATYPE_Int); TSG_Rect r = pShapes->Get_Extent(); CSG_Shape *pExtent = pExtents->Add_Shape(); pExtent->Set_Value(0, 1); pExtent->Add_Point(r.xMin, r.yMin); pExtent->Add_Point(r.xMin, r.yMax); pExtent->Add_Point(r.xMax, r.yMax); pExtent->Add_Point(r.xMax, r.yMin); return( true ); } //----------------------------------------------------- if( pShapes->Get_Type() == SHAPE_TYPE_Point ) { Message_Add(_TL("no 'get extents' support for single point layers")); return( false ); } //----------------------------------------------------- pExtents->Create(SHAPE_TYPE_Polygon, pShapes->Get_Name(), pShapes); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); if( iOutput == 1 ) // each shape { TSG_Rect r = pShape->Get_Extent(); CSG_Shape *pExtent = pExtents->Add_Shape(pShape, SHAPE_COPY_ATTR); pExtent->Add_Point(r.xMin, r.yMin); pExtent->Add_Point(r.xMin, r.yMax); pExtent->Add_Point(r.xMax, r.yMax); pExtent->Add_Point(r.xMax, r.yMin); } else // if( iOutput == 2 ) // each shape's part { for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Rect r = pShape->Get_Extent(iPart); CSG_Shape *pExtent = pExtents->Add_Shape(pShape, SHAPE_COPY_ATTR); pExtent->Add_Point(r.xMin, r.yMin); pExtent->Add_Point(r.xMin, r.yMax); pExtent->Add_Point(r.xMax, r.yMax); pExtent->Add_Point(r.xMax, r.yMin); } } } //----------------------------------------------------- return( pExtents->is_Valid() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/shapes_generate.h0000664000175000017500000001131612565125410025325 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_generate.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_generate.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Generate_H #define HEADER_INCLUDED__Shapes_Generate_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Generate : public CSG_Module { public: CShapes_Generate(void); virtual ~CShapes_Generate(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual bool On_Execute (void); private: bool Generate_Point_Shapes (CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY); bool Generate_Line_Shapes (CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY); bool Generate_Polygon_Shapes (CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Generate_H saga-2.2.3/src/modules/shapes/shapes_tools/CreateChartLayer.h0000664000175000017500000000332412565125410025352 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CreateChartLayer.h 2447 2015-03-19 14:43:42Z oconrad $ *********************************************************/ /******************************************************************************* CreateChartLayer.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CCreateChartLayer : public CSG_Module { public: CCreateChartLayer(); virtual ~CCreateChartLayer(); virtual bool is_ProjectDependent(void) {return( false );} private: double m_fMaxValue, m_fMinValue; double m_fMaxSize, m_fMinSize; CSG_Parameters *m_pExtraParameters; bool *m_bIncludeParam; CSG_Shapes *m_pOutput; void AddPieChart(CSG_Shape*, int); void AddBarChart(CSG_Shape*, int); bool GetExtraParameters(); TSG_Point GetLineMidPoint(CSG_Shape_Line*); protected: virtual bool On_Execute(void); }; saga-2.2.3/src/modules/shapes/shapes_tools/shapes_split_randomly.cpp0000664000175000017500000001774012605526014027135 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_split_randomly.cpp 2642 2015-10-08 11:57:54Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Split_Randomly.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_split_randomly.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Split_Randomly::CShapes_Split_Randomly(void) { Set_Name (_TL("Split Shapes Layer Randomly")); Set_Author ("O.Conrad (c) 2008"); Set_Description (_TW( "Randomly splits one layer into to two new layers. " "Useful to create a control group for model testing. " "Optionally this can be done category-wise if a category " "field is specified. " )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Categories"), _TL(""), true ); Parameters.Add_Shapes( NULL , "A" , _TL("Group A"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "B" , _TL("Group B"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "PERCENT" , _TL("Relation B / A"), _TL(""), PARAMETER_TYPE_Double, 25.0, 0.0, true, 100.0, true ); Parameters.Add_Value( NULL , "EXACT" , _TL("Exact"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Split_Randomly::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pSplit[2], *pShapes = Parameters("SHAPES")->asShapes(); if( !pShapes->is_Valid() ) { Error_Set("invalid input"); return( false ); } //----------------------------------------------------- double Percent = Parameters("PERCENT")->asDouble(); pSplit[0] = Parameters("A")->asShapes(); pSplit[1] = Parameters("B")->asShapes(); pSplit[0]->Create(pShapes->Get_Type(), CSG_String::Format("%s [%d%%]", pShapes->Get_Name(), (int)(100.5 - Percent)), pShapes); pSplit[1]->Create(pShapes->Get_Type(), CSG_String::Format("%s [%d%%]", pShapes->Get_Name(), (int)( 0.5 + Percent)), pShapes); CSG_Random::Initialize(); // initialize with current time //----------------------------------------------------- int Field = Parameters("FIELD")->asInt(); if( Field < 0 ) { Split(pShapes, pSplit, Percent); } else // stratified { CSG_String Category; CSG_Shapes Shapes(pShapes->Get_Type(), pShapes->Get_Name(), pShapes); pShapes->Set_Index(Field, TABLE_INDEX_Ascending); for(int i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { CSG_Shape *pShape = pShapes->Get_Shape_byIndex(i); if( Shapes.Get_Count() == 0 ) { Category = pShape->asString(Field); } else if( Category.Cmp(pShape->asString(Field)) ) // category changed { Category = pShape->asString(Field); Split(&Shapes, pSplit, Percent); Shapes.Del_Shapes(); } Shapes.Add_Shape(pShape); } Split(&Shapes, pSplit, Percent); // don't forget to split last category } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CShapes_Split_Randomly::Split(CSG_Shapes *pShapes, CSG_Shapes *pSplit[2], double Percent) { //----------------------------------------------------- if( !Parameters("EXACT")->asBool() ) { for(int i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { pSplit[Percent >= CSG_Random::Get_Uniform(0, 100) ? 1 : 0]->Add_Shape(pShapes->Get_Shape(i)); } } //----------------------------------------------------- else { int i, n = (int)(0.5 + pShapes->Get_Count() * Percent / 100.0); CSG_Table Random; Random.Add_Field("INDEX" , SG_DATATYPE_Int); Random.Add_Field("PERCENT", SG_DATATYPE_Double); for(i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { CSG_Table_Record *pRecord = Random.Add_Record(); pRecord->Set_Value(0, i); pRecord->Set_Value(1, CSG_Random::Get_Uniform(0, 100)); } Random.Set_Index(1, TABLE_INDEX_Ascending); //------------------------------------------------- for(i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { pSplit[i < n ? 1 : 0]->Add_Shape(pShapes->Get_Shape(Random[i].asInt(0))); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/shapes_cut_interactive.h0000664000175000017500000001113712565125410026724 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_cut_interactive.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Cut_Interactive.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Cut_Interactive_H #define HEADER_INCLUDED__Shapes_Cut_Interactive_H //--------------------------------------------------------- #include "shapes_cut.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Cut_Interactive : public CSG_Module_Interactive { public: CShapes_Cut_Interactive(void); virtual ~CShapes_Cut_Interactive(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: bool m_bDown; int m_Method; CSG_Point m_pDown; CSG_Shapes *m_pShapes, *m_pCut, *m_pExtent; bool Get_Extent (CSG_Rect &r); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Cut_Interactive_H saga-2.2.3/src/modules/shapes/shapes_tools/shapes_buffer.cpp0000664000175000017500000003514712565125410025347 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_buffer.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Buffer.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_buffer.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Buffer::CShapes_Buffer(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Shapes Buffer")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "A vector based buffer construction partly based on the method supposed by Dong et al. 2003. " "\n\n" "References:\n" "Dong, P, Yang, C., Rui, X., Zhang, L., Cheng, Q. (2003): " "'An effective buffer generation method in GIS'. " "Geoscience and Remote Sensing Symposium, 2003. " "IGARSS '03. Proceedings. 2003 IEEE International, Vol.6, p.3706-3708.\n" "online version\n" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "BUFFER" , _TL("Buffer"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); pNode = Parameters.Add_Table_Field_or_Const( pNode , "DIST_FIELD" , _TL("Buffer Distance"), _TL(""), 100.0, 0.0, true ); Parameters.Add_Value( pNode , "DIST_SCALE" , _TL("Scaling Factor for Attribute Value"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL , "DISSOLVE" , _TL("Dissolve Buffers"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "NZONES" , _TL("Number of Buffer Zones"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Value( NULL , "POLY_INNER" , _TL("Inner Buffer"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "DARC" , _TL("Arc Vertex Distance [Degree]"), _TL(""), PARAMETER_TYPE_Double, 5.0, 0.01, true, 45.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CShapes_Buffer::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SHAPES")) ) { pParameters->Get_Parameter("POLY_INNER")->Set_Enabled(pParameter->asShapes() && pParameter->asShapes()->Get_Type() == SHAPE_TYPE_Polygon); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("NZONES")) ) { pParameters->Get_Parameter("DISSOLVE" )->Set_Enabled(pParameter->asInt() == 1); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("DIST_FIELD")) ) { pParameters->Get_Parameter("DIST_SCALE")->Set_Enabled(pParameter->asInt() >= 0); } //----------------------------------------------------- return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Buffer::On_Execute(void) { int Field, nZones; CSG_Shapes *pShapes, *pBuffers; //----------------------------------------------------- pShapes = Parameters("SHAPES" )->asShapes(); pBuffers = Parameters("BUFFER" )->asShapes(); nZones = Parameters("NZONES" )->asInt(); Field = Parameters("DIST_FIELD")->asInt(); m_dArc = Parameters("DARC" )->asDouble() * M_DEG_TO_RAD; m_bPolyInner = Parameters("POLY_INNER")->asBool() && pShapes->Get_Type() == SHAPE_TYPE_Polygon; //----------------------------------------------------- if( !pShapes->is_Valid() ) { Message_Add(_TL("Invalid Shapes")); return( false ); } if( Field < 0 && Parameters("DIST_FIELD")->asDouble() <= 0.0 ) { Message_Add(_TL("Invalid Buffer Distance")); return( false ); } //----------------------------------------------------- if( nZones == 1 ) { Get_Buffers(pShapes, Field, pBuffers, 1.0, Parameters("DISSOLVE")->asBool()); } //----------------------------------------------------- else if( nZones > 1 ) { CSG_Shape *pBuffer; CSG_Shapes Buffers; pBuffers->Create(SHAPE_TYPE_Polygon); pBuffers->Add_Field(_TL("ID") , SG_DATATYPE_Int); pBuffers->Add_Field(_TL("ZONE") , SG_DATATYPE_Double); double dZone = 1.0 / nZones; for(int iZone=0; iZone 0 ) { SG_Polygon_Difference(pBuffer, Buffers.Get_Shape(0)); } pBuffer = pBuffers->Add_Shape(Buffers.Get_Shape(0)); pBuffer ->Set_Value(0, (nZones - iZone) + 1); pBuffer ->Set_Value(1, (nZones - iZone) * dZone * 100.0); } } //----------------------------------------------------- pBuffers->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Buffer"))); return( pBuffers->is_Valid() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffers(CSG_Shapes *pShapes, int Field, CSG_Shapes *pBuffers, double Scale, bool bDissolve) { //----------------------------------------------------- double Distance; CSG_Shapes Part(SHAPE_TYPE_Polygon); CSG_Shape *pPart = Part.Add_Shape(), *pBuffer; Distance = Parameters("DIST_FIELD")->asDouble() * Scale; Scale = Parameters("DIST_SCALE")->asDouble() * Scale; if( !bDissolve ) { pBuffers->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Buffer")), pShapes); } else { pBuffers->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Buffer"))); pBuffers->Add_Field(_TL("ID"), SG_DATATYPE_Int); pBuffer = pBuffers->Add_Shape(); } //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); if( Field < 0 || (Distance = Scale * pShape->asDouble(Field)) > 0.0 ) { if( !bDissolve ) { pBuffer = pBuffers->Add_Shape(pShape, SHAPE_COPY_ATTR); } if( pBuffer->Get_Part_Count() == 0 ) { Get_Buffer(pShape, pBuffer, Distance); } else { Get_Buffer(pShape, pPart , Distance); SG_Polygon_Union(pBuffer, pPart); pPart->Del_Parts(); } } } //----------------------------------------------------- return( pBuffers->is_Valid() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer(CSG_Shape *pShape, CSG_Shape *pBuffer, double Distance) { switch( pShape->Get_Type() ) { case SHAPE_TYPE_Point: return( Get_Buffer_Point (pShape, pBuffer, Distance) ); case SHAPE_TYPE_Points: return( Get_Buffer_Points (pShape, pBuffer, Distance) ); case SHAPE_TYPE_Line: return( Get_Buffer_Line (pShape, pBuffer, Distance) ); case SHAPE_TYPE_Polygon: return( Get_Buffer_Polygon (pShape, pBuffer, Distance) ); default: return( false ); } } //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer_Point(CSG_Shape *pPoint, CSG_Shape *pBuffer, double Distance) { Add_Arc(pBuffer, pPoint->Get_Point(0), Distance, 0.0, M_PI_360); return( true ); } //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer_Points(CSG_Shape *pPoints, CSG_Shape *pBuffer, double Distance) { CSG_Shapes Part(SHAPE_TYPE_Polygon); CSG_Shape *pPart = Part.Add_Shape(); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { if( pBuffer->Get_Part_Count() == 0 ) { Add_Arc(pBuffer, pPoints->Get_Point(iPoint), Distance, 0.0, M_PI_360); } else { Add_Arc(pPart , pPoints->Get_Point(iPoint), Distance, 0.0, M_PI_360); SG_Polygon_Union(pBuffer, pPart); pPart->Del_Parts(); } } } return( true ); } //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer_Line(CSG_Shape *pLine, CSG_Shape *pBuffer, double Distance) { return( SG_Polygon_Offset(pLine, Distance, m_dArc, pBuffer) ); } //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer_Polygon(CSG_Shape *pPolygon, CSG_Shape *pBuffer, double Distance) { if( m_bPolyInner ) { if( SG_Polygon_Offset(pPolygon, -Distance, m_dArc, pBuffer) ) SG_Polygon_Difference(pPolygon, pBuffer, pBuffer); else pBuffer->Assign(pPolygon, false); return( true ); } return( SG_Polygon_Offset(pPolygon, Distance, m_dArc, pBuffer) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CShapes_Buffer::Get_Direction(const TSG_Point &From, const TSG_Point &To) { double dx = To.x - From.x; double dy = To.y - From.y; return( dx != 0.0 ? M_PI_180 + atan2(dy, dx) : ( dy > 0.0 ? M_PI_270 : ( dy < 0.0 ? M_PI_090 : 0.0 ) ) ); } //--------------------------------------------------------- inline bool CShapes_Buffer::Get_Parallel(const TSG_Point &A, const TSG_Point &B, TSG_Point AB[2], double Distance) { double d; TSG_Point C; if( (d = SG_Get_Distance(A, B)) > 0.0 ) { d = Distance / d; C.x = d * (A.y - B.y); C.y = d * (B.x - A.x); AB[0].x = A.x + C.x; AB[0].y = A.y + C.y; AB[1].x = B.x + C.x; AB[1].y = B.y + C.y; return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CShapes_Buffer::Add_Vertex(CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, double theta) { pBuffer->Add_Point( Center.x + Distance * cos(theta), Center.y + Distance * sin(theta) ); } //--------------------------------------------------------- inline void CShapes_Buffer::Add_Arc(CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, double alpha, double beta) { double theta; if( alpha < beta ) { for(theta=alpha; thetabeta; theta-=m_dArc) { Add_Vertex(pBuffer, Center, Distance, theta); } } Add_Vertex(pBuffer, Center, Distance, beta); } //--------------------------------------------------------- inline void CShapes_Buffer::Add_Arc(CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, const TSG_Point &A, const TSG_Point &B) { double alpha, beta; alpha = Get_Direction(A, Center); beta = Get_Direction(B, Center); if( alpha - beta >= M_PI_180 ) { beta += M_PI_360; } Add_Arc(pBuffer, Center, Distance, alpha, beta); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/quadtree_structure.h0000664000175000017500000001102512565125410026117 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: quadtree_structure.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // quadtree_structure.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__quadtree_structure_H #define HEADER_INCLUDED__quadtree_structure_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CQuadTree_Structure : public CSG_Module { public: CQuadTree_Structure(void); protected: virtual bool On_Execute (void); private: bool Get_Shapes (CSG_Shapes *pShapes, CSG_PRQuadTree_Item *pItem); void Get_Shapes (CSG_Shapes *pShapes, CSG_PRQuadTree_Item *pItem, int Level); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__quadtree_structure_H saga-2.2.3/src/modules/shapes/shapes_tools/TransformShapes.h0000664000175000017500000000271412565125410025311 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: TransformShapes.h 2339 2014-11-17 16:15:58Z reklov_w $ *********************************************************/ /******************************************************************************* TransformShapes.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CTransformShapes : public CSG_Module{ public: CTransformShapes(void); virtual ~CTransformShapes(void); protected: virtual bool On_Execute(void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: }; saga-2.2.3/src/modules/shapes/shapes_tools/NewLayerFromSelectedShapes.h0000664000175000017500000000562512565125410027365 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: NewLayerFromSelectedShapes.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* NewLayerFromSelectedShapes.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelection_Copy : public CSG_Module { public: CSelection_Copy(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelection_Delete : public CSG_Module { public: CSelection_Delete(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelection_Invert : public CSG_Module { public: CSelection_Invert(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_tools/NewLayerFromSelectedShapes.cpp0000664000175000017500000001252612565125410027716 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: NewLayerFromSelectedShapes.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* NewLayerFromSelectedShapes.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "NewLayerFromSelectedShapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelection_Copy::CSelection_Copy(void) { Set_Name (_TL("Copy Selection to New Shapes Layer")); Set_Author (SG_T("Victor Olaya (c) 2004")); Set_Description (_TW( "Copies selected shapes to a new shapes layer." )); Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- bool CSelection_Copy::On_Execute(void) { CSG_Shapes *pInput, *pOutput; pInput = Parameters("INPUT") ->asShapes(); pOutput = Parameters("OUTPUT")->asShapes(); if( pInput->Get_Selection_Count() <= 0 ) { Error_Set(_TL("no shapes in selection")); return( false ); } if( pOutput->Get_Type() != SHAPE_TYPE_Undefined && pOutput->Get_Type() != pInput->Get_Type() && pOutput->Get_Vertex_Type() != pInput->Get_Vertex_Type() ) { Parameters("OUTPUT")->Set_Value(pOutput = SG_Create_Shapes()); } pOutput->Create(pInput->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), _TL("Selection")), pInput, pInput->Get_Vertex_Type()); for(int i=0; iGet_Selection_Count() && Set_Progress(i, pInput->Get_Selection_Count()); i++) { CSG_Shape *pShape = pInput->Get_Selection(i); pOutput->Add_Shape(pShape); if( pInput->Get_Vertex_Type() > SG_VERTEX_TYPE_XY ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pOutput->Get_Shape(i)->Set_Z(pShape->Get_Z(iPoint, iPart), iPoint, iPart); if( pInput->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pOutput->Get_Shape(i)->Set_M(pShape->Get_M(iPoint, iPart), iPoint, iPart); } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelection_Delete::CSelection_Delete(void) { Set_Name (_TL("Delete Selection from Shapes Layer")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Deletes selected shapes from shapes layer." )); Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); } //--------------------------------------------------------- bool CSelection_Delete::On_Execute(void) { CSG_Shapes *pInput; pInput = Parameters("INPUT") ->asShapes(); if( pInput->Get_Selection_Count() <= 0 ) { Error_Set(_TL("no shapes in selection")); return( false ); } pInput->Del_Selection(); DataObject_Update(pInput); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelection_Invert::CSelection_Invert(void) { Set_Name (_TL("Invert Selection of Shapes Layer")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Deselects selected and selects unselected shapes of given shapes layer." )); Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); } //--------------------------------------------------------- bool CSelection_Invert::On_Execute(void) { CSG_Shapes *pInput; pInput = Parameters("INPUT") ->asShapes(); pInput->Inv_Selection(); DataObject_Update(pInput); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/Makefile.am0000664000175000017500000000013712565125410021347 0ustar00oconradoconrad00000000000000SUBDIRS = shapes_tools shapes_polygons shapes_points shapes_lines shapes_grid shapes_transect saga-2.2.3/src/modules/shapes/shapes_polygons/0000775000175000017500000000000012634325745022541 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/shapes/shapes_polygons/Polygons_From_Lines.cpp0000664000175000017500000001767712565125410027204 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygons_From_Lines.cpp 2175 2014-06-24 15:42:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygons_From_Lines.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygons_From_Lines.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygons_From_Lines::CPolygons_From_Lines(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Convert Lines to Polygons")); Set_Author ("O.Conrad (c) 2005"); Set_Description (_TW( "Converts lines to polygons. " "Line arcs are closed to polygons simply by connecting the last point with the first. " "Optionally parts of polylines can be merged into one polygon optionally. " )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); pNode = Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); pNode = Parameters.Add_Value( NULL , "SINGLE" , _TL("Create Single Multipart Polygon"), _TL(""), PARAMETER_TYPE_Bool, false ); pNode = Parameters.Add_Value( NULL , "MERGE" , _TL("Merge Line Parts to One Polygon"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygons_From_Lines::On_Execute(void) { bool bSingle, bMerge; CSG_Shape *pLine , *pPolygon; CSG_Shapes *pLines, *pPolygons; pPolygons = Parameters("POLYGONS")->asShapes(); pLines = Parameters("LINES" )->asShapes(); bSingle = Parameters("SINGLE" )->asBool (); bMerge = Parameters("MERGE" )->asBool (); if( pLines->Get_Count() <= 0 ) { return( false ); } if( !bSingle ) { pPolygons ->Create(SHAPE_TYPE_Polygon, pLines->Get_Name(), pLines); } else { pPolygons ->Create(SHAPE_TYPE_Polygon, pLines->Get_Name()); pPolygons ->Add_Field(SG_T("ID"), SG_DATATYPE_Int); pPolygon = pPolygons ->Add_Shape(); pPolygon ->Set_Value(0, 1); } //----------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); if( pLine->is_Valid() ) { if( !bSingle ) { pPolygon = pPolygons->Add_Shape(pLine, SHAPE_COPY_ATTR); } if( !bMerge || pLine->Get_Part_Count() == 1 ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { Add_Part(pPolygon, pLine, pPolygon->Get_Part_Count(), iPart); } } else // if( bMerge && pLine->Get_Part_Count() > 1 ) { CSG_Shapes Copy(SHAPE_TYPE_Line); Add_Line(pPolygon, Copy.Add_Shape(pLine)); } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygons_From_Lines::Add_Part(CSG_Shape *pPolygon, CSG_Shape *pLine, int iPart_Polygon, int iPart_Line, bool bAscending) { for(int iPoint=0; iPointGet_Point_Count(iPart_Line); iPoint++) { pPolygon->Add_Point(pLine->Get_Point(iPoint, iPart_Line, bAscending), iPart_Polygon); } return( true ); } //--------------------------------------------------------- bool CPolygons_From_Lines::Add_Line(CSG_Shape *pPolygon, CSG_Shape *pLine, int iPart_Polygon) { bool bAscending; int iPart_Line; Add_Part(pPolygon, pLine, iPart_Polygon, 0); pLine->Del_Part(0); while( pLine->Get_Part_Count() > 0 ) { if( Get_Part(pPolygon->Get_Point(0, iPart_Polygon, false), pLine, iPart_Line, bAscending) ) { Add_Part(pPolygon, pLine, iPart_Polygon, iPart_Line, bAscending); pLine->Del_Part(iPart_Line); } else // start a new polygon part { Add_Part(pPolygon, pLine, ++iPart_Polygon, 0); pLine->Del_Part(0); } } return( true ); } //--------------------------------------------------------- bool CPolygons_From_Lines::Get_Part(CSG_Point Point, CSG_Shape *pLine, int &iPart, bool &bAscending) { for(iPart=0; iPartGet_Part_Count(); iPart++) { if( Point.is_Equal(pLine->Get_Point(0, iPart, bAscending = true)) ) { return( true ); } if( Point.is_Equal(pLine->Get_Point(0, iPart, bAscending = false)) ) { return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_Clip.cpp0000664000175000017500000003127312565125410025637 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Clip.cpp 1230 2011-11-22 11:12:10Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Clip.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Clip.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Clip::CPolygon_Clip(void) { //----------------------------------------------------- Set_Name (_TL("Polygon Clipping")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Clipping of vector layers with a polygon layer.\n" "Uses the free and open source software library Clipper created by Angus Johnson.\n" "Clipper Homepage\n" "Clipper at SourceForge\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "CLIP" , _TL("Clip Features"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "S_INPUT" , _TL("Input Features"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "S_OUTPUT" , _TL("Output Features"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes_List( NULL , "M_INPUT" , _TL("Input Features"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes_List( NULL , "M_OUTPUT" , _TL("Output Features"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "DISSOLVE" , _TL("Dissolve Clip Features"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "MULTIPLE" , _TL("Multiple Input Features"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPolygon_Clip::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("MULTIPLE")) ) { pParameters->Get_Parameter("S_INPUT" )->Set_Enabled(pParameter->asBool() == false); pParameters->Get_Parameter("S_OUTPUT")->Set_Enabled(pParameter->asBool() == false); pParameters->Get_Parameter("M_INPUT" )->Set_Enabled(pParameter->asBool() == true); pParameters->Get_Parameter("M_OUTPUT")->Set_Enabled(pParameter->asBool() == true); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Clip::On_Execute(void) { CSG_Shapes Clip, *pClip = Parameters("CLIP")->asShapes(); if( Parameters("DISSOLVE")->asBool() && Dissolve(pClip, &Clip) ) { pClip = &Clip; } //----------------------------------------------------- if( !Parameters("MULTIPLE")->asBool() ) // single input mode { return( Clip_Shapes(pClip, Parameters("S_INPUT" )->asShapes(), Parameters("S_OUTPUT")->asShapes() )); } //----------------------------------------------------- else // multiple input mode { CSG_Parameter_Shapes_List *pInput = Parameters("M_INPUT" )->asShapesList(); CSG_Parameter_Shapes_List *pOutput = Parameters("M_OUTPUT")->asShapesList(); pOutput->Del_Items(); for(int i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Shapes *pShapes = SG_Create_Shapes(); if( Clip_Shapes(pClip, pInput->asShapes(i), pShapes) ) { pOutput->Add_Item(pShapes); } else { delete(pShapes); } } return( pOutput->Get_Count() > 0 ); } } //--------------------------------------------------------- bool CPolygon_Clip::Clip_Shapes(CSG_Shapes *pClip, CSG_Shapes *pInput, CSG_Shapes *pOutput) { pOutput->Create(pInput->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), _TL("clipped")), pInput); switch( pInput->Get_Type() ) { case SHAPE_TYPE_Point: Clip_Points (pClip, pInput, pOutput); break; case SHAPE_TYPE_Points: Clip_Points (pClip, pInput, pOutput); break; case SHAPE_TYPE_Line: Clip_Lines (pClip, pInput, pOutput); break; case SHAPE_TYPE_Polygon: Clip_Polygons(pClip, pInput, pOutput); break; } return( pOutput->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPolygon_Clip::Clip_Points(CSG_Shapes *pClips, CSG_Shapes *pInputs, CSG_Shapes *pOutputs) { for(int iClip=0; iClipGet_Count() && Set_Progress(iClip, pClips->Get_Count()); iClip++) { CSG_Shape_Polygon *pClip = (CSG_Shape_Polygon *)pClips->Get_Shape(iClip); for(int iInput=0; iInputGet_Count(); iInput++) { CSG_Shape *pInput = pInputs->Get_Shape(iInput); CSG_Shape *pOutput = NULL; for(int iPoint=0; iPointGet_Point_Count(0); iPoint++) { if( pClip->Contains(pInput->Get_Point(iPoint, 0)) ) { if( pOutput == NULL ) { pOutput = pOutputs->Add_Shape(pInput, SHAPE_COPY_ATTR); } pOutput->Add_Point(pInput->Get_Point(iPoint, 0)); } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPolygon_Clip::Clip_Lines(CSG_Shapes *pClips, CSG_Shapes *pInputs, CSG_Shapes *pOutputs) { for(int iClip=0; iClipGet_Count() && Set_Progress(iClip, pClips->Get_Count()); iClip++) { CSG_Shape_Polygon *pClip = (CSG_Shape_Polygon *)pClips->Get_Shape(iClip); if( pInputs->Select(pClip->Get_Extent()) ) { for(int iInput=0; iInputGet_Selection_Count(); iInput++) { CSG_Shape *pNew_Line, *pLine = pInputs->Get_Selection(iInput); for(int iPart=0, jPart=-1; iPartGet_Part_Count(); iPart++) { TSG_Point B, A = pLine->Get_Point(0, iPart); bool bIn = pClip->Contains(A); if( bIn ) { pNew_Line = pOutputs->Add_Shape(pLine, SHAPE_COPY_ATTR); pNew_Line->Add_Point(A, ++jPart); } for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { B = A; A = pLine->Get_Point(iPoint, iPart); if( bIn ) { if( pClip->Contains(A) ) { pNew_Line->Add_Point(A, jPart); } else { pNew_Line->Add_Point(Get_Crossing(pClip, A, B), jPart); bIn = false; } } else if( pClip->Contains(A) ) { if( jPart < 0 ) { pNew_Line = pOutputs->Add_Shape(pLine, SHAPE_COPY_ATTR); } pNew_Line->Add_Point(Get_Crossing(pClip, A, B), ++jPart); pNew_Line->Add_Point(A, jPart); bIn = true; } } } } } } } //--------------------------------------------------------- TSG_Point CPolygon_Clip::Get_Crossing(CSG_Shape_Polygon *pPolygon, const TSG_Point &a, const TSG_Point &b) { TSG_Point c = a; for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point A, B; B = pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { A = B; B = pPolygon->Get_Point(iPoint, iPart); if( SG_Get_Crossing(c, A, B, a, b) ) { return( c ); } } } return( c ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPolygon_Clip::Clip_Polygons(CSG_Shapes *pClips, CSG_Shapes *pInputs, CSG_Shapes *pOutputs) { for(int iClip=0; iClipGet_Count() && Process_Get_Okay(); iClip++) { Process_Set_Text(CSG_String::Format(SG_T("%s: %d/%d"), _TL("clip features"), iClip + 1, pClips->Get_Count())); CSG_Shape *pClip = pClips->Get_Shape(iClip); for(int iInput=0; iInputGet_Count() && Set_Progress(iInput, pInputs->Get_Count()); iInput++) { CSG_Shape *pOutput = pOutputs->Add_Shape(pInputs->Get_Shape(iInput)); if( !SG_Polygon_Intersection(pOutput, pClip) ) { pOutputs->Del_Shape(pOutputs->Get_Count() - 1); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Clip::Dissolve(CSG_Shapes *pPolygons, CSG_Shapes *pOutput) { pOutput->Create(SHAPE_TYPE_Polygon); pOutput->Add_Field(_TL("ID"), SG_DATATYPE_Int); CSG_Shape *pDissolved = pOutput->Add_Shape(pPolygons->Get_Shape(0), SHAPE_COPY_GEOM); for(int iPolygon=1; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(iPolygon); for(int iPart=0; iPartGet_Part_Count(); iPart++) { CSG_Shape_Part *pPart = ((CSG_Shape_Polygon *)pPolygon)->Get_Part(iPart); for(int iPoint=0, nParts=pDissolved->Get_Part_Count(); iPointGet_Count(); iPoint++) { pDissolved->Add_Point(pPart->Get_Point(iPoint), nParts); } } } return( SG_Polygon_Dissolve(pDissolved) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/shape_index.h0000664000175000017500000001027712565125410025176 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shape_index.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Polygon // // // //-------------------------------------------------------// // // // Shape_Index.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shape_Index_H #define HEADER_INCLUDED__Shape_Index_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShape_Index : public CSG_Module { public: CShape_Index(void); virtual ~CShape_Index(void); protected: virtual bool On_Execute (void); private: double Get_Distance (CSG_Shape *pShape); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shape_Index_H saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_split_parts.cpp0000664000175000017500000001430712565125410027353 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_split_parts.cpp 915 2011-02-15 08:43:36Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_split_parts.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_split_parts.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Split_Parts::CPolygon_Split_Parts(void) { //----------------------------------------------------- Set_Name (_TL("Polygon Parts to Separate Polygons")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Splits parts of multipart polygons into separate polygons. " "This can be done only for islands (outer rings) or for all " "parts (inner and outer rings) by checking the 'ignore lakes' " "option." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "PARTS" , _TL("Polygon Parts"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "LAKES" , _TL("Ignore Lakes"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Split_Parts::On_Execute(void) { bool bIgnoreLakes; CSG_Shapes *pPolygons, *pParts; pPolygons = Parameters("POLYGONS") ->asShapes(); pParts = Parameters("PARTS") ->asShapes(); bIgnoreLakes = Parameters("LAKES") ->asBool(); pParts->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Parts")), pPolygons); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pPolygons->Get_Count()); iShape++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count() && Process_Get_Okay(); iPart++) { if( bIgnoreLakes || !((CSG_Shape_Polygon *)pPolygon)->is_Lake(iPart) ) { CSG_Shape *pPart = pParts->Add_Shape(pPolygon, SHAPE_COPY_ATTR); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pPart->Add_Point(pPolygon->Get_Point(iPoint, iPart)); } if( !bIgnoreLakes ) { for(int jPart=0; jPartGet_Part_Count(); jPart++) { if( ((CSG_Shape_Polygon *)pPolygon)->is_Lake(jPart) && ((CSG_Shape_Polygon *)pPart)->Contains(pPolygon->Get_Point(0, jPart)) ) { for(int jPoint=0, nPart=pPart->Get_Part_Count(); jPointGet_Point_Count(jPart); jPoint++) { pPart->Add_Point(pPolygon->Get_Point(jPoint, jPart), nPart); } } } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_Geometrics.cpp0000664000175000017500000001225012565125410027043 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Geometrics.cpp 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* Polygon_Geometrics.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Geometrics.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Geometrics::CPolygon_Geometrics(void) { Set_Name (_TL("Polygon Properties")); Set_Author (_TL("V.Olaya (c) 2004, O.Conrad (c) 2011")); Set_Description (_TW( "General and geometric properties of polygons." )); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Polygons with Property Attributes"), _TL("If not set property attributes will be added to the orignal layer."), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "BPARTS" , _TL("Number of Parts"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BPOINTS" , _TL("Number of Vertices"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BLENGTH" , _TL("Perimeter"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "BAREA" , _TL("Area"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Geometrics::On_Execute(void) { //------------------------------------------------- int bParts = Parameters("BPARTS") ->asBool() ? 0 : -1; int bPoints = Parameters("BPOINTS") ->asBool() ? 0 : -1; int bLength = Parameters("BLENGTH") ->asBool() ? 0 : -1; int bArea = Parameters("BAREA") ->asBool() ? 0 : -1; if( bParts && bPoints && bLength && bArea ) { Error_Set(_TL("no properties selected")); return( false ); } //------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( !pPolygons->is_Valid() || pPolygons->Get_Count() <= 0 ) { Error_Set(_TL("invalid lines layer")); return( false ); } if( Parameters("OUTPUT")->asShapes() && Parameters("OUTPUT")->asShapes() != pPolygons ) { pPolygons = Parameters("OUTPUT")->asShapes(); pPolygons->Create(*Parameters("POLYGONS")->asShapes()); } //------------------------------------------------- if( !bParts ) { bParts = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("NPARTS") , SG_DATATYPE_Int ); } if( !bPoints ) { bPoints = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("NPOINTS") , SG_DATATYPE_Int ); } if( !bLength ) { bLength = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("PERIMETER"), SG_DATATYPE_Double); } if( !bArea ) { bArea = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("AREA") , SG_DATATYPE_Double); } //------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pPolygons->Get_Count()); i++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(i); if( bParts >= 0 ) pPolygon->Set_Value(bParts , pPolygon->Get_Part_Count()); if( bPoints >= 0 ) pPolygon->Set_Value(bPoints, pPolygon->Get_Point_Count()); if( bLength >= 0 ) pPolygon->Set_Value(bLength, ((CSG_Shape_Polygon *)pPolygon)->Get_Perimeter()); if( bArea >= 0 ) pPolygon->Set_Value(bArea , ((CSG_Shape_Polygon *)pPolygon)->Get_Area()); } //------------------------------------------------- if( pPolygons == Parameters("POLYGONS")->asShapes() ) { DataObject_Update(pPolygons); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_split_parts.h0000664000175000017500000001040712565125410027015 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_split_parts.h 915 2011-02-15 08:43:36Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_split_parts.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__polygon_split_parts_H #define HEADER_INCLUDED__polygon_split_parts_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Split_Parts : public CSG_Module { public: CPolygon_Split_Parts(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__polygon_split_parts_H saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_line_intersection.cpp0000664000175000017500000006035712565125410030532 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_line_intersection.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_line_intersection.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_line_intersection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSG_Network_Node { friend class CSG_Network; public: int Get_ID (void) const { return( m_ID ); } const TSG_Point & Get_Point (void) const { return( m_Point ); } int Get_Edge_Count (void) const { return( m_Edges.Get_Count() ); } int Get_Edge (int iEdge) const { return( iEdge >= 0 && iEdge < m_Edges.Get_Count() ? m_Edges[iEdge].asInt(0) : -1 ); } double Get_Direction (int iEdge) const { return( m_Edges[iEdge][1] ); } int Get_Edge_Next (int iEdge, bool bClockwise = true) const { if( Get_Edge_Count() > 1 ) { for(int i=0; iasInt(0) == iEdge ) { i = bClockwise ? i < m_Edges.Get_Count() - 1 ? i + 1 : 0 : i > 0 ? i - 1 : m_Edges.Get_Count() - 1; return( m_Edges.Get_Record_byIndex(i)->asInt(0) ); } } } return( -1 ); } private: int m_ID; TSG_Point m_Point; CSG_Table m_Edges; CSG_Network_Node(int ID, const TSG_Point &Point) { m_ID = ID; m_Point = Point; m_Edges.Add_Field(SG_T("ID") , SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("DIR"), SG_DATATYPE_Double); } bool Add_Edge (int ID, double Direction) { CSG_Table_Record *pEdge = m_Edges.Add_Record(); pEdge->Set_Value(0, ID); pEdge->Set_Value(1, Direction); m_Edges.Set_Index(1, TABLE_INDEX_Ascending); return( true ); } bool Del_Edge (int ID) { int n = 0; for(int i=m_Edges.Get_Count()-1; i>=0; i--) { if( m_Edges[i].asInt(0) == ID ) { m_Edges.Del_Record(i); n++; } } if( n > 0 ) { m_Edges.Set_Index(1, TABLE_INDEX_Ascending); return( true ); } return( false ); } }; //--------------------------------------------------------- class CSG_Network { public: CSG_Network (void); bool Create (void); CSG_Network (CSG_Shapes *pLines); bool Create (CSG_Shapes *pLines); virtual ~CSG_Network (void); bool Destroy (void); const CSG_Shapes & Get_Edges (void) const { return( m_Edges ); } int Get_Node_Count (void) const { return( (int)m_Nodes.Get_Size() ); } CSG_Network_Node & Get_Node (int i) const { return( *((CSG_Network_Node **)m_Nodes.Get_Array())[i] ); } bool Add_Shape (CSG_Shape *pShape); bool Update (void); bool Remove_End_Nodes (void); private: CSG_Array m_Nodes; CSG_Shapes m_Edges; void _On_Construction (void); bool _Add_Line (CSG_Shape *pLine, int ID); int _Add_Node (CSG_PRQuadTree &Search, int Edge_ID, const TSG_Point &Node_Point, const TSG_Point &Dir_Point); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Network::CSG_Network(void) { _On_Construction(); Create(); } bool CSG_Network::Create(void) { Destroy(); return( true ); } //--------------------------------------------------------- CSG_Network::CSG_Network(CSG_Shapes *pLines) { _On_Construction(); Create(pLines); } bool CSG_Network::Create(CSG_Shapes *pLines) { Destroy(); if( !pLines || pLines->Get_Type() != SHAPE_TYPE_Line || !pLines->is_Valid() ) { return( false ); } for(int iLine=0; iLineGet_Count(); iLine++) { Add_Shape(pLines->Get_Shape(iLine)); } return( true ); } //--------------------------------------------------------- CSG_Network::~CSG_Network(void) { Destroy(); } bool CSG_Network::Destroy(void) { for(int i=0; iis_Valid() ) { return( false ); } //----------------------------------------------------- CSG_Shapes Part(SHAPE_TYPE_Line); CSG_Shape *pPart = Part.Add_Shape(); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pShape->Get_Point_Count(iPart) > 1 ) { bool bAscending = pShape->Get_Type() != SHAPE_TYPE_Polygon || ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) != ((CSG_Shape_Polygon *)pShape)->is_Clockwise(iPart); CSG_Point q, p = pShape->Get_Point(0, iPart, bAscending); pPart->Add_Point(p); for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { if( !p.is_Equal(q = pShape->Get_Point(iPoint, iPart, bAscending)) ) { p = q; pPart->Add_Point(p); } } if( pPart->Get_Point_Count(0) > 1 ) { _Add_Line(pPart, pShape->Get_Type()); } pPart->Del_Parts(); } } return( true ); } //--------------------------------------------------------- bool CSG_Network::_Add_Line(CSG_Shape *pLine, int ID) { int iEdge, iPoint, iCrossing; CSG_Shape *pEdge, *pCrossing; CSG_Shapes Crossings(SHAPE_TYPE_Point); //----------------------------------------------------- // 1. find crossings Crossings.Add_Field(SG_T("LINE_POINT") , SG_DATATYPE_Int); Crossings.Add_Field(SG_T("EDGE_ID") , SG_DATATYPE_Int); Crossings.Add_Field(SG_T("EDGE_POINT") , SG_DATATYPE_Int); Crossings.Add_Field(SG_T("EDGE_DIST") , SG_DATATYPE_Double); for(iEdge=0; iEdgeIntersects(pLine) ) { TSG_Point a = pEdge->Get_Point(0); for(int iEdge_Point=1; iEdge_PointGet_Point_Count(0); iEdge_Point++) { TSG_Point b = a; a = pEdge->Get_Point(iEdge_Point); TSG_Point A = pLine->Get_Point(0); for(iPoint=1; iPointGet_Point_Count(0); iPoint++) { TSG_Point C, B = A; A = pLine->Get_Point(iPoint); if( SG_Get_Crossing(C, A, B, a, b) ) { pCrossing = Crossings.Add_Shape(); pCrossing->Add_Point(C); pCrossing->Set_Value(0, iPoint); pCrossing->Set_Value(1, iEdge); pCrossing->Set_Value(2, iEdge_Point); pCrossing->Set_Value(3, SG_Get_Distance(C, b)); } } } } } //----------------------------------------------------- // 2. add new line's vertices Crossings.Set_Index(0, TABLE_INDEX_Ascending); pEdge = m_Edges.Add_Shape(); pEdge ->Set_Value(3, ID); for(iCrossing=0, iPoint=0; iCrossingasInt(0) ) { pEdge->Add_Point(pLine->Get_Point(iPoint++)); } pEdge->Add_Point(pCrossing->Get_Point(0)); pEdge = m_Edges.Add_Shape(); pEdge ->Set_Value(3, ID); pEdge ->Add_Point(pCrossing->Get_Point(0)); } while( iPoint < pLine->Get_Point_Count(0) ) { pEdge->Add_Point(pLine->Get_Point(iPoint++)); } //----------------------------------------------------- // 3. split edges, if necessary Crossings.Set_Index(1, TABLE_INDEX_Descending, 2, TABLE_INDEX_Ascending, 3, TABLE_INDEX_Ascending); for(iCrossing=0; iCrossingasInt(1); pLine = m_Edges.Get_Shape(iEdge); ID = pLine->asInt(0); iPoint = 0; pEdge = m_Edges.Add_Shape(); pEdge ->Set_Value(3, pLine->asInt(3)); while( 1 ) { while( iPoint < pCrossing->asInt(2) ) { pEdge->Add_Point(pLine->Get_Point(iPoint++)); } pEdge->Add_Point(pCrossing->Get_Point(0)); if( ++iCrossing < Crossings.Get_Count() && iEdge == Crossings.Get_Shape_byIndex(iCrossing)->asInt(1) ) { pEdge = m_Edges.Add_Shape(); pEdge ->Set_Value(3, pLine->asInt(3)); pEdge->Add_Point(pCrossing->Get_Point(0)); pCrossing = Crossings.Get_Shape_byIndex(iCrossing); } else { if( iPoint < pLine->Get_Point_Count() ) { pEdge = m_Edges.Add_Shape(); pEdge ->Set_Value(3, pLine->asInt(3)); pEdge->Add_Point(pCrossing->Get_Point(0)); while( iPoint < pLine->Get_Point_Count() ) { pEdge->Add_Point(pLine->Get_Point(iPoint++)); } } break; } } m_Edges.Del_Shape(iEdge); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Network::Update(void) { int iEdge; //----------------------------------------------------- for(iEdge=m_Edges.Get_Count()-1; iEdge>=0; iEdge--) { CSG_Shape *pEdge = m_Edges.Get_Shape(iEdge); if( !(((CSG_Shape_Line *)pEdge)->Get_Length() > 0.0) ) { m_Edges.Del_Shape(iEdge); } } //----------------------------------------------------- for(int i=0; iSet_Value(0, iEdge); pEdge->Set_Value(1, _Add_Node(Search, iEdge, pEdge->Get_Point(0), pEdge->Get_Point(1) )); pEdge->Set_Value(2, _Add_Node(Search, iEdge, pEdge->Get_Point(pEdge->Get_Point_Count(0) - 1), pEdge->Get_Point(pEdge->Get_Point_Count(0) - 2) )); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- int CSG_Network::_Add_Node(CSG_PRQuadTree &Search, int Edge_ID, const TSG_Point &Node_Point, const TSG_Point &Dir_Point) { int Node_ID; double Distance; CSG_PRQuadTree_Leaf *pLeaf = Search.Get_Nearest_Leaf(Node_Point, Distance); if( !pLeaf || Distance > 0.0 )//00001 ) { Node_ID = Get_Node_Count(); m_Nodes.Inc_Array(); ((CSG_Network_Node **)m_Nodes.Get_Array())[Node_ID] = new CSG_Network_Node(Node_ID, Node_Point); Search.Add_Point(Node_Point.x, Node_Point.y, Node_ID); } else { Node_ID = (int)pLeaf->Get_Z(); } Get_Node(Node_ID).Add_Edge(Edge_ID, SG_Get_Angle_Of_Direction(Node_Point, Dir_Point)); return( Node_ID ); } //--------------------------------------------------------- bool CSG_Network::Remove_End_Nodes(void) { int iEdge, n; //----------------------------------------------------- for(iEdge=0; iEdgeasInt(3) == SHAPE_TYPE_Line ) { bool bRemove = false; for(int iNode=1; iNode<=2 && !bRemove; iNode++) { CSG_Network_Node &Node = Get_Node(pEdge->asInt(iNode)); CSG_Point Point = Node.Get_Point(); CSG_Shape *pNext; if( ( (pNext = m_Edges.Get_Shape(Node.Get_Edge_Next(pEdge->asInt(0), true))) != NULL && pNext->asInt(3) == SHAPE_TYPE_Polygon && !Point.is_Equal(pNext->Get_Point(0, 0, false)) ) || ( (pNext = m_Edges.Get_Shape(Node.Get_Edge_Next(pEdge->asInt(0), false))) != NULL && pNext->asInt(3) == SHAPE_TYPE_Polygon && !Point.is_Equal(pNext->Get_Point(0, 0, true)) ) ) { bRemove = true; } } if( bRemove ) { Get_Node(pEdge->asInt(1)).Del_Edge(pEdge->asInt(0)); Get_Node(pEdge->asInt(2)).Del_Edge(pEdge->asInt(0)); pEdge->Set_Value(4, 1); } } } //----------------------------------------------------- do { for(n=0, iEdge=0; iEdgeasInt(3) == SHAPE_TYPE_Line && pEdge->asInt(4) == 0 ) { if( Get_Node(pEdge->asInt(1)).Get_Edge_Count() <= 1 || Get_Node(pEdge->asInt(2)).Get_Edge_Count() <= 1 ) { Get_Node(pEdge->asInt(1)).Del_Edge(pEdge->asInt(0)); Get_Node(pEdge->asInt(2)).Del_Edge(pEdge->asInt(0)); pEdge->Set_Value(4, 1); n++; } } } } while( n > 0 ); //----------------------------------------------------- for(iEdge=m_Edges.Get_Count()-1; iEdge>=0; iEdge--) { if( m_Edges[iEdge][4] ) { m_Edges.Del_Shape(iEdge); } } //----------------------------------------------------- return( Update() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Line_Intersection::CPolygon_Line_Intersection(void) { //----------------------------------------------------- Set_Name (_TL("Polygon-Line Intersection")); Set_Author (SG_T("O. Conrad (c) 2011")); Set_Description (_TW( "Polygon-line intersection. Splits polygons with lines. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "INTERSECT" , _TL("Intersection"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Line_Intersection::On_Execute(void) { CSG_Shapes *pPolygons; //-------------------------------------------------------- pPolygons = Parameters("POLYGONS") ->asShapes(); m_pLines = Parameters("LINES") ->asShapes(); m_pIntersection = Parameters("INTERSECT") ->asShapes(); //-------------------------------------------------------- if( !m_pLines ->is_Valid() || m_pLines ->Get_Count() < 1 || !pPolygons->is_Valid() || pPolygons->Get_Count() < 1 || m_pLines->Get_Extent().Intersects(pPolygons->Get_Extent()) == INTERSECTION_None ) { Error_Set(_TL("no shapes for intersection found")); return( false ); } //-------------------------------------------------------- m_pIntersection->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s: %s]"), pPolygons->Get_Name(), _TL("Intersection"), m_pLines->Get_Name()), pPolygons ); //-------------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { if( !Get_Intersection((CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon)) ) { m_pIntersection->Add_Shape(pPolygons->Get_Shape(iPolygon)); } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool Trace_Polygon(CSG_Shape *pPolygon, CSG_Network &Network, int iEdge) { bool bAscending = true; CSG_Shape *pEdge = Network.Get_Edges().Get_Shape(iEdge); if( pEdge->asInt(3) == SHAPE_TYPE_Polygon ) { if( pEdge->asInt(4) ) { return( false ); } bAscending = true; } else if( (pEdge->asInt(4) & 0x1) == 0 ) { bAscending = true; } else if( (pEdge->asInt(4) & 0x2) == 0 ) { bAscending = false; } else { return( false ); } while( pEdge != NULL ) { pEdge->Set_Value(4, pEdge->asInt(4) | (bAscending ? 0x1 : 0x2)); for(int iPoint=0; iPointGet_Point_Count(0); iPoint++) { pPolygon->Add_Point(pEdge->Get_Point(iPoint, 0, bAscending)); } int End_Node = pEdge->asInt(bAscending ? 2 : 1); iEdge = Network.Get_Node(End_Node).Get_Edge_Next(iEdge, false); pEdge = Network.Get_Edges().Get_Shape(iEdge); if( pEdge ) { bAscending = pEdge->asInt(3) == SHAPE_TYPE_Polygon || End_Node == pEdge->asInt(1); if( (pEdge->asInt(4) & (bAscending ? 0x1 : 0x2)) ) { pEdge = NULL; } } } return( pPolygon->is_Valid() ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Line_Intersection::Get_Intersection(CSG_Shape_Polygon *pPolygon) { CSG_Network Network; for(int iLine=0; iLineGet_Count(); iLine++) { CSG_Shape *pLine = m_pLines->Get_Shape(iLine); if( pLine->Intersects(pPolygon) ) { Network.Add_Shape(pLine); } } if( Network.Get_Edges().Get_Count() == 0 ) { return( false ); } Network.Add_Shape(pPolygon); Network.Update(); Network.Remove_End_Nodes(); //----------------------------------------------------- int iEdge, iPolygon; CSG_Shapes Intersection(SHAPE_TYPE_Polygon); Intersection.Add_Field(SG_T("ID"), SG_DATATYPE_Int); for(iEdge=0; iEdgeasInt(3) == SHAPE_TYPE_Polygon ) { Trace_Polygon(Intersection.Add_Shape(), Network, iEdge); } else if( pPolygon->Contains(pEdge->Get_Point(0)) && pPolygon->Contains(pEdge->Get_Point(pEdge->Get_Point_Count(0) - 1)) ) { Trace_Polygon(Intersection.Add_Shape(), Network, iEdge); Trace_Polygon(Intersection.Add_Shape(), Network, iEdge); } } //----------------------------------------------------- for(iPolygon=0; iPolygonGet_Point_Count() > 0 && ((CSG_Shape_Polygon *)pIntersect)->is_Clockwise(0) == true ) { pIntersect->Set_Value(0, m_pIntersection->Get_Count()); ((CSG_Table_Record *)m_pIntersection->Add_Shape(pIntersect, SHAPE_COPY_GEOM))->Assign(pPolygon); } } for(iPolygon=0; iPolygonGet_Point_Count() > 0 && ((CSG_Shape_Polygon *)pIntersect)->is_Clockwise(0) == false ) { for(int j=0; jContains(pIntersect->Get_Point(0)) ) { CSG_Shape *pShape = m_pIntersection->Get_Shape(Intersection[j].asInt(0)); for(int iPoint=0, iPart=pShape->Get_Part_Count(); iPointGet_Point_Count(0); iPoint++) { pShape->Add_Point(pIntersect->Get_Point(iPoint), iPart); } break; } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// /*/--------------------------------------------------------- { //----------------------------------------------------- CSG_Shapes p(SHAPE_TYPE_Point); p.Add_Field(SG_T("ID") , SG_DATATYPE_Int); p.Add_Field(SG_T("COUNT"), SG_DATATYPE_Int); for(int i=0; iAdd_Point(Network.Get_Node(i).Get_Point()); pNode->Set_Value(0, Network.Get_Node(i).Get_ID()); pNode->Set_Value(1, Network.Get_Node(i).Get_Edge_Count()); } DataObject_Add(SG_Create_Shapes(p)); DataObject_Add(SG_Create_Shapes(Network.Get_Edges())); //----------------------------------------------------- CSG_Shapes l(SHAPE_TYPE_Line); l.Add_Field(SG_T("ID") , SG_DATATYPE_Int); l.Add_Field(SG_T("COUNT"), SG_DATATYPE_Int); l.Add_Field(SG_T("EDGE") , SG_DATATYPE_Int); l.Add_Field(SG_T("DIR") , SG_DATATYPE_Double); l.Add_Field(SG_T("ORDER"), SG_DATATYPE_Int); for(int i=0; iSet_Value(0, Network.Get_Node(i).Get_ID()); pNode->Set_Value(1, Network.Get_Node(i).Get_Edge_Count()); pNode->Set_Value(2, Network.Get_Node(i).Get_Edge(j)); pNode->Set_Value(3, Network.Get_Node(i).Get_Direction(j) * M_RAD_TO_DEG); pNode->Set_Value(4, j); pNode->Add_Point(P); pNode->Add_Point( P.x + 10.0 * sin(Network.Get_Node(i).Get_Direction(j)), P.y + 10.0 * cos(Network.Get_Node(i).Get_Direction(j)) ); } } //----------------------------------------------------- CSG_Shapes p(SHAPE_TYPE_Point); p.Add_Field(SG_T("COUNT"), SG_DATATYPE_Int); for(int i=0; iAdd_Point(Network.Get_Node(i).Get_Point()); pNode->Set_Value(0, Network.Get_Node(i).Get_Edge_Count()); } DataObject_Add(SG_Create_Shapes(p)); }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_to_edges_nodes.cpp0000664000175000017500000002220612565125410027765 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_to_edges_nodes.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_to_edges_nodes.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_to_edges_nodes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_to_Edges_Nodes::CPolygon_to_Edges_Nodes(void) { //----------------------------------------------------- Set_Name (_TL("Polygons to Edges and Nodes")); Set_Author (SG_T("O. Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "EDGES" , _TL("Edges"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "NODES" , _TL("Nodes"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_to_Edges_Nodes::On_Execute(void) { CSG_Shapes *pPolygons; pPolygons = Parameters("POLYGONS") ->asShapes(); m_pEdges = Parameters("EDGES") ->asShapes(); m_pNodes = Parameters("NODES") ->asShapes(); if( !m_Vertices.Create(pPolygons, -1) ) { Error_Set(_TL("initialisation error")); return( false ); } //----------------------------------------------------- m_pEdges->Create(SHAPE_TYPE_Line , CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Edges"))); m_pEdges->Add_Field(_TL("ID") , SG_DATATYPE_Int); m_pEdges->Add_Field(_TL("NODE_A"), SG_DATATYPE_Int); m_pEdges->Add_Field(_TL("NODE_B"), SG_DATATYPE_Int); m_pEdges->Add_Field(_TL("FACE_A"), SG_DATATYPE_Int); m_pEdges->Add_Field(_TL("FACE_B"), SG_DATATYPE_Int); m_pNodes->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Nodes"))); m_pNodes->Add_Field(_TL("ID") , SG_DATATYPE_Int); m_pNodes->Add_Field(_TL("COUNT") , SG_DATATYPE_Int); m_pNodes->Add_Field(_TL("EDGES") , SG_DATATYPE_String); m_Nodes.Create(pPolygons->Get_Extent()); //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(iPolygon); for(int iPart=0, iPoint; iPartGet_Part_Count(); iPart++) { if( !Find_Node(pPolygon, iPart, iPoint = 0) ) { CSG_Shape *pEdge = m_pEdges->Add_Shape(); for(iPoint=0; iPointGet_Point_Count(); iPoint++) { pEdge->Add_Point(pPolygon->Get_Point(iPoint, iPart)); } } else { do { Trace_Edge(pPolygon, iPart, iPoint); } while( Find_Node(pPolygon, iPart, ++iPoint) ); } } } //----------------------------------------------------- m_Vertices .Destroy(); m_Nodes .Destroy(); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_to_Edges_Nodes::Find_Node(CSG_Shape *pPolygon, int iPart, int &iPoint) { for( ; iPointGet_Point_Count(iPart); iPoint++) { double Distance; CSG_PRQuadTree_Leaf *pLeaf = m_Vertices.Get_Nearest_Leaf(pPolygon->Get_Point(iPoint, iPart), Distance); if( pLeaf->has_Statistics() && ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Count() > 2 ) { return( true ); } } return( false ); } //--------------------------------------------------------- bool CPolygon_to_Edges_Nodes::Trace_Edge(CSG_Shape *pPolygon, int iPart, int aPoint) { CSG_Shape *pEdge = m_pEdges->Add_Shape(); for(int iPoint=aPoint; pEdge->Get_Point_Count(0)Get_Point_Count(iPart); iPoint=iPointGet_Point_Count(iPart)-1 ? iPoint+1 : 0) { double Distance; CSG_PRQuadTree_Leaf *pLeaf = m_Vertices.Get_Nearest_Leaf(pPolygon->Get_Point(iPoint, iPart), Distance); pEdge->Add_Point(pPolygon->Get_Point(iPoint, iPart)); if( iPoint != aPoint && pLeaf->has_Statistics() ) { if( ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Count() > 2 ) // Node { TSG_Point A = pPolygon->Get_Point(aPoint, iPart); TSG_Point B = pPolygon->Get_Point(iPoint, iPart); if( pEdge->Get_Point_Count(0) > 2 || (A.x != B.x || A.y != B.y) ) { int Node_A = Add_Node(A, pEdge->Get_Index()); int Node_B = Add_Node(B, pEdge->Get_Index()); pEdge->Set_Value(0, pEdge->Get_Index()); pEdge->Set_Value(1, Node_A < Node_B ? Node_A : Node_B); pEdge->Set_Value(2, Node_A < Node_B ? Node_B : Node_A); pEdge->Set_Value(3, pPolygon->Get_Index()); return( true ); } m_pEdges->Del_Shape(pEdge); return( false ); } } } m_pEdges->Del_Shape(pEdge); return( false ); } //--------------------------------------------------------- int CPolygon_to_Edges_Nodes::Add_Node(TSG_Point &Point, int Edge_ID) { int Node_ID; double Distance; CSG_Shape *pNode; CSG_PRQuadTree_Leaf *pLeaf = m_Nodes.Get_Nearest_Leaf(Point, Distance); if( !pLeaf || Distance > 0.0 ) { Node_ID = m_pNodes->Get_Count(); pNode = m_pNodes->Add_Shape(); pNode ->Set_Value(0, Node_ID); pNode ->Set_Value(1, 1); pNode ->Set_Value(2, CSG_String::Format(SG_T("%d"), Edge_ID)); pNode ->Set_Value(3, -1); pNode ->Add_Point(Point); m_Nodes.Add_Point(Point.x, Point.y, Node_ID); } else { Node_ID = (int)pLeaf->Get_Z(); pNode = m_pNodes->Get_Shape(Node_ID); pNode ->Add_Value(1, 1); pNode ->Set_Value(2, CSG_String::Format(SG_T("%s|%d"), pNode->asString(2), Edge_ID)); } return( pNode->Get_Index() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.h0000664000175000017500000000527712565125410030575 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_StatisticsFromPoints.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* PolygonStatisticsFromPoints.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PolygonStatisticsFromPoints_H #define HEADER_INCLUDED__PolygonStatisticsFromPoints_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygonStatisticsFromPoints : public CSG_Module { public: CPolygonStatisticsFromPoints(void); protected: virtual bool On_Execute (void); private: CSG_String Get_Field_Name (const CSG_String &Type, const CSG_String &Name); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PolygonStatisticsFromPoints_H saga-2.2.3/src/modules/shapes/shapes_polygons/add_point_attributes.h0000664000175000017500000001004512565125410027107 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: add_point_attributes.h 1958 2014-02-03 12:40:27Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // add_point_attributes.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__add_point_attributes_H #define HEADER_INCLUDED__add_point_attributes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CAdd_Point_Attributes : public CSG_Module { public: CAdd_Point_Attributes(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__add_point_attributes_H saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_SelfIntersection.cpp0000664000175000017500000001745712565125410030240 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_SelfIntersection.cpp 1230 2011-11-22 11:12:10Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_SelfIntersection.cpp // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_SelfIntersection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_SelfIntersection::CPolygon_SelfIntersection(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Polygon Self-Intersection")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Self-intersection of one layer's polygons.\n" "Uses the free and open source software library Clipper created by Angus Johnson.\n" "Clipper Homepage\n" "Clipper at SourceForge\n" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field( pNode , "ID" , _TL("Identifier"), _TL(""), true ); Parameters.Add_Shapes( NULL , "INTERSECT" , _TL("Intersection"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_SelfIntersection::On_Execute(void) { int ID; CSG_Shapes *pPolygons, Intersect; pPolygons = Parameters("POLYGONS" )->asShapes(); m_pIntersect = Parameters("INTERSECT")->asShapes() ? Parameters("INTERSECT")->asShapes() : &Intersect; ID = Parameters("ID")->asInt(); if( ID >= pPolygons->Get_Field_Count() ) { ID = -1; } m_pIntersect->Create(SHAPE_TYPE_Polygon, pPolygons->Get_Name(), pPolygons); m_pIntersect->Add_Field("ID", SG_DATATYPE_String); //----------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pPolygons->Get_Count()); i++) { Add_Polygon(pPolygons->Get_Shape(i), ID); } //----------------------------------------------------- if( m_pIntersect->Get_Count() != pPolygons->Get_Count() ) { Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("number of added polygons"), m_pIntersect->Get_Count() - pPolygons->Get_Count())); if( m_pIntersect == &Intersect ) { pPolygons->Create(Intersect); DataObject_Update(pPolygons); } else { m_pIntersect->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("self-intersection"))); } } else { Message_Add(_TL("no self-intersecting polygons detected")); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPolygon_SelfIntersection::Add_Polygon(CSG_Shape *pPolygon, int ID) { CSG_String sID; if( ID >= 0 ) { sID = pPolygon->asString(ID); } else { sID = SG_Get_String(pPolygon->Get_Index() + 1, 0); } ID = m_pIntersect->Get_Field_Count() - 1; //----------------------------------------------------- if( !m_pIntersect->Select(pPolygon->Get_Extent()) ) { pPolygon = m_pIntersect->Add_Shape(pPolygon); pPolygon ->Set_Value(ID, sID); return; } //----------------------------------------------------- CSG_Shapes Intersect(m_pIntersect->Get_Type(), SG_T(""), m_pIntersect); int nIntersects = m_pIntersect->Get_Count(); pPolygon = m_pIntersect->Add_Shape(pPolygon); pPolygon ->Set_Value(ID, sID); for(int i=0; iis_Valid(); i++) { if( pPolygon != m_pIntersect->Get_Shape(i) && pPolygon->Intersects(m_pIntersect->Get_Shape(i)) ) { CSG_Shape *pOriginal = Intersect.Add_Shape(m_pIntersect->Get_Shape(i)); CSG_Shape *pIntersect = Intersect.Add_Shape(); if( SG_Polygon_Intersection(pOriginal, pPolygon, pIntersect) ) { pIntersect = m_pIntersect->Add_Shape(pIntersect); pIntersect ->Set_Value(ID, CSG_String::Format(SG_T("%s|%s"), pPolygon->asString(ID), pOriginal->asString(ID))); SG_Polygon_Difference(m_pIntersect->Get_Shape(i), pPolygon); SG_Polygon_Difference(pPolygon, pOriginal); } Intersect.Del_Shapes(); } } m_pIntersect->Select(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_to_edges_nodes.h0000664000175000017500000001105412565125410027431 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_to_edges_nodes.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_to_edges_nodes.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__polygon_to_edges_nodes_H #define HEADER_INCLUDED__polygon_to_edges_nodes_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_to_Edges_Nodes : public CSG_Module { public: CPolygon_to_Edges_Nodes(void); protected: virtual bool On_Execute (void); private: CSG_PRQuadTree m_Vertices, m_Nodes; CSG_Shapes *m_pEdges, *m_pNodes; bool Find_Node (CSG_Shape *pPolygon, int iPart, int &iPoint); bool Trace_Edge (CSG_Shape *pPolygon, int iPart, int iPoint); int Add_Node (TSG_Point &Point, int Edge_ID); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__polygon_to_edges_nodes_H saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_shared_edges.cpp0000664000175000017500000003703612565125410027430 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_shared_edges.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_shared_edges.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_shared_edges.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Shared_Edges::CPolygon_Shared_Edges(void) { //----------------------------------------------------- Set_Name (_TL("Shared Polygon Edges")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field( pNode , "ATTRIBUTE" , _TL("Attribute"), _TL(""), true ); Parameters.Add_Shapes( NULL , "EDGES" , _TL("Edges"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); // Parameters.Add_Shapes( // NULL , "NODES" , _TL("Nodes"), // _TL(""), // PARAMETER_OUTPUT, SHAPE_TYPE_Point // ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Tolerance"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Value( NULL , "VERTICES" , _TL("Check Vertices"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "DOUBLE" , _TL("Double Edges"), _TL("give output of an edge twice, i.e. once for each of the two adjacent polygons"), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Shared_Edges::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); m_Field = Parameters("ATTRIBUTE")->asInt(); m_pEdges = Parameters("EDGES")->asShapes(); m_pEdges->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Edges"))); m_pEdges->Add_Field("ID_A", m_Field < 0 ? SG_DATATYPE_Int : pPolygons->Get_Field_Type(m_Field)); m_pEdges->Add_Field("ID_B", m_Field < 0 ? SG_DATATYPE_Int : pPolygons->Get_Field_Type(m_Field)); // m_pNodes = Parameters("NODES")->asShapes(); // m_pNodes->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Nodes"))); // m_pNodes->Add_Field("ID", SG_DATATYPE_Int); bool bVertices = Parameters("VERTICES")->asBool (); double Epsilon = Parameters("EPSILON" )->asDouble(); int iPolygon, nAdded = 0, nRemoved = 0; //----------------------------------------------------- if( bVertices ) { for(iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); for(int iPart=0; iPartGet_Part_Count() && Process_Get_Okay(); iPart++) { CSG_Shape_Part *pPart = pPolygon->Get_Part(iPart); CSG_Point A = pPart->Get_Point(pPart->Get_Count() - 1); if( A != pPart->Get_Point(0) ) { pPart->Add_Point(A); } for(int iPoint=pPart->Get_Count()-2; iPoint>=0; iPoint--) { CSG_Point B = A; A = pPart->Get_Point(iPoint); if( A == B ) { pPart->Del_Point(iPoint + 1); nRemoved--; } } } } } //----------------------------------------------------- for(iPolygon=0; iPolygonGet_Count()-1 && Set_Progress(iPolygon, pPolygons->Get_Count()-1); iPolygon++) { CSG_Shape_Polygon *pA = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); for(int jPolygon=iPolygon+1; jPolygonGet_Count() && Process_Get_Okay(); jPolygon++) { CSG_Shape_Polygon *pB = (CSG_Shape_Polygon *)pPolygons->Get_Shape(jPolygon); for(int iPart=0; iPartGet_Part_Count() && Process_Get_Okay(); iPart++) { for(int jPart=0; jPartGet_Part_Count() && Process_Get_Okay(); jPart++) { if( pA->Get_Part(iPart)->Get_Extent().Intersects(pB->Get_Part(jPart)->Get_Extent()) ) { if( bVertices ) { nAdded += Check_Vertices(pA->Get_Part(iPart), pB->Get_Part(jPart), Epsilon); nAdded += Check_Vertices(pB->Get_Part(jPart), pA->Get_Part(iPart), Epsilon); } Get_Shared_Edges(pA->Get_Part(iPart), pB->Get_Part(jPart), Epsilon); } } } } } //----------------------------------------------------- if( Parameters("DOUBLE")->asBool() ) { for(int iEdge=0, nEdges=m_pEdges->Get_Count(); iEdgeGet_Shape(iEdge); CSG_Shape *pB = m_pEdges->Add_Shape(pA); *(pB->Get_Value(0)) = *(pA->Get_Value(1)); *(pB->Get_Value(1)) = *(pA->Get_Value(0)); } } //----------------------------------------------------- if( nAdded > 0 || nRemoved > 0 ) { Message_Add(CSG_String::Format(SG_T("\n%s: %d %s, %d %s\n"), _TL("Vertices"), nAdded , _TL("added" ), nRemoved, _TL("removed") ), false); DataObject_Update(pPolygons); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Shared_Edges::Get_Shared_Edges(CSG_Shape_Part *pA, CSG_Shape_Part *pB, double Epsilon) { int Edge_1st = m_pEdges->Get_Count(); CSG_Shape *pEdge = NULL; for(int iPoint=0, jPoint; iPointGet_Count(); iPoint++) { CSG_Point Point = pA->Get_Point(iPoint); if( !pEdge ) { for(jPoint=0; jPointGet_Count(); jPoint++) { if( Point.is_Equal(pB->Get_Point(jPoint), Epsilon) ) { pEdge = m_pEdges->Add_Shape(); pEdge ->Add_Point(Point); if( m_Field < 0 ) { pEdge->Set_Value(0, pA->Get_Owner()->Get_Index()); pEdge->Set_Value(1, pB->Get_Owner()->Get_Index()); } else { pEdge->Set_Value(0, pA->Get_Owner()->asString(m_Field)); pEdge->Set_Value(1, pB->Get_Owner()->asString(m_Field)); } break; } } } else { int j = jPoint; if( Point.is_Equal(pB->Get_Point(jPoint = Get_Next_Vertex(pB, j, false)), Epsilon) || Point.is_Equal(pB->Get_Point(jPoint = Get_Next_Vertex(pB, j, true )), Epsilon) ) { pEdge->Add_Point(Point); } else { pEdge = NULL; } } } //----------------------------------------------------- if( pEdge ) { CSG_Shape *pEdge_1st = m_pEdges->Get_Shape(Edge_1st); if( pEdge != pEdge_1st && SG_Is_Equal(pA->Get_Point(0), pEdge_1st->Get_Point(0)) ) { for(int i=0; iGet_Point_Count(0); i++) { pEdge->Add_Point(pEdge_1st->Get_Point(i)); } m_pEdges->Del_Shape(Edge_1st); } } //----------------------------------------------------- for(int iEdge=m_pEdges->Get_Count()-1; iEdge>=Edge_1st; iEdge--) { if( m_pEdges->Get_Shape(iEdge)->Get_Point_Count() <= 1 ) // touches at point { m_pEdges->Del_Shape(iEdge); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- int CPolygon_Shared_Edges::Get_Next_Vertex(CSG_Shape_Part *pPoints, int iPoint, bool bAscending) { if( bAscending ) { if( iPoint < pPoints->Get_Count() - 1 ) { iPoint ++; } else { iPoint = 1; } } else { if( iPoint > 0 ) { iPoint --; } else { iPoint = pPoints->Get_Count() - 2; } } return( iPoint ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPolygon_Shared_Edges::Check_Vertices(CSG_Shape_Part *pPolygon, CSG_Shape_Part *pVertices, double Epsilon) { int nAdded = 0; TSG_Point A = pPolygon->Get_Point(0, false); for(int iPoint=0; iPointGet_Count(); iPoint++) { TSG_Point B = A; A = pPolygon->Get_Point(iPoint); for(int iVertex=0; iVertexGet_Count(); iVertex++) { TSG_Point Vertex = pVertices->Get_Point(iVertex); if( (SG_Is_Between(Vertex.x, A.x, B.x, Epsilon) && SG_Is_Between(Vertex.y, A.y, B.y, Epsilon)) && !SG_Is_Equal(Vertex, A, Epsilon) && !SG_Is_Equal(Vertex, B, Epsilon) && SG_Is_Point_On_Line(Vertex, A, B, true, Epsilon) ) { pPolygon->Ins_Point(Vertex, iPoint++); nAdded++; } } } return( nAdded ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Vertex_Check::CPolygon_Vertex_Check(void) { //----------------------------------------------------- Set_Name (_TL("Polygon Vertex Check")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "CHECKED" , _TL("Checked"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "ADDED" , _TL("Added"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Tolerance"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Vertex_Check::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( Parameters("CHECKED")->asShapes() && Parameters("CHECKED")->asShapes() != pPolygons ) { CSG_Shapes *pCopy = Parameters("CHECKED")->asShapes(); pCopy->Create(*pPolygons); pCopy->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("checked"))); pPolygons = pCopy; } if( (m_pAdded = Parameters("ADDED")->asShapes()) != NULL ) { m_pAdded->Create(SHAPE_TYPE_Point, _TL("Added")); } double Epsilon = Parameters("EPSILON")->asDouble(); //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count()-1 && Set_Progress(iPolygon, pPolygons->Get_Count()-1); iPolygon++) { CSG_Shape_Polygon *pA = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); for(int jPolygon=iPolygon+1; jPolygonGet_Count() && Process_Get_Okay(); jPolygon++) { CSG_Shape_Polygon *pB = (CSG_Shape_Polygon *)pPolygons->Get_Shape(jPolygon); for(int iPart=0; iPartGet_Part_Count() && Process_Get_Okay(); iPart++) { for(int jPart=0; jPartGet_Part_Count() && Process_Get_Okay(); jPart++) { if( pA->Get_Part(iPart)->Get_Extent().Intersects(pB->Get_Part(jPart)->Get_Extent()) ) { Check_Vertices(pA->Get_Part(iPart), pB->Get_Part(jPart), Epsilon); Check_Vertices(pB->Get_Part(jPart), pA->Get_Part(iPart), Epsilon); } } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Vertex_Check::Check_Vertices(CSG_Shape_Part *pPolygon, CSG_Shape_Part *pVertices, double Epsilon) { TSG_Point A = pPolygon->Get_Point(0, false); for(int iPoint=0; iPointGet_Count(); iPoint++) { TSG_Point B = A; A = pPolygon->Get_Point(iPoint); for(int iVertex=0; iVertexGet_Count(); iVertex++) { TSG_Point Vertex = pVertices->Get_Point(iVertex); if( (SG_Is_Between(Vertex.x, A.x, B.x, Epsilon) && SG_Is_Between(Vertex.y, A.y, B.y, Epsilon)) && !SG_Is_Equal(Vertex, A, Epsilon) && !SG_Is_Equal(Vertex, B, Epsilon) && SG_Is_Point_On_Line(Vertex, A, B, true, Epsilon) ) { pPolygon->Ins_Point(Vertex, iPoint++); if( m_pAdded ) { m_pAdded->Add_Shape()->Add_Point(Vertex); } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_Intersection.h0000664000175000017500000001434412565125410027063 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Intersection.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Intersection.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Intersection_H #define HEADER_INCLUDED__Polygon_Intersection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Overlay : public CSG_Module { public: CPolygon_Overlay(const CSG_String &Name); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Overlay") ); } protected: bool Add_Description (const CSG_String &Text); bool Initialize (CSG_Shapes **ppA, CSG_Shapes **ppB, bool bBothAttributes); bool Get_Intersection (CSG_Shapes *pA, CSG_Shapes *pB); bool Get_Difference (CSG_Shapes *pA, CSG_Shapes *pB, bool bInvert = false); private: bool m_bSplit, m_bInvert; CSG_Shapes *m_pA, *m_pB, *m_pAB; CSG_Shape * Add_Polygon (int id_A, int id_B); void Add_Polygon (CSG_Shape *pShape, int id_A, int id_B = -1); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Intersection : public CPolygon_Overlay { public: CPolygon_Intersection(void); protected: virtual bool On_Execute (void); }; //--------------------------------------------------------- class CPolygon_Difference : public CPolygon_Overlay { public: CPolygon_Difference(void); protected: virtual bool On_Execute (void); }; //--------------------------------------------------------- class CPolygon_SymDifference : public CPolygon_Overlay { public: CPolygon_SymDifference(void); protected: virtual bool On_Execute (void); }; //--------------------------------------------------------- class CPolygon_Union : public CPolygon_Overlay { public: CPolygon_Union(void); protected: virtual bool On_Execute (void); }; //--------------------------------------------------------- class CPolygon_Identity : public CPolygon_Overlay { public: CPolygon_Identity(void); protected: virtual bool On_Execute (void); }; //--------------------------------------------------------- class CPolygon_Update : public CPolygon_Overlay { public: CPolygon_Update(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Intersection_H saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.cpp0000664000175000017500000002276412622617361031135 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_StatisticsFromPoints.cpp 2689 2015-11-16 12:56:48Z reklov_w $ *********************************************************/ /******************************************************************************* CPolygonStatisticsFromPoints.cpp 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 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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_StatisticsFromPoints.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygonStatisticsFromPoints::CPolygonStatisticsFromPoints(void) { CSG_Parameter *pNode; //----------------------------------------------------- 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." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL, "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("") ); Parameters.Add_Shapes( NULL, "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL, "STATISTICS" , _TL("Statistics"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value(NULL, "SUM", _TL("Sum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "AVG", _TL("Mean" ), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value(NULL, "VAR", _TL("Variance" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "DEV", _TL("Deviation"), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "MIN", _TL("Minimum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "MAX", _TL("Maximum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "NUM", _TL("Count" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Choice( NULL, "FIELD_NAME" , _TL("Field Naming"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("variable type + original name"), _TL("original name + variable type"), _TL("original name"), _TL("variable type") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygonStatisticsFromPoints::On_Execute(void) { //----------------------------------------------------- bool bSum = Parameters("SUM")->asBool(); bool bAvg = Parameters("AVG")->asBool(); bool bVar = Parameters("VAR")->asBool(); bool bDev = Parameters("DEV")->asBool(); bool bMin = Parameters("MIN")->asBool(); bool bMax = Parameters("MAX")->asBool(); bool bNum = Parameters("NUM")->asBool(); if( !bSum && !bAvg && !bVar && !bDev && !bMin && !bMax && !bNum ) { Error_Set(_TL("no target variable in selection")); return( false ); } //----------------------------------------------------- CSG_Parameter_Table_Fields *pFields = Parameters("FIELDS")->asTableFields(); if( pFields->Get_Count() <= 0 ) { Error_Set(_TL("no attributes in selection")); return( false ); } //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS" )->asShapes(); CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( pPolygons->Get_Count() <= 0 || pPoints->Get_Count() <= 0 ) { Error_Set(_TL("no records in input data")); 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(); } //----------------------------------------------------- int i, n, Offset = pPolygons->Get_Field_Count(); for(i=0; iGet_Count(); i++) { CSG_String sName = pPoints->Get_Field_Name(pFields->Get_Index(i)); if( bSum ) { pPolygons->Add_Field(Get_Field_Name("SUM", sName), SG_DATATYPE_Double); } if( bAvg ) { pPolygons->Add_Field(Get_Field_Name("AVG", sName), SG_DATATYPE_Double); } if( bVar ) { pPolygons->Add_Field(Get_Field_Name("VAR", sName), SG_DATATYPE_Double); } if( bDev ) { pPolygons->Add_Field(Get_Field_Name("DEV", sName), SG_DATATYPE_Double); } if( bMin ) { pPolygons->Add_Field(Get_Field_Name("MIN", sName), SG_DATATYPE_Double); } if( bMax ) { pPolygons->Add_Field(Get_Field_Name("MAX", sName), SG_DATATYPE_Double); } if( bNum ) { pPolygons->Add_Field(Get_Field_Name("NUM", sName), SG_DATATYPE_Long ); } } //----------------------------------------------------- CSG_Simple_Statistics *Statistics = new CSG_Simple_Statistics[pFields->Get_Count()]; for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); //------------------------------------------------- for(i=0; iGet_Count(); i++) { Statistics[i].Invalidate(); } //------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Process_Get_Okay(); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); if( pPolygon->Contains(pPoint->Get_Point(0)) ) { for(i=0; iGet_Count(); i++) { if( !pPoint->is_NoData(pFields->Get_Index(i))) { Statistics[i].Add_Value(pPoint->asDouble(pFields->Get_Index(i))); } } } } //------------------------------------------------- for(i=0, n=Offset; iGet_Count(); i++) { if( Statistics[i].Get_Count() > 0 ) { if( bSum ) { pPolygon->Set_Value (n++, Statistics[i].Get_Sum()); } if( bAvg ) { pPolygon->Set_Value (n++, Statistics[i].Get_Mean()); } if( bVar ) { pPolygon->Set_Value (n++, Statistics[i].Get_Variance()); } if( bDev ) { pPolygon->Set_Value (n++, Statistics[i].Get_StdDev()); } if( bMin ) { pPolygon->Set_Value (n++, Statistics[i].Get_Minimum()); } if( bMax ) { pPolygon->Set_Value (n++, Statistics[i].Get_Maximum()); } if( bNum ) { pPolygon->Set_Value (n++, (double)Statistics[i].Get_Count()); } } else { if( bSum ) { pPolygon->Set_NoData(n++); } if( bAvg ) { pPolygon->Set_NoData(n++); } if( bVar ) { pPolygon->Set_NoData(n++); } if( bDev ) { pPolygon->Set_NoData(n++); } if( bMin ) { pPolygon->Set_NoData(n++); } if( bMax ) { pPolygon->Set_NoData(n++); } if( bNum ) { pPolygon->Set_Value (n++, 0.0); } } } } //----------------------------------------------------- delete[](Statistics); DataObject_Update(pPolygons); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CPolygonStatisticsFromPoints::Get_Field_Name(const CSG_String &Type, const CSG_String &Name) { CSG_String s; switch( Parameters("FIELD_NAME")->asInt() ) { default: case 0: s.Printf(SG_T("%s_%s"), Type.c_str(), Name.c_str()); break; case 1: s.Printf(SG_T("%s_%s"), Name.c_str(), Type.c_str()); break; case 2: s.Printf(SG_T("%s" ), Name.c_str() ); break; case 3: s.Printf(SG_T("%s" ), Type.c_str() ); break; } return( s ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/Makefile.in0000664000175000017500000006102112622651171024576 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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_polygons DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_polygons_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_polygons_la_OBJECTS = add_point_attributes.lo \ MLB_Interface.lo Polygon_Centroids.lo Polygon_Clip.lo \ polygon_flatten.lo Polygon_Geometrics.lo \ Polygon_Intersection.lo Polygon_SelfIntersection.lo \ Polygon_StatisticsFromPoints.lo Polygon_Union.lo \ Polygons_From_Lines.lo polygon_line_intersection.lo \ polygon_shared_edges.lo polygon_split_parts.lo \ polygon_to_edges_nodes.lo polygon_to_points.lo shape_index.lo libshapes_polygons_la_OBJECTS = $(am_libshapes_polygons_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_polygons_la_SOURCES) DIST_SOURCES = $(libshapes_polygons_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 2192 2014-08-13 16:58:22Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_polygons.la libshapes_polygons_la_SOURCES = \ add_point_attributes.cpp\ MLB_Interface.cpp\ Polygon_Centroids.cpp\ Polygon_Clip.cpp\ polygon_flatten.cpp\ Polygon_Geometrics.cpp\ Polygon_Intersection.cpp\ Polygon_SelfIntersection.cpp\ Polygon_StatisticsFromPoints.cpp\ Polygon_Union.cpp\ Polygons_From_Lines.cpp\ polygon_line_intersection.cpp\ polygon_shared_edges.cpp\ polygon_split_parts.cpp\ polygon_to_edges_nodes.cpp\ polygon_to_points.cpp\ shape_index.cpp\ add_point_attributes.h\ MLB_Interface.h\ Polygon_Centroids.h\ Polygon_Clip.h\ polygon_flatten.h\ Polygon_Geometrics.h\ Polygon_Intersection.h\ Polygon_SelfIntersection.h\ Polygon_StatisticsFromPoints.h\ Polygon_Union.h\ Polygons_From_Lines.h\ polygon_line_intersection.h\ polygon_shared_edges.h\ polygon_split_parts.h\ polygon_to_edges_nodes.h\ polygon_to_points.h\ shape_index.h libshapes_polygons_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) --foreign src/modules/shapes/shapes_polygons/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_polygons/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_polygons.la: $(libshapes_polygons_la_OBJECTS) $(libshapes_polygons_la_DEPENDENCIES) $(EXTRA_libshapes_polygons_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_polygons_la_OBJECTS) $(libshapes_polygons_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Centroids.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Clip.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Geometrics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Intersection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_SelfIntersection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_StatisticsFromPoints.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Union.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygons_From_Lines.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_point_attributes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_flatten.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_line_intersection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_shared_edges.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_split_parts.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_to_edges_nodes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_to_points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_index.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_Union.h0000664000175000017500000001207312565125410025502 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Union.h 1982 2014-02-10 16:52:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Union.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Union_H #define HEADER_INCLUDED__Polygon_Union_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Dissolve : public CSG_Module { public: CPolygon_Dissolve(void); protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool m_bSUM, m_bAVG, m_bMIN, m_bMAX, m_bRNG, m_bDEV, m_bVAR, m_bLST, m_bNUM; int m_Stat_Offset; CSG_Strings m_List; CSG_Parameter_Table_Fields *m_Stat_pFields; CSG_Simple_Statistics *m_Statistics; CSG_String Get_Statistics_Name (const CSG_String &Type, const CSG_String &Name); bool Init_Statistics (CSG_Shapes *pUnions, CSG_Shapes *pPolygons); bool Add_Statistics (CSG_Shape *pUnion, CSG_Shape *pPolygon, bool bReset); bool Set_Union (CSG_Shape *pUnion, bool bDissolve); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Union_H saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_flatten.cpp0000664000175000017500000001646212565125410026450 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_flatten.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygon // // // //-------------------------------------------------------// // // // polygon_flatten.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_flatten.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Flatten::CPolygon_Flatten(void) { //----------------------------------------------------- Set_Name (_TL("Flatten Polygon Layer")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "Removes invalid polygons, i.e. polygons with less than three vertices, " "and merges polygons belonging spatially together, i.e. forming outer " "and inner rings. Inner rings are not preserved as separate polygon, " "but become new part of the polygon forming the outer ring. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Flatten::On_Execute(void) { CSG_Shapes *pShapes = Parameters("INPUT")->asShapes(); if( !pShapes->is_Valid() || pShapes->Get_Count() <= 1 ) { Message_Add(_TL("less than two polygons in layer, nothing to do!")); return( false ); } if( Parameters("OUTPUT")->asShapes() != NULL && pShapes != Parameters("OUTPUT")->asShapes() ) { pShapes = Parameters("OUTPUT")->asShapes(); pShapes->Create(*Parameters("INPUT")->asShapes()); pShapes->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("dissolved inner rings"))); } //----------------------------------------------------- int i, j, k, n; int *Container = (int *)SG_Malloc(pShapes->Get_Count() * sizeof(int)); //----------------------------------------------------- Process_Set_Text(_TL("find inner rings")); for(i=0, n=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { CSG_Shape *pShape = pShapes->Get_Shape(i); if( !pShape->is_Valid() ) { Container[i] = -2; } else { for(j=0, k=-1; k<0 && jGet_Count(); j++) { if( j > i || (j < i && Container[j] != i) ) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pShapes->Get_Shape(j); if( pPolygon->Intersects(pShape) == INTERSECTION_Contains ) { k = j; n ++; } } } Container[i] = k; } } Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("number of inner rings"), n)); if( n == 0 ) { SG_Free(Container); return( true ); } //----------------------------------------------------- Process_Set_Text(_TL("solve inner rings")); for(i=0, n=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { if( Container[i] >= 0 ) { j = Container[i]; while( Container[j] >= 0 ) { j = Container[j]; } CSG_Shape *pOuter = pShapes->Get_Shape(j); CSG_Shape *pInner = pShapes->Get_Shape(i); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0, jPart=pOuter->Get_Part_Count(); iPointGet_Point_Count(iPart); iPoint++) { pOuter->Add_Point(pInner->Get_Point(iPoint, iPart), jPart); } } pInner->Del_Parts(); // save memory n++; } } //----------------------------------------------------- Process_Set_Text(_TL("clean inner rings")); for(i=0, j=pShapes->Get_Count()-1; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++, j--) { if( Container[j] != -1 ) // valid outer ring { pShapes->Del_Shape(j); } } //----------------------------------------------------- SG_Free(Container); if( pShapes == Parameters("INPUT")->asShapes() ) { DataObject_Update(pShapes); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_line_intersection.h0000664000175000017500000001062512565125410030170 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_line_intersection.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_line_intersection.h // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__polygon_line_intersection_H #define HEADER_INCLUDED__polygon_line_intersection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Line_Intersection : public CSG_Module { public: CPolygon_Line_Intersection(void); protected: virtual bool On_Execute (void); private: CSG_Shapes *m_pLines, *m_pIntersection; bool Get_Intersection (CSG_Shape_Polygon *pPolygon); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__polygon_line_intersection_H saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_Geometrics.h0000664000175000017500000000456712565125410026524 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Geometrics.h 2072 2014-03-31 08:50:43Z reklov_w $ *********************************************************/ /******************************************************************************* Polygon_Geometrics.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Geometrics_H #define HEADER_INCLUDED__Polygon_Geometrics_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Geometrics : public CSG_Module { public: CPolygon_Geometrics(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Geometrics_H saga-2.2.3/src/modules/shapes/shapes_polygons/shape_index.cpp0000664000175000017500000001774012565125410025533 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shape_index.cpp 2099 2014-04-16 09:04:19Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Polygon // // // //-------------------------------------------------------// // // // Shape_Index.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shape_index.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShape_Index::CShape_Index(void) { //----------------------------------------------------- Set_Name (_TL("Polygon Shape Indices")); Set_Author (SG_T("(c) 2008 by O.Conrad")); Set_Description (_TW( "Various indices describing the shape of polygons. " "Based on area, perimeter, maximum distance between the vertices of a polygon.\n" "\n" " - Interior Edge Ratio (Perimeter / Area)\n" " - Shape Index (Perimeter / (2 * SquareRoot(PI * Area))\n" "\n" "References:\n" "Lang, S., Blaschke, T. (2007): Landschaftsanalyse mit GIS.\n" "\n" "Forman, R.T.T., Godron, M. (1986): Landscape Ecology. Cambridge.\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "INDEX" , _TL("Shape Index"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); } //--------------------------------------------------------- CShape_Index::~CShape_Index(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShape_Index::On_Execute(void) { CSG_Shapes *pShapes, *pIndex; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); pIndex = Parameters("INDEX") ->asShapes(); //----------------------------------------------------- if( pShapes->is_Valid() ) { int iField = pShapes->Get_Field_Count(); if( pIndex == NULL ) { pIndex = pShapes; } if( pIndex != pShapes ) { pIndex->Create(SHAPE_TYPE_Polygon, _TL("Shape Index"), pShapes); } pIndex->Add_Field(_TL("Area") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("Perimeter") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("P/A") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("P/sqrt(A)") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("Max.Distance") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("D/A") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("D/sqrt(A)") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("Shape Index") , SG_DATATYPE_Double); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape_Polygon *pShape = (CSG_Shape_Polygon *)pShapes->Get_Shape(iShape); double Area = pShape->Get_Area(); double Perimeter = pShape->Get_Perimeter(); double Distance = Get_Distance(pShape); if( Perimeter > 0.0 && Distance > 0.0 ) { if( pIndex != pShapes ) { pShape = (CSG_Shape_Polygon *)pIndex->Add_Shape(pShape, SHAPE_COPY); } pShape->Set_Value(iField + 0, Area); pShape->Set_Value(iField + 1, Perimeter); if (Area > 0.0) { pShape->Set_Value(iField + 2, Perimeter / Area); pShape->Set_Value(iField + 3, Perimeter / sqrt(Area)); } else { pShape->Set_NoData(iField + 2); pShape->Set_NoData(iField + 3); } pShape->Set_Value(iField + 4, Distance); if (Area > 0.0) { pShape->Set_Value(iField + 5, Distance / Area); pShape->Set_Value(iField + 6, Distance / sqrt(Area)); pShape->Set_Value(iField + 7, Perimeter / (2.0 * sqrt(M_PI * Area))); } else { pShape->Set_NoData(iField + 5); pShape->Set_NoData(iField + 6); pShape->Set_NoData(iField + 7); } } } if( pIndex == pShapes ) { DataObject_Update(pShapes); } return( pIndex->is_Valid() ); } //----------------------------------------------------- return( false ); } //--------------------------------------------------------- double CShape_Index::Get_Distance(CSG_Shape *pShape) { double dMax = 0.0; for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pShape->Get_Point_Count(iPart) > 2 ) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point A = pShape->Get_Point(iPoint, iPart); for(int jPoint=iPoint+1; jPointGet_Point_Count(iPart); jPoint++) { double d = SG_Get_Distance(A, pShape->Get_Point(jPoint, iPart)); if( dMax < d ) { dMax = d; } } } } } return( dMax ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_Clip.h0000664000175000017500000001150712565125410025302 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Clip.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Clip.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Clip_H #define HEADER_INCLUDED__Polygon_Clip_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Clip : public CSG_Module { public: CPolygon_Clip(void); protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool Clip_Shapes (CSG_Shapes *pClip, CSG_Shapes *pInput, CSG_Shapes *pOutput); void Clip_Points (CSG_Shapes *pClip, CSG_Shapes *pInput, CSG_Shapes *pOutput); void Clip_Lines (CSG_Shapes *pClip, CSG_Shapes *pInput, CSG_Shapes *pOutput); void Clip_Polygons (CSG_Shapes *pClip, CSG_Shapes *pInput, CSG_Shapes *pOutput); TSG_Point Get_Crossing (CSG_Shape_Polygon *pPolygon, const TSG_Point &a, const TSG_Point &b); bool Dissolve (CSG_Shapes *pPolygons, CSG_Shapes *pOutput); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Clip_H saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_Centroids.h0000664000175000017500000001062612565125410026346 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Centroids.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Centroids.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Centroids_H #define HEADER_INCLUDED__Polygon_Centroids_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Centroids : public CSG_Module { public: CPolygon_Centroids(void); virtual ~CPolygon_Centroids(void); protected: virtual bool On_Execute(void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Centroids_H saga-2.2.3/src/modules/shapes/shapes_polygons/add_point_attributes.cpp0000664000175000017500000002122112565125410027440 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: add_point_attributes.cpp 2322 2014-11-03 21:29:57Z johanvdw $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // add_point_attributes.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "add_point_attributes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CAdd_Point_Attributes::CAdd_Point_Attributes(void) { Set_Name (_TL("Add Point Attributes to Polygons")); Set_Author (SG_T("V. Wichmann (c) 2014")); Set_Description (_TW( "Spatial join for polygons. Retrieves for each polygon the selected " "attributes from that point, which is contained in the polygon. In case " "a polygon contains more than one point, the last point wins.\n" "Optionally, the module allows one to attach the geometrical properties " "(x,y(z,m)) of each point as additional attributes.\n\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Polygons"), _TL("Input polygon shapefile"), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL("Input point shapefile"), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("Attributes to add. Select none to add all") ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Result"), _TL("Optional output polygon shapefile"), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "ADD_LOCATION_INFO", _TL("Add Location Info"), _TL("Add location information from points (x,y,(z,m))"), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CAdd_Point_Attributes::On_Execute(void) { //----------------------------------------------------- bool bAddLocInfo = Parameters("ADD_LOCATION_INFO")->asBool(); //----------------------------------------------------- CSG_Shapes *pInput = Parameters("INPUT")->asShapes(); if( !pInput->is_Valid() ) { Error_Set(_TL("Invalid polygon layer.")); return( false ); } //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS")->asShapes(); if( !pPoints->is_Valid() ) { Error_Set(_TL("Invalid points layer.")); return( false ); } CSG_Parameter_Table_Fields *pFields = Parameters("FIELDS")->asTableFields(); if( pFields->Get_Count() == 0 ) // no fields specified, so add all { CSG_String sFields; for(int iField=0; iFieldGet_Field_Count(); iField++) { sFields += CSG_String::Format(SG_T("%d,"), iField); } pFields->Set_Value(sFields); } //----------------------------------------------------- CSG_Shapes *pOutput = Parameters("OUTPUT")->asShapes(); if( pOutput && pOutput != pInput ) { pOutput->Create(*pInput); } else { Parameters("OUTPUT")->Set_Value(pOutput = pInput); } pOutput->Set_Name(CSG_String::Format(SG_T("%s_%s"), pInput->Get_Name(), pPoints->Get_Name())); //----------------------------------------------------- int outField = pOutput->Get_Field_Count(); int iXField = -1; for(int iField=0; iFieldGet_Count(); iField++) { int jField = pFields->Get_Index(iField); pOutput->Add_Field(pPoints->Get_Field_Name(jField), pPoints->Get_Field_Type(jField)); } if( bAddLocInfo ) { pOutput->Add_Field(SG_T("X"), SG_DATATYPE_Float); iXField = pOutput->Get_Field_Count() - 1; pOutput->Add_Field(SG_T("Y"), SG_DATATYPE_Float); if( pPoints->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pOutput->Add_Field(SG_T("Z"), SG_DATATYPE_Float); if( pPoints->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pOutput->Add_Field(SG_T("M"), SG_DATATYPE_Float); } } } //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pOutput->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pOutput->Get_Shape(iPolygon); //------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Process_Get_Okay(); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); if( pPolygon->Contains(pPoint->Get_Point(0)) ) { for(int iField=0; iFieldGet_Count(); iField++) { int jField = pFields->Get_Index(iField); switch( pPoints->Get_Field_Type(jField) ) { case SG_DATATYPE_String: case SG_DATATYPE_Date: pPolygon->Set_Value(outField + iField, pPoint->asString(jField)); break; default: pPolygon->Set_Value(outField + iField, pPoint->asDouble(jField)); break; } } if( bAddLocInfo ) { pPolygon->Set_Value(iXField , pPoint->Get_Point(0).x); pPolygon->Set_Value(iXField + 1, pPoint->Get_Point(0).y); if( pPoints->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pPolygon->Set_Value(iXField + 2, pPoint->Get_Z(0)); if( pPoints->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pPolygon->Set_Value(iXField + 3, pPoint->Get_M(0)); } } } } } // iPoint } // iPolygon //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_shared_edges.h0000664000175000017500000001413512565125410027070 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_shared_edges.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_shared_edges.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__polygon_shared_edges_H #define HEADER_INCLUDED__polygon_shared_edges_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Shared_Edges : public CSG_Module { public: ////// public members and functions: ////////////// CPolygon_Shared_Edges(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("R:Landsat") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute (void); private: ///// private members and functions: ///////////// bool m_bDouble; int m_Field; CSG_Shapes *m_pEdges, *m_pNodes; bool Get_Shared_Edges (CSG_Shape_Part *pA, CSG_Shape_Part *pB, double Epsilon); int Get_Next_Vertex (CSG_Shape_Part *pPoints, int iPoint, bool bAscending); int Check_Vertices (CSG_Shape_Part *pPolygon, CSG_Shape_Part *pVertices, double Epsilon); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Vertex_Check : public CSG_Module { public: ////// public members and functions: ////////////// CPolygon_Vertex_Check(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("R:Landsat") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute (void); private: ///// private members and functions: ///////////// CSG_Shapes *m_pAdded; bool Check_Vertices (CSG_Shape_Part *pPolygon, CSG_Shape_Part *pVertices, double Epsilon); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__polygon_shared_edges_H saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_to_points.h0000664000175000017500000001035212565125410026466 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_to_points.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Polygon // // // //-------------------------------------------------------// // // // Polygon_To_Points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_To_Points_H #define HEADER_INCLUDED__Polygon_To_Points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_To_Points : public CSG_Module { public: CPolygon_To_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_To_Points_H saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_flatten.h0000664000175000017500000001164012565125410026106 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_flatten.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygon // // // //-------------------------------------------------------// // // // polygon_flatten.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__polygon_flatten_H #define HEADER_INCLUDED__polygon_flatten_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Flatten : public CSG_Module { public: ////// public members and functions: ////////////// CPolygon_Flatten(void); protected: /// protected members and functions: /////////// virtual bool On_Execute (void); private: ///// private members and functions: ///////////// }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__polygon_flatten_H saga-2.2.3/src/modules/shapes/shapes_polygons/MLB_Interface.cpp0000664000175000017500000001412212565125410025625 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2281 2014-10-09 15:49:41Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Polygons") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Olaya, V. Wichmann (c) 2002-14") ); case MLB_INFO_Description: return( _TL("Tools for polygons.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Polygons") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Polygon_Intersection.h" #include "Polygon_Centroids.h" #include "Polygon_Geometrics.h" #include "Polygons_From_Lines.h" #include "Polygon_StatisticsFromPoints.h" #include "Polygon_Union.h" #include "polygon_to_points.h" #include "shape_index.h" #include "polygon_line_intersection.h" #include "polygon_to_edges_nodes.h" #include "polygon_split_parts.h" #include "Polygon_Clip.h" #include "Polygon_SelfIntersection.h" #include "add_point_attributes.h" #include "polygon_flatten.h" #include "polygon_shared_edges.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 1: return( new CPolygon_Centroids ); case 2: return( new CPolygon_Geometrics ); case 3: return( new CPolygons_From_Lines ); case 4: return( new CPolygonStatisticsFromPoints ); case 5: return( new CPolygon_Dissolve ); case 6: return( new CPolygon_To_Points ); case 7: return( new CShape_Index ); case 8: return( new CPolygon_Line_Intersection ); case 9: return( new CPolygon_to_Edges_Nodes ); case 10: return( new CPolygon_Split_Parts ); case 11: return( new CPolygon_Clip ); case 12: return( new CPolygon_SelfIntersection ); case 14: return( new CPolygon_Intersection ); case 15: return( new CPolygon_Difference ); case 16: return( new CPolygon_SymDifference ); case 17: return( new CPolygon_Union ); case 18: return( new CPolygon_Update ); case 19: return( new CPolygon_Identity ); case 20: return( new CAdd_Point_Attributes ); case 21: return( new CPolygon_Flatten ); case 22: return( new CPolygon_Shared_Edges ); //----------------------------------------------------- case 23: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/shapes/shapes_polygons/Makefile.am0000664000175000017500000000251312565125410024564 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 2192 2014-08-13 16:58:22Z oconrad $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_polygons.la libshapes_polygons_la_SOURCES =\ add_point_attributes.cpp\ MLB_Interface.cpp\ Polygon_Centroids.cpp\ Polygon_Clip.cpp\ polygon_flatten.cpp\ Polygon_Geometrics.cpp\ Polygon_Intersection.cpp\ Polygon_SelfIntersection.cpp\ Polygon_StatisticsFromPoints.cpp\ Polygon_Union.cpp\ Polygons_From_Lines.cpp\ polygon_line_intersection.cpp\ polygon_shared_edges.cpp\ polygon_split_parts.cpp\ polygon_to_edges_nodes.cpp\ polygon_to_points.cpp\ shape_index.cpp\ add_point_attributes.h\ MLB_Interface.h\ Polygon_Centroids.h\ Polygon_Clip.h\ polygon_flatten.h\ Polygon_Geometrics.h\ Polygon_Intersection.h\ Polygon_SelfIntersection.h\ Polygon_StatisticsFromPoints.h\ Polygon_Union.h\ Polygons_From_Lines.h\ polygon_line_intersection.h\ polygon_shared_edges.h\ polygon_split_parts.h\ polygon_to_edges_nodes.h\ polygon_to_points.h\ shape_index.h libshapes_polygons_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_Centroids.cpp0000664000175000017500000001415312565125410026700 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Centroids.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Centroids.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Centroids.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Centroids::CPolygon_Centroids(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Polygon Centroids")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Creates a points layer containing the centroids of the input polygon layer." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "CENTROIDS" , _TL("Centroids"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); //----------------------------------------------------- pNode = Parameters.Add_Value( NULL , "METHOD" , _TL("Centroids for each part"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- } //--------------------------------------------------------- CPolygon_Centroids::~CPolygon_Centroids(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Centroids::On_Execute(void) { bool bPart; int iShape, iPart; CSG_Shape *pCentroid; CSG_Shape_Polygon *pPolygon; CSG_Shapes *pPolygons, *pCentroids; pPolygons = Parameters("POLYGONS") ->asShapes(); pCentroids = Parameters("CENTROIDS") ->asShapes(); bPart = Parameters("METHOD") ->asBool(); if( pPolygons->Get_Type() == SHAPE_TYPE_Polygon && pPolygons->Get_Count() > 0 ) { pCentroids->Create(SHAPE_TYPE_Point, pPolygons->Get_Name(), pPolygons); //------------------------------------------------- for(iShape=0; iShapeGet_Count(); iShape++) { pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iShape); if( bPart ) { for(iPart=0; iPartGet_Part_Count(); iPart++) { pCentroid = pCentroids->Add_Shape(pPolygon, SHAPE_COPY_ATTR); pCentroid->Add_Point(pPolygon->Get_Centroid(iPart)); } } else { pCentroid = pCentroids->Add_Shape(pPolygon, SHAPE_COPY_ATTR); pCentroid->Add_Point(pPolygon->Get_Centroid()); } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/polygon_to_points.cpp0000664000175000017500000001570112565125410027024 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_to_points.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Polygon // // // //-------------------------------------------------------// // // // Polygon_To_Points.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_to_points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_To_Points::CPolygon_To_Points(void) { //----------------------------------------------------- Set_Name (_TL("Convert Polygon/Line Vertices to Points")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_To_Points::On_Execute(void) { CSG_Shapes *pShapes, *pPoints; pShapes = Parameters("SHAPES") ->asShapes(); pPoints = Parameters("POINTS") ->asShapes(); //----------------------------------------------------- if( pShapes->is_Valid() ) { pPoints->Create(SHAPE_TYPE_Point, pShapes->Get_Name()); pPoints->Add_Field(SG_T("ID") , SG_DATATYPE_String); pPoints->Add_Field(SG_T("ID_SHAPE") , SG_DATATYPE_Int); pPoints->Add_Field(SG_T("ID_PART") , SG_DATATYPE_Int); pPoints->Add_Field(SG_T("ID_POINT") , SG_DATATYPE_Int); if( pShapes->Get_Type() == SHAPE_TYPE_Polygon ) { pPoints->Add_Field(SG_T("CLOCKWISE"), SG_DATATYPE_String); pPoints->Add_Field(SG_T("LAKE") , SG_DATATYPE_String); } switch( pShapes->Get_Vertex_Type() ) { case SG_VERTEX_TYPE_XY: break; case SG_VERTEX_TYPE_XYZ: pPoints->Add_Field(SG_T("Z"), SG_DATATYPE_Double); break; case SG_VERTEX_TYPE_XYZM: pPoints->Add_Field(SG_T("Z"), SG_DATATYPE_Double); pPoints->Add_Field(SG_T("M"), SG_DATATYPE_Double); break; } for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { CSG_Shape *pPoint = pPoints->Add_Shape(); pPoint->Add_Point(pShape->Get_Point(iPoint, iPart)); int n = 0; pPoint->Set_Value(n++, CSG_String::Format(SG_T("%d/%d/%d"), iShape, iPart, iPoint)); pPoint->Set_Value(n++, iShape); pPoint->Set_Value(n++, iPart); pPoint->Set_Value(n++, iPoint); if( pShapes->Get_Type() == SHAPE_TYPE_Polygon ) { pPoint->Set_Value(n++, ((CSG_Shape_Polygon *)pShape)->is_Clockwise(iPart) ? SG_T("Y") : SG_T("N")); pPoint->Set_Value(n++, ((CSG_Shape_Polygon *)pShape)->is_Lake (iPart) ? SG_T("Y") : SG_T("N")); } switch( pShapes->Get_Vertex_Type() ) { case SG_VERTEX_TYPE_XY: break; case SG_VERTEX_TYPE_XYZ: pPoint->Set_Value(n++, pShape->Get_Z(iPoint, iPart)); break; case SG_VERTEX_TYPE_XYZM: pPoint->Set_Value(n++, pShape->Get_Z(iPoint, iPart)); pPoint->Set_Value(n++, pShape->Get_M(iPoint, iPart)); break; } } } } return( pPoints->is_Valid() ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/MLB_Interface.h0000664000175000017500000000774412565125410025306 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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__shapes_polygons_H #define HEADER_INCLUDED__shapes_polygons_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef shapes_polygons_EXPORTS #define shapes_polygons_EXPORT _SAGA_DLL_EXPORT #else #define shapes_polygons_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_polygon_H saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_Intersection.cpp0000664000175000017500000003567712565125410027432 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Intersection.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Intersection.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Intersection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Overlay::CPolygon_Overlay(const CSG_String &Name) { //----------------------------------------------------- Set_Name (Name); Set_Author (SG_T("O.Conrad (c) 2003-13")); Set_Description (_TW( "Uses the free and open source software library Clipper created by Angus Johnson.\n" "Clipper Homepage\n" "Clipper at SourceForge\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "A" , _TL("Layer A"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "B" , _TL("Layer B"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "RESULT" , Name, _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "SPLIT" , _TL("Split Parts"), _TL("Set true if you want multipart polygons to become separate polygons."), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Overlay::Add_Description(const CSG_String &Text) { Set_Description(Text + "\n" + Get_Description()); return( true ); } //--------------------------------------------------------- bool CPolygon_Overlay::Initialize(CSG_Shapes **ppA, CSG_Shapes **ppB, bool bBothAttributes) { *ppA = Parameters("A")->asShapes(); if( (*ppA)->Get_Type() != SHAPE_TYPE_Polygon || !(*ppA)->is_Valid() ) return( false ); *ppB = Parameters("B")->asShapes(); if( (*ppB)->Get_Type() != SHAPE_TYPE_Polygon || !(*ppB)->is_Valid() ) return( false ); m_bSplit = Parameters("SPLIT")->asBool(); m_pA = NULL; m_pB = NULL; m_pAB = Parameters("RESULT")->asShapes(); m_pAB->Create(SHAPE_TYPE_Polygon, SG_T(""), *ppA); m_pAB->Set_Name(CSG_String::Format(SG_T("%s [%s]-[%s]"), Get_Name().c_str(), (*ppA)->Get_Name(), (*ppB)->Get_Name())); if( bBothAttributes ) { for(int i=0; i<(*ppB)->Get_Field_Count(); i++) { m_pAB->Add_Field((*ppB)->Get_Field_Name(i), (*ppB)->Get_Field_Type(i)); } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Overlay::Get_Intersection(CSG_Shapes *pA, CSG_Shapes *pB) { m_bInvert = false; m_pA = pA; m_pB = pB; CSG_Shapes Tmp(SHAPE_TYPE_Polygon); CSG_Shape *pShape_AB = Tmp.Add_Shape(); //----------------------------------------------------- for(int id_A=0; id_AGet_Count() && Set_Progress(id_A, m_pA->Get_Count()); id_A++) { if( m_pB->Select(m_pA->Get_Shape(id_A)->Get_Extent()) ) { CSG_Shape *pShape_A = m_pA->Get_Shape(id_A); for(int id_B=0; id_BGet_Selection_Count(); id_B++) { CSG_Shape *pShape_B = m_pB->Get_Selection(id_B); if( SG_Polygon_Intersection(pShape_A, pShape_B, pShape_AB) ) { Add_Polygon(pShape_AB, id_A, pShape_B->Get_Index()); } } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Overlay::Get_Difference(CSG_Shapes *pA, CSG_Shapes *pB, bool bInvert) { m_bInvert = bInvert; m_pA = pA; m_pB = pB; CSG_Shapes Tmp(SHAPE_TYPE_Polygon); CSG_Shape *pShape_A = Tmp.Add_Shape(); //----------------------------------------------------- for(int id_A=0; id_AGet_Count() && Set_Progress(id_A, m_pA->Get_Count()); id_A++) { if( m_pB->Select(m_pA->Get_Shape(id_A)->Get_Extent()) ) { int nIntersections = 0; pShape_A->Assign(m_pA->Get_Shape(id_A)); for(int id_B=0; id_BGet_Selection_Count(); id_B++) { if( SG_Polygon_Difference(pShape_A, m_pB->Get_Selection(id_B)) ) { nIntersections++; } } if( nIntersections > 0 && pShape_A->is_Valid() ) { Add_Polygon(pShape_A, id_A); } } else { Add_Polygon(m_pA->Get_Shape(id_A), id_A); } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shape * CPolygon_Overlay::Add_Polygon(int id_A, int id_B) { CSG_Shape *pOriginal, *pNew = m_pAB->Add_Shape(); if( pNew ) { if( (pOriginal = m_pA->Get_Shape(id_A)) != NULL ) { for(int i=0, j=m_bInvert ? m_pB->Get_Field_Count() : 0; iGet_Field_Count(); i++, j++) { if( pNew->Get_Value(j) ) *pNew->Get_Value(j) = *pOriginal->Get_Value(i); } } if( (pOriginal = m_pB->Get_Shape(id_B)) != NULL ) { for(int i=0, j=m_bInvert ? 0 : m_pA->Get_Field_Count(); iGet_Field_Count(); i++, j++) { if( pNew->Get_Value(j) ) *pNew->Get_Value(j) = *pOriginal->Get_Value(i); } } } return( pNew ); } //--------------------------------------------------------- void CPolygon_Overlay::Add_Polygon(CSG_Shape *pShape, int id_A, int id_B) { int iPoint, iPart, jPart, nParts; CSG_Shape *pShape_Add; for(iPart=pShape->Get_Part_Count()-1; iPart>=0; iPart--) { if( ((CSG_Shape_Polygon *)pShape)->Get_Area(iPart) <= 0.0 ) { pShape->Del_Part(iPart); } else if( pShape->Get_Point_Count(iPart) <= 3 ) { CSG_Point a(pShape->Get_Point(0, iPart)), b(pShape->Get_Point(1, iPart)), c(pShape->Get_Point(2, iPart)); if( a == b || b == c || c == a ) { pShape->Del_Part(iPart); } } } if( pShape->is_Valid() ) { if( m_bSplit && pShape->Get_Part_Count() > 1 ) { for(iPart=0; iPartGet_Part_Count(); iPart++) { if( !((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) && (pShape_Add = Add_Polygon(id_A, id_B)) != NULL ) { for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pShape_Add->Add_Point(pShape->Get_Point(iPoint, iPart), 0); } for(jPart=0, nParts=0; jPartGet_Part_Count(); jPart++) { if( ((CSG_Shape_Polygon *)pShape)->is_Lake(jPart) && ((CSG_Shape_Polygon *)pShape)->Contains(pShape->Get_Point(0, jPart), iPart) ) { nParts++; for(iPoint=0; iPointGet_Point_Count(jPart); iPoint++) { pShape_Add->Add_Point(pShape->Get_Point(iPoint, jPart), nParts); } } } } } } else if( (pShape_Add = Add_Polygon(id_A, id_B)) != NULL ) { pShape_Add->Assign(pShape, false); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Intersection::CPolygon_Intersection(void) : CPolygon_Overlay(_TL("Intersect")) { Add_Description(_TW( "Calculates the geometric intersection of the overlayed polygon layers, " "i.e. layer A and layer B." )); } //--------------------------------------------------------- bool CPolygon_Intersection::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, true) ) { return( false ); } return( Get_Intersection(pA, pB) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Difference::CPolygon_Difference(void) : CPolygon_Overlay(_TL("Difference")) { Add_Description(_TW( "Calculates the geometric difference of the overlayed polygon layers, " "i.e. layer A less layer B. Sometimes referred to as \'Erase\' command." )); } //--------------------------------------------------------- bool CPolygon_Difference::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, false) ) { return( false ); } return( Get_Difference(pA, pB) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_SymDifference::CPolygon_SymDifference(void) : CPolygon_Overlay(_TL("Symmetrical Difference")) { Add_Description(_TW( "Calculates the symmetrical geometric difference of the overlayed polygon layers, " "i.e. layer A less layer B plus layer B less layer A." )); } //--------------------------------------------------------- bool CPolygon_SymDifference::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, true) ) { return( false ); } return( Get_Difference(pA, pB) && Get_Difference(pB, pA, true) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Union::CPolygon_Union(void) : CPolygon_Overlay(_TL("Union")) { Add_Description(_TW( "Calculates the geometric union of the overlayed polygon layers, " "i.e. the intersection plus the symmetrical difference of layers A and B." )); } //--------------------------------------------------------- bool CPolygon_Union::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, true) ) { return( false ); } return( Get_Intersection(pA, pB) && Get_Difference (pA, pB) && Get_Difference (pB, pA, true) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Identity::CPolygon_Identity(void) : CPolygon_Overlay(_TL("Identity")) { Add_Description(_TW( "Calculates the geometric intersection between both layers " "and adds the difference of layer A less layer B." )); } //--------------------------------------------------------- bool CPolygon_Identity::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, true) ) { return( false ); } return( Get_Intersection(pA, pB) && Get_Difference (pA, pB) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Update::CPolygon_Update(void) : CPolygon_Overlay(_TL("Update")) { Add_Description(_TW( "Updates features of layer A with the features of layer B, " "i.e. all features of layer B will be supplemented with the " "difference of layer A less layer B plus. It is assumed, " "that both input layers share the same attribute structure." )); } //--------------------------------------------------------- bool CPolygon_Update::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, false) ) { return( false ); } if( !Get_Difference(pA, pB) ) { return( false ); } //----------------------------------------------------- CSG_Shapes *pAB = Parameters("RESULT")->asShapes(); for(int i=0; iGet_Count(); i++) { pAB->Add_Shape(pB->Get_Shape(i)); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_SelfIntersection.h0000664000175000017500000001057612565125410027700 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_SelfIntersection.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_SelfIntersection.h // // // // Copyright (C) 2012 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_SelfIntersection_H #define HEADER_INCLUDED__Polygon_SelfIntersection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_SelfIntersection : public CSG_Module { public: CPolygon_SelfIntersection(void); protected: virtual bool On_Execute (void); private: CSG_Shapes *m_pIntersect; void Add_Polygon (CSG_Shape *pPolygon, int ID); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_SelfIntersection_H saga-2.2.3/src/modules/shapes/shapes_polygons/Polygon_Union.cpp0000664000175000017500000004072712565125410026044 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Union.cpp 1982 2014-02-10 16:52:17Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Union.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Union.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Dissolve::CPolygon_Dissolve(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Polygon Dissolve")); Set_Author ("O.Conrad (c) 2008"); Set_Description (_TW( "Merges polygons, which share the same attribute value, and " "(optionally) dissolves borders between adjacent polygon parts. " "If no attribute or combination of attributes is chosen, all polygons will be merged. " "\nUses the free and open source software library Clipper created by Angus Johnson.\n" "Clipper Homepage\n" "Clipper at SourceForge\n" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field(pNode, "FIELD_1", _TL("1. Attribute"), _TL(""), true); Parameters.Add_Table_Field(pNode, "FIELD_2", _TL("2. Attribute"), _TL(""), true); Parameters.Add_Table_Field(pNode, "FIELD_3", _TL("3. Attribute"), _TL(""), true); Parameters.Add_Shapes( NULL , "DISSOLVED" , _TL("Dissolved Polygons"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "BND_KEEP" , _TL("Keep Boundaries"), _TL(""), PARAMETER_TYPE_Bool, false ); pNode = Parameters.Add_Table_Fields( pNode , "STAT_FIELDS" , _TL("Statistics"), _TL("") ); Parameters.Add_Value(pNode, "STAT_SUM", _TL("Sum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_AVG", _TL("Mean" ), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value(pNode, "STAT_MIN", _TL("Minimum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_MAX", _TL("Maximum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_RNG", _TL("Range" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_DEV", _TL("Deviation"), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_VAR", _TL("Variance" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_LST", _TL("Listing" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_NUM", _TL("Count" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Choice( pNode, "STAT_NAMING" , _TL("Field Naming"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("variable type + original name"), _TL("original name + variable type"), _TL("original name"), _TL("variable type") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPolygon_Dissolve::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("POLYGONS")) && pParameters->Get_Parameter("POLYGONS")->asShapes() != NULL ) { int nFields = pParameters->Get_Parameter("POLYGONS")->asShapes()->Get_Field_Count(); pParameters->Get_Parameter("FIELD_2")->Set_Value(nFields); pParameters->Get_Parameter("FIELD_3")->Set_Value(nFields); } return( 0 ); } //--------------------------------------------------------- int CPolygon_Dissolve::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FIELD_1")) ) { pParameters->Get_Parameter("FIELD_2")->Set_Enabled(pParameter->asInt() >= 0); pParameters->Get_Parameter("FIELD_3")->Set_Enabled(pParameter->asInt() >= 0 && pParameters->Get_Parameter("FIELD_2")->asInt() >= 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FIELD_2")) ) { pParameters->Get_Parameter("FIELD_3")->Set_Enabled(pParameter->asInt() >= 0 && pParameters->Get_Parameter("FIELD_1")->asInt() >= 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("STAT_FIELDS")) ) { pParameters->Get_Parameter("STAT_SUM")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_AVG")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_MIN")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_MAX")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_RNG")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_DEV")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_VAR")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_LST")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_NUM")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_NAMING")->Set_Enabled(pParameter->asInt() > 0); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Dissolve::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( !pPolygons->is_Valid() || pPolygons->Get_Count() < 2 ) { Error_Set(_TL("invalid or empty polygons layer")); return( false ); } //----------------------------------------------------- CSG_Shapes *pUnions = Parameters("DISSOLVED")->asShapes(); pUnions->Create(SHAPE_TYPE_Polygon); int Field_1 = Parameters("FIELD_1")->asInt(); int Field_2 = Parameters("FIELD_2")->asInt(); if( Field_1 < 0 ) Field_2 = -1; int Field_3 = Parameters("FIELD_3")->asInt(); if( Field_2 < 0 ) Field_3 = -1; if( Field_1 >= 0 ) { CSG_String s = pPolygons->Get_Field_Name(Field_1); pUnions->Add_Field(pPolygons->Get_Field_Name(Field_1), pPolygons->Get_Field_Type(Field_1)); if( Field_2 >= 0 ) { s += CSG_String(" | ") + pPolygons->Get_Field_Name(Field_2); pUnions->Add_Field(pPolygons->Get_Field_Name(Field_2), pPolygons->Get_Field_Type(Field_2)); if( Field_3 >= 0 ) { s += CSG_String(" | ") + pPolygons->Get_Field_Name(Field_3); pUnions->Add_Field(pPolygons->Get_Field_Name(Field_3), pPolygons->Get_Field_Type(Field_3)); } } pPolygons->Set_Index(Field_1, TABLE_INDEX_Ascending, Field_2, TABLE_INDEX_Ascending, Field_3, TABLE_INDEX_Ascending); pUnions->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pPolygons->Get_Name(), _TL("Dissolved"), s.c_str())); } else // if( Field_1 < 0 ) { pUnions->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pPolygons->Get_Name(), _TL("Dissolved"), _TL("All"))); } Init_Statistics(pUnions, pPolygons); //----------------------------------------------------- CSG_String Value; CSG_Shape *pUnion = NULL; bool bDissolve = Parameters("BND_KEEP")->asBool() == false; //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(pPolygons->Get_Record_byIndex(iPolygon)->Get_Index()); CSG_String s; if( Field_1 >= 0 ) s = pPolygon->asString(Field_1); if( Field_2 >= 0 ) s += pPolygon->asString(Field_2); if( Field_3 >= 0 ) s += pPolygon->asString(Field_3); if( pUnion == NULL || (Field_1 >= 0 && Value.Cmp(s)) ) { Set_Union(pUnion, bDissolve); Value = s; pUnion = pUnions->Add_Shape(pPolygon, SHAPE_COPY_GEOM); if( Field_1 >= 0 ) pUnion->Set_Value(0, pPolygon->asString(Field_1)); if( Field_2 >= 0 ) pUnion->Set_Value(1, pPolygon->asString(Field_2)); if( Field_3 >= 0 ) pUnion->Set_Value(2, pPolygon->asString(Field_3)); Add_Statistics(pUnion, pPolygon, true); } else { for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0, nParts=pUnion->Get_Part_Count(); iPointGet_Point_Count(iPart); iPoint++) { pUnion->Add_Point(pPolygon->Get_Point(iPoint, iPart), nParts); } } Add_Statistics(pUnion, pPolygon, false); } } Set_Union(pUnion, bDissolve); //----------------------------------------------------- if( m_Statistics ) { delete[](m_Statistics); } m_List.Clear(); return( pUnions->is_Valid() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Dissolve::Init_Statistics(CSG_Shapes *pUnions, CSG_Shapes *pPolygons) { m_Stat_pFields = Parameters("STAT_FIELDS")->asTableFields(); m_bSUM = Parameters("STAT_SUM")->asBool(); m_bAVG = Parameters("STAT_AVG")->asBool(); m_bMIN = Parameters("STAT_MIN")->asBool(); m_bMAX = Parameters("STAT_MAX")->asBool(); m_bRNG = Parameters("STAT_RNG")->asBool(); m_bDEV = Parameters("STAT_DEV")->asBool(); m_bVAR = Parameters("STAT_VAR")->asBool(); m_bLST = Parameters("STAT_LST")->asBool(); m_bNUM = Parameters("STAT_NUM")->asBool(); if( m_Stat_pFields->Get_Count() > 0 && (m_bSUM || m_bAVG || m_bMIN || m_bMAX || m_bRNG || m_bDEV || m_bVAR || m_bLST || m_bNUM) ) { m_Statistics = new CSG_Simple_Statistics[m_Stat_pFields->Get_Count()]; m_Stat_Offset = pUnions->Get_Field_Count(); for(int iField=0; iFieldGet_Count(); iField++) { CSG_String s = pPolygons->Get_Field_Name(m_Stat_pFields->Get_Index(iField)); if( m_bSUM ) pUnions->Add_Field(Get_Statistics_Name("SUM", s), SG_DATATYPE_Double); if( m_bAVG ) pUnions->Add_Field(Get_Statistics_Name("AVG", s), SG_DATATYPE_Double); if( m_bMIN ) pUnions->Add_Field(Get_Statistics_Name("MIN", s), SG_DATATYPE_Double); if( m_bMAX ) pUnions->Add_Field(Get_Statistics_Name("MAX", s), SG_DATATYPE_Double); if( m_bRNG ) pUnions->Add_Field(Get_Statistics_Name("RNG", s), SG_DATATYPE_Double); if( m_bDEV ) pUnions->Add_Field(Get_Statistics_Name("STD", s), SG_DATATYPE_Double); if( m_bVAR ) pUnions->Add_Field(Get_Statistics_Name("VAR", s), SG_DATATYPE_Double); if( m_bNUM ) pUnions->Add_Field(Get_Statistics_Name("NUM", s), SG_DATATYPE_Int ); if( m_bLST ) pUnions->Add_Field(Get_Statistics_Name("LST", s), SG_DATATYPE_String); } if( m_bLST ) { m_List.Set_Count(m_Stat_pFields->Get_Count()); } return( true ); } m_Statistics = NULL; if( pUnions->Get_Field_Count() == 0 ) { pUnions->Add_Field("OID", SG_DATATYPE_Int); } return( false ); } //--------------------------------------------------------- CSG_String CPolygon_Dissolve::Get_Statistics_Name(const CSG_String &Type, const CSG_String &Name) { CSG_String s; switch( Parameters("STAT_NAMING")->asInt() ) { default: case 0: s.Printf(SG_T("%s_%s"), Type.c_str(), Name.c_str()); break; case 1: s.Printf(SG_T("%s_%s"), Name.c_str(), Type.c_str()); break; case 2: s.Printf(SG_T("%s" ), Name.c_str() ); break; case 3: s.Printf(SG_T("%s" ), Type.c_str() ); break; } return( s ); } //--------------------------------------------------------- bool CPolygon_Dissolve::Add_Statistics(CSG_Shape *pUnion, CSG_Shape *pPolygon, bool bReset) { if( m_Statistics ) { for(int iField=0; iFieldGet_Count(); iField++) { if( bReset ) { m_Statistics[iField].Create(); if( iField < m_List.Get_Count() ) { m_List[iField].Clear(); } } m_Statistics[iField] += pPolygon->asDouble(m_Stat_pFields->Get_Index(iField)); if( iField < m_List.Get_Count() ) { if( !m_List[iField].is_Empty() ) { m_List[iField] += "|"; } m_List[iField] += pPolygon->asString(m_Stat_pFields->Get_Index(iField)); } } return( true ); } return( false ); } //--------------------------------------------------------- bool CPolygon_Dissolve::Set_Union(CSG_Shape *pUnion, bool bDissolve) { if( !pUnion ) { return( false ); } if( bDissolve ) { SG_Polygon_Dissolve(pUnion); } if( m_Statistics ) { for(int iField=0, jField=m_Stat_Offset; iFieldGet_Count(); iField++) { if( m_bSUM ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Sum ()); if( m_bAVG ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Mean ()); if( m_bMIN ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Minimum ()); if( m_bMAX ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Maximum ()); if( m_bRNG ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Range ()); if( m_bDEV ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_StdDev ()); if( m_bVAR ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Variance()); if( m_bNUM ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Count ()); if( m_bLST ) pUnion->Set_Value(jField++, m_List [iField]); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/shapes/shapes_polygons/Polygons_From_Lines.h0000664000175000017500000001137412565125410026635 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygons_From_Lines.h 2174 2014-06-24 14:43:45Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygons_From_Lines.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygons_From_Lines_H #define HEADER_INCLUDED__Polygons_From_Lines_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygons_From_Lines : public CSG_Module { public: CPolygons_From_Lines(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); private: bool Add_Part (CSG_Shape *pPolygon, CSG_Shape *pLine, int iPart_Polygon, int iPart_Line, bool bAscending = true); bool Add_Line (CSG_Shape *pPolygon, CSG_Shape *pLine, int iPart_Polygon = 0); bool Get_Part (CSG_Point Point, CSG_Shape *pLine, int &iPart, bool &bAscending); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygons_From_Lines_H saga-2.2.3/src/modules/io/0000775000175000017500000000000012634325744016447 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_grid_image/0000775000175000017500000000000012634325744021225 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_grid_image/grid_import.cpp0000664000175000017500000003470212565125414024251 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_import.cpp 2089 2014-04-04 12:37:27Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // image_io // // // //-------------------------------------------------------// // // // Grid_Import.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include #include "grid_import.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Import::CGrid_Import(void) { //----------------------------------------------------- Set_Name (_TL("Import Image (bmp, jpg, png, tif, gif, pnm, xpm)")); Set_Author (SG_T("(c) 2005 by O.Conrad")); Set_Description (_TW( "Loads an image." )); //----------------------------------------------------- Parameters.Add_Grid_Output( NULL , "OUT_GRID" , _TL("Image"), _TL("") ); Parameters.Add_Grid_Output( NULL , "OUT_RED" , _TL("Image (Red Channel)"), _TL("") ); Parameters.Add_Grid_Output( NULL , "OUT_GREEN" , _TL("Image (Green Channel)"), _TL("") ); Parameters.Add_Grid_Output( NULL , "OUT_BLUE" , _TL("Image (Blue Channel)"), _TL("") ); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILE" , _TL("Image File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s"), _TL("All Recognized File Types") , SG_T("*.bmp;*.ico;*.gif;*.jpg;*.jif;*.jpeg;*.pcx;*.png;*.pnm;*.tif;*.tiff;*.xpm"), _TL("CompuServe Graphics Interchange (*.gif)") , SG_T("*.gif"), _TL("JPEG - JFIF Compliant (*.jpg, *.jif, *.jpeg)") , SG_T("*.jpg;*.jif;*.jpeg"), _TL("Portable Network Graphics (*.png)") , SG_T("*.png"), _TL("Tagged Image File Format (*.tif, *.tiff)") , SG_T("*.tif;*.tiff"), _TL("Windows or OS/2 Bitmap (*.bmp)") , SG_T("*.bmp"), _TL("Zsoft Paintbrush (*.pcx)") , SG_T("*.pcx"), _TL("All Files") , SG_T("*.*") ) ); 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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Import::On_Execute(void) { bool bTransform; int x, y, yy, Method; double ax, ay, dx, dy, rx, ry, xMin, yMin, Cellsize; CSG_Colors Colors; CSG_String fImage, fWorld, Name; CSG_Grid *pImage; CSG_File Stream; wxImage Image; wxImageHistogram Histogram; //----------------------------------------------------- fImage = Parameters("FILE") ->asString(); Method = Parameters("METHOD") ->asInt(); Name = SG_File_Get_Name(fImage, false); //----------------------------------------------------- wxImageHandler *pImgHandler = NULL; if( !SG_UI_Get_Window_Main() ) { CSG_String fName = SG_File_Get_Name(fImage, true); if( SG_File_Cmp_Extension(fName, SG_T("jpg")) ) pImgHandler = new wxJPEGHandler; else if( SG_File_Cmp_Extension(fName, SG_T("pcx")) ) pImgHandler = new wxPCXHandler; else if( SG_File_Cmp_Extension(fName, SG_T("tif")) ) pImgHandler = new wxTIFFHandler; else if( SG_File_Cmp_Extension(fName, SG_T("gif")) ) pImgHandler = new wxGIFHandler; else if( SG_File_Cmp_Extension(fName, SG_T("pnm")) ) pImgHandler = new wxPNMHandler; else if( SG_File_Cmp_Extension(fName, SG_T("xpm")) ) pImgHandler = new wxXPMHandler; #ifdef _SAGA_MSW else if( SG_File_Cmp_Extension(fName, SG_T("bmp")) ) pImgHandler = new wxBMPHandler; #endif else // if( SG_File_Cmp_Extension(fName, SG_T("png")) ) pImgHandler = new wxPNGHandler; wxImage::AddHandler(pImgHandler); } 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( dx != -dy || rx != 0.0 || ry != 0.0 ) { bTransform = true; } else { xMin = ax; yMin = ay + dy * (Image.GetHeight() - 1); Cellsize = dx; } } //----------------------------------------------------- // 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) { Colors.Set_Color(i->second.index, SG_GET_R(i->first), SG_GET_G(i->first), SG_GET_B(i->first)); } pImage = SG_Create_Grid(yy <= 2 ? SG_DATATYPE_Bit : SG_DATATYPE_Byte, Image.GetWidth(), Image.GetHeight(), Cellsize, xMin, yMin); for(y=0; yGet_NY() && Set_Progress(y, pImage->Get_NY()); y++) { yy = bTransform ? y : pImage->Get_NY() - 1 - y; for(x=0; xGet_NX(); x++) { pImage->Set_Value(x, y, Histogram[SG_GET_RGB(Image.GetRed(x, yy), Image.GetGreen(x, yy), Image.GetBlue(x, yy))].index); } } if( bTransform ) { Set_Transformation(&pImage, ax, ay, dx, dy, rx, ry); } pImage->Set_Name(Name); pImage->Get_Projection().Load(SG_File_Make_Path(NULL, fImage, SG_T("prj"))); 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; yGet_NY() && Set_Progress(y, pImage->Get_NY()); y++) { yy = bTransform ? y : pImage->Get_NY() - 1 - y; for(x=0; xGet_NX(); x++) { pImage->Set_Value(x, y, SG_GET_RGB(Image.GetRed(x, yy), Image.GetGreen(x, yy), Image.GetBlue(x, yy))); } } if( bTransform ) { Set_Transformation(&pImage, ax, ay, dx, dy, rx, ry); } //------------------------------------------------- if( Method != 1 ) // true color... { pImage->Get_Projection().Load(fImage, SG_PROJ_FMT_WKT); pImage->Set_Name(Name); pImage->Get_Projection().Load(SG_File_Make_Path(NULL, fImage, SG_T("prj"))); Parameters("OUT_GRID")->Set_Value(pImage); DataObject_Set_Colors(pImage, 100, SG_COLORS_BLACK_WHITE); DataObject_Set_Parameter(pImage, "COLORS_TYPE", 6); // Color Classification Type: RGB } //------------------------------------------------- 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; yGet_NY() && Set_Progress(y, pImage->Get_NY()); y++) { for(x=0; xGet_NX(); x++) { 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))); } } 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); 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())); pR->Get_Projection().Load(SG_File_Make_Path(NULL, fImage, SG_T("prj"))); pG->Get_Projection().Load(SG_File_Make_Path(NULL, fImage, SG_T("prj"))); pB->Get_Projection().Load(SG_File_Make_Path(NULL, fImage, SG_T("prj"))); 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); } } //----------------------------------------------------- if( !SG_UI_Get_Window_Main() && pImgHandler != NULL) { wxImage::RemoveHandler(pImgHandler->GetName()); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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; //----------------------------------------------------- pSource = *ppImage; 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(); //----------------------------------------------------- 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]; 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]; 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]; 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]; 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(); yGet_NY() && Set_Progress(y, pTarget->Get_NY()); y++, XTgt[1]+=pTarget->Get_Cellsize()) { for(x=0, XTgt[0]=pTarget->Get_XMin(); xGet_NX(); x++, XTgt[0]+=pTarget->Get_Cellsize()) { XSrc = DInv * (XTgt - A); 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); } } } delete(pSource); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid_image/grid_export.h0000664000175000017500000001075612565125414023730 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_export.h 2089 2014-04-04 12:37:27Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // image_io // // // //-------------------------------------------------------// // // // Grid_Export.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Export_H #define HEADER_INCLUDED__Grid_Export_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_grid_image_EXPORT CGrid_Export : public CSG_Module_Grid { public: CGrid_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Export") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Export_H saga-2.2.3/src/modules/io/io_grid_image/grid_export.cpp0000664000175000017500000004266712565125414024271 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_export.cpp 2542 2015-07-15 12:31:48Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // image_io // // // //-------------------------------------------------------// // // // Grid_Export.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include #include "grid_export.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Export::CGrid_Export(void) { Set_Name (_TL("Export Image (bmp, jpg, pcx, png, tif)")); Set_Author (SG_T("O.Conrad (c) 2005")); Set_Description (_TW( "The module allows one to save a grid as image.\n" "Optionally, a shade grid can be overlayed and it's " "transparency and brightness can be adjusted.\n\n") ); Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SHADE" , _TL("Shade"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILE" , _TL("Image File"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", _TL("Portable Network Graphics (*.png)") , SG_T("*.png"), _TL("JPEG - JFIF Compliant (*.jpg, *.jif, *.jpeg)") , SG_T("*.jpg;*.jif;*.jpeg"), _TL("Tagged Image File Format (*.tif, *.tiff)") , SG_T("*.tif;*.tiff"), _TL("Windows or OS/2 Bitmap (*.bmp)") , SG_T("*.bmp"), _TL("Zsoft Paintbrush (*.pcx)") , SG_T("*.pcx") ), NULL, true ); Parameters.Add_Value( NULL , "FILE_KML" , _TL("Create KML File"), _TL(""), PARAMETER_TYPE_Bool, true ); if( SG_UI_Get_Window_Main() ) { Parameters.Add_Choice( NULL , "COLOURING" , _TL("Colouring"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("stretch to grid's standard deviation"), _TL("stretch to grid's value range"), _TL("stretch to specified value range"), _TL("lookup table"), _TL("rgb coded values"), _TL("same as in graphical user interface") ), 5 ); Parameters.Add_Colors( NULL , "COL_PALETTE" , _TL("Colours Palette"), _TL("") ); } else { Parameters.Add_Choice( NULL , "COLOURING" , _TL("Colouring"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("stretch to grid's standard deviation"), _TL("stretch to grid's value range"), _TL("stretch to specified value range"), _TL("lookup table"), _TL("rgb coded values") ), 0 ); 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|%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"), _TL("TOPOGRAPHY"), _TL("ASPECT_1"), _TL("ASPECT_2"), _TL("ASPECT_3") ), 0 ); Parameters.Add_Value( NULL , "COL_COUNT" , _TL("Number of Colors"), _TL(""), PARAMETER_TYPE_Int, 100 ); Parameters.Add_Value( NULL , "COL_REVERT" , _TL("Revert Palette"), _TL(""), PARAMETER_TYPE_Bool, false ); } Parameters.Add_Value( NULL , "STDDEV" , _TL("Standard Deviation"), _TL(""), PARAMETER_TYPE_Double, 2.0, 0.0, true ); Parameters.Add_Range( NULL , "STRETCH" , _TL("Stretch to Value Range"), _TL(""), 0.0, 100.0 ); Parameters.Add_Table( NULL , "LUT" , _TL("Lookup Table"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( NULL , "SHADE_TRANS" , _TL("Shade Transparency [%]"), _TL("The transparency of the shade [%]"), PARAMETER_TYPE_Double, 40.0, 0.0, true, 100.0, true ); Parameters.Add_Range( NULL , "SHADE_BRIGHT", _TL("Shade Brightness [%]"), _TL("Allows one to scale shade brightness [%]"), 0.0, 100.0, 0.0, true, 100.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_Export::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("COLOURING")) ) { pParameters->Get_Parameter("COL_PALETTE")->Set_Enabled(pParameter->asInt() <= 2); pParameters->Get_Parameter("STDDEV" )->Set_Enabled(pParameter->asInt() == 0); pParameters->Get_Parameter("STRETCH" )->Set_Enabled(pParameter->asInt() == 2); pParameters->Get_Parameter("LUT" )->Set_Enabled(pParameter->asInt() == 3); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SHADE")) ) { pParameters->Get_Parameter("SHADE_TRANS" )->Set_Enabled(pParameter->asGrid() != NULL); pParameters->Get_Parameter("SHADE_BRIGHT" )->Set_Enabled(pParameter->asGrid() != NULL); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Export::On_Execute(void) { //----------------------------------------------------- int y, iy, Method; double dTrans; CSG_Grid *pGrid, *pShade, Grid, Shade; //----------------------------------------------------- pGrid = Parameters("GRID" )->asGrid(); pShade = Parameters("SHADE" )->asGrid(); Method = Parameters("COLOURING" )->asInt (); dTrans = Parameters("SHADE_TRANS" )->asDouble() / 100.0; if( !pGrid ) { return( false ); } //----------------------------------------------------- if( Method == 5 ) // same as in graphical user interface { if( !SG_UI_DataObject_asImage(pGrid, &Grid) ) { Error_Set("could not retrieve colour coding from graphical user interface."); return( false ); } } else { double zMin, zScale; CSG_Colors Colors; CSG_Table LUT; if( SG_UI_Get_Window_Main() ) { Colors.Assign(Parameters("COL_PALETTE")->asColors()); } else { Colors.Set_Palette( Parameters("COL_PALETTE")->asInt (), Parameters("COL_REVERT" )->asBool(), Parameters("COL_COUNT" )->asInt () ); } switch( Method ) { case 0: // stretch to grid's standard deviation zMin = pGrid->Get_Mean() - Parameters("STDDEV")->asDouble() * pGrid->Get_StdDev(); zScale = Colors.Get_Count() / (2 * Parameters("STDDEV")->asDouble() * pGrid->Get_StdDev()); break; case 1: // stretch to grid's value range zMin = pGrid->Get_ZMin(); zScale = Colors.Get_Count() / pGrid->Get_ZRange(); break; case 2: // stretch to specified value range zMin = Parameters("STRETCH")->asRange()->Get_LoVal(); if( zMin >= (zScale = Parameters("STRETCH")->asRange()->Get_HiVal()) ) { Error_Set(_TL("invalid user specified value range.")); return( false ); } zScale = Colors.Get_Count() / (zScale - zMin); break; case 3: // lookup table if( !Parameters("LUT")->asTable() || Parameters("LUT")->asTable()->Get_Field_Count() < 5 ) { Error_Set(_TL("invalid lookup table.")); return( false ); } LUT.Create(*Parameters("LUT")->asTable()); break; case 4: // rgb coded values break; } //------------------------------------------------- Grid.Create(*Get_System(), SG_DATATYPE_Int); for(y=0, iy=Get_NY()-1; yasDouble(x, y); if( Method == 3 ) // lookup table { int i, iColor = -1; for(i=0; iColor<0 && i= LUT[i][3] && z <= LUT[i][4] ) { Grid.Set_Value(x, iy, LUT[iColor = i].asInt(0)); } } if( iColor < 0 ) { Grid.Set_NoData(x, iy); } } else if( pGrid->is_NoData(x, y) ) { Grid.Set_NoData(x, iy); } else if( Method == 4 ) // rgb coded values { Grid.Set_Value(x, iy, z); } else { int i = (int)(zScale * (z - zMin)); Grid.Set_Value(x, iy, Colors[i < 0 ? 0 : i >= Colors.Get_Count() ? Colors.Get_Count() - 1 : i]); } } } } //----------------------------------------------------- if( !pShade || pShade->Get_ZRange() <= 0.0 ) { pShade = NULL; } else { double dMinBright, dMaxBright; dMinBright = Parameters("SHADE_BRIGHT")->asRange()->Get_LoVal() / 100.0; dMaxBright = Parameters("SHADE_BRIGHT")->asRange()->Get_HiVal() / 100.0; if( dMinBright >= dMaxBright ) { SG_UI_Msg_Add_Error(_TL("Minimum shade brightness must be lower than maximum shade brightness!")); return( false ); } int nColors = 100; CSG_Colors Colors(nColors, SG_COLORS_BLACK_WHITE, true); //------------------------------------------------- Shade.Create(*Get_System(), SG_DATATYPE_Int); for(y=0, iy=Get_NY()-1; yis_NoData(x, y) ) { Shade.Set_NoData(x, iy); } else { Shade.Set_Value (x, iy, Colors[(int)(nColors * (dMaxBright - dMinBright) * (pShade->asDouble(x, y) - pShade->Get_ZMin()) / pShade->Get_ZRange() + dMinBright)]); } } } } //----------------------------------------------------- wxImage Image(Get_NX(), Get_NY()); if( Grid.Get_NoData_Count() > 0 ) { Image.SetAlpha(); } for(y=0; yasString()); if( !SG_File_Cmp_Extension(fName, SG_T("bmp")) && !SG_File_Cmp_Extension(fName, SG_T("jpg")) && !SG_File_Cmp_Extension(fName, SG_T("pcx")) && !SG_File_Cmp_Extension(fName, SG_T("png")) && !SG_File_Cmp_Extension(fName, SG_T("tif")) ) { fName = SG_File_Make_Path(NULL, fName, SG_T("png")); Parameters("FILE")->Set_Value(fName); } //----------------------------------------------------- wxImageHandler *pImgHandler = NULL; if( !SG_UI_Get_Window_Main() ) { if( SG_File_Cmp_Extension(fName, SG_T("jpg")) ) pImgHandler = new wxJPEGHandler; else if( SG_File_Cmp_Extension(fName, SG_T("pcx")) ) pImgHandler = new wxPCXHandler; else if( SG_File_Cmp_Extension(fName, SG_T("tif")) ) pImgHandler = new wxTIFFHandler; #ifdef _SAGA_MSW else if( SG_File_Cmp_Extension(fName, SG_T("bmp")) ) pImgHandler = new wxBMPHandler; #endif else // if( SG_File_Cmp_Extension(fName, SG_T("png")) ) pImgHandler = new wxPNGHandler; wxImage::AddHandler(pImgHandler); } if( !Image.SaveFile(fName.c_str()) ) { Error_Set(CSG_String::Format(SG_T("%s [%s]"), _TL("could not save image file"), fName.c_str())); return( false ); } pGrid->Get_Projection().Save(SG_File_Make_Path(NULL, fName, SG_T("prj")), SG_PROJ_FMT_WKT); //----------------------------------------------------- CSG_File Stream; if( SG_File_Cmp_Extension(fName, SG_T("bmp")) ) Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("bpw")), SG_FILE_W, false); else if( SG_File_Cmp_Extension(fName, SG_T("jpg")) ) Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("jgw")), SG_FILE_W, false); else if( SG_File_Cmp_Extension(fName, SG_T("pcx")) ) Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("pxw")), SG_FILE_W, false); else if( SG_File_Cmp_Extension(fName, SG_T("png")) ) Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("pgw")), SG_FILE_W, false); else if( SG_File_Cmp_Extension(fName, SG_T("tif")) ) Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("tfw")), SG_FILE_W, false); if( Stream.is_Open() ) { Stream.Printf(SG_T("%.10f\n%f\n%f\n%.10f\n%.10f\n%.10f\n"), pGrid->Get_Cellsize(), 0.0, 0.0, -pGrid->Get_Cellsize(), pGrid->Get_XMin(), pGrid->Get_YMax() ); } //----------------------------------------------------- if( Parameters("FILE_KML")->asBool() ) { CSG_MetaData KML; KML.Set_Name("kml"); KML.Add_Property("xmlns", "http://www.opengis.net/kml/2.2"); // CSG_MetaData *pFolder = KML.Add_Child("Folder"); // pFolder->Add_Child("name" , "Raster exported from SAGA"); // pFolder->Add_Child("description", "System for Automated Geoscientific Analyses - www.saga-gis.org"); // CSG_MetaData *pOverlay = pFolder->Add_Child("GroundOverlay"); CSG_MetaData *pOverlay = KML.Add_Child("GroundOverlay"); pOverlay->Add_Child("name" , pGrid->Get_Name()); pOverlay->Add_Child("description", pGrid->Get_Description()); pOverlay->Add_Child("Icon" )->Add_Child("href", SG_File_Get_Name(fName, true)); pOverlay->Add_Child("LatLonBox" ); pOverlay->Get_Child("LatLonBox" )->Add_Child("north", pGrid->Get_YMax()); pOverlay->Get_Child("LatLonBox" )->Add_Child("south", pGrid->Get_YMin()); pOverlay->Get_Child("LatLonBox" )->Add_Child("east" , pGrid->Get_XMax()); pOverlay->Get_Child("LatLonBox" )->Add_Child("west" , pGrid->Get_XMin()); KML.Save(fName, SG_T("kml")); } //----------------------------------------------------- if( !SG_UI_Get_Window_Main() && pImgHandler != NULL) { wxImage::RemoveHandler(pImgHandler->GetName()); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid_image/Makefile.in0000664000175000017500000005526412622651166023303 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/io_grid_image DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_grid_image_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libio_grid_image_la_OBJECTS = grid_export.lo grid_import.lo \ grid_to_kml.lo MLB_Interface.lo libio_grid_image_la_OBJECTS = $(am_libio_grid_image_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_grid_image_la_SOURCES) DIST_SOURCES = $(libio_grid_image_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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@ @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @SAGA_UNICODE_FALSE@DEP_DEFS = -fPIC `wx-config --unicode=no --static=no --cxxflags` $(DBGFLAGS) @SAGA_UNICODE_TRUE@DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` -D_SAGA_UNICODE $(DBGFLAGS) @SAGA_UNICODE_FALSE@DEP_LFLG = -fPIC -shared `wx-config --unicode=no --static=no --libs` @SAGA_UNICODE_TRUE@DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` 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) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libio_grid_image.la libio_grid_image_la_SOURCES = \ grid_export.cpp\ grid_import.cpp\ grid_to_kml.cpp\ MLB_Interface.cpp\ grid_export.h\ grid_import.h\ grid_to_kml.h\ MLB_Interface.h libio_grid_image_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) --foreign src/modules/io/io_grid_image/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_grid_image/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_grid_image.la: $(libio_grid_image_la_OBJECTS) $(libio_grid_image_la_DEPENDENCIES) $(EXTRA_libio_grid_image_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_grid_image_la_OBJECTS) $(libio_grid_image_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_export.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_to_kml.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/io/io_grid_image/grid_to_kml.h0000664000175000017500000001166712565125414023676 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_to_kml.h 2542 2015-07-15 12:31:48Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_grid_image // // // //-------------------------------------------------------// // // // grid_to_kml.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_to_kml_H #define HEADER_INCLUDED__grid_to_kml_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_to_KML : public CSG_Module_Grid { public: CGrid_to_KML(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Export") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_from_KML : public CSG_Module { public: CGrid_from_KML(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: CSG_Parameter_Grid_List *m_pGrids; bool Load_KML (const SG_Char *Dir, const CSG_MetaData &KML); bool Load_Overlay (const SG_Char *Dir, const CSG_MetaData &KML); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_to_kml_H saga-2.2.3/src/modules/io/io_grid_image/grid_import.h0000664000175000017500000001077512565125414023722 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_import.h 2089 2014-04-04 12:37:27Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // image_io // // // //-------------------------------------------------------// // // // Grid_Import.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Import_H #define HEADER_INCLUDED__Grid_Import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_grid_image_EXPORT CGrid_Import : public CSG_Module { public: CGrid_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: void Set_Transformation (CSG_Grid **ppImage, double ax, double ay, double dx, double dy, double rx, double ry); }; #endif // #ifndef HEADER_INCLUDED__Grid_Import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid_image/grid_to_kml.cpp0000664000175000017500000004541012565125414024222 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_to_kml.cpp 2543 2015-07-27 13:48:24Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_grid_image // // // //-------------------------------------------------------// // // // grid_to_kml.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include #include //--------------------------------------------------------- #include "grid_to_kml.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_to_KML::CGrid_to_KML(void) { Set_Name (_TL("Export Grid to KML")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "Uses 'Export Image' tool to create the image file. Automatically projects raster to geographic " "coordinate system, if its projection is known and not geographic. " )); Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SHADE" , _TL("Shade"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILE" , _TL("Image File"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", _TL("Portable Network Graphics (*.png)") , SG_T("*.png"), _TL("JPEG - JFIF Compliant (*.jpg, *.jif, *.jpeg)") , SG_T("*.jpg;*.jif;*.jpeg"), _TL("Tagged Image File Format (*.tif, *.tiff)") , SG_T("*.tif;*.tiff"), _TL("Windows or OS/2 Bitmap (*.bmp)") , SG_T("*.bmp"), _TL("Zsoft Paintbrush (*.pcx)") , SG_T("*.pcx") ), NULL, true ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format("%s|%s|%s|", _TL("kml and image files"), _TL("kmz, kml and image files"), _TL("kmz file") ), 2 ); if( SG_UI_Get_Window_Main() ) { Parameters.Add_Choice( NULL , "COLOURING" , _TL("Colouring"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|%s|", _TL("stretch to grid's standard deviation"), _TL("stretch to grid's value range"), _TL("stretch to specified value range"), _TL("lookup table"), _TL("rgb coded values"), _TL("same as in graphical user interface") ), 5 ); Parameters.Add_Colors( NULL , "COL_PALETTE" , _TL("Colours Palette"), _TL("") ); } else { Parameters.Add_Choice( NULL , "COLOURING" , _TL("Colouring"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|", _TL("stretch to grid's standard deviation"), _TL("stretch to grid's value range"), _TL("stretch to specified value range"), _TL("lookup table"), _TL("rgb coded values") ), 0 ); Parameters.Add_Choice( NULL , "COL_PALETTE" , _TL("Color Palette"), _TL(""), CSG_String::Format("%s|%s|%s|%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("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"), _TL("TOPOGRAPHY"), _TL("ASPECT_1"), _TL("ASPECT_2"), _TL("ASPECT_3") ), 0 ); Parameters.Add_Value( NULL , "COL_COUNT" , _TL("Number of Colors"), _TL(""), PARAMETER_TYPE_Int, 100 ); Parameters.Add_Value( NULL , "COL_REVERT" , _TL("Revert Palette"), _TL(""), PARAMETER_TYPE_Bool, false ); } Parameters.Add_Value( NULL , "STDDEV" , _TL("Standard Deviation"), _TL(""), PARAMETER_TYPE_Double, 2.0, 0.0, true ); Parameters.Add_Range( NULL , "STRETCH" , _TL("Stretch to Value Range"), _TL(""), 0.0, 100.0 ); Parameters.Add_Table( NULL , "LUT" , _TL("Lookup Table"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( NULL , "INTERPOL" , _TL("Interpolation"), _TL("interpolate values if projection is needed"), PARAMETER_TYPE_Bool, true ); if( !SG_UI_Get_Window_Main() ) { Parameters.Add_Range( NULL , "SHADE_BRIGHT", _TL("Shade Brightness"), _TL("Allows to scale shade brightness, [percent]"), 0.0, 100.0, 0.0, true, 100.0, true ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_to_KML::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "COLOURING") ) { pParameters->Get_Parameter("COL_PALETTE")->Set_Enabled(pParameter->asInt() <= 2); pParameters->Get_Parameter("STDDEV" )->Set_Enabled(pParameter->asInt() == 0); pParameters->Get_Parameter("STRETCH" )->Set_Enabled(pParameter->asInt() == 2); pParameters->Get_Parameter("LUT" )->Set_Enabled(pParameter->asInt() == 3); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "SHADE") && pParameters->Get_Parameter("SHADE_BRIGHT") ) { pParameters->Get_Parameter("SHADE_BRIGHT")->Set_Enabled(pParameter->asGrid() != NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "GRID") || !SG_STR_CMP(pParameter->Get_Identifier(), "COLOURING") ) { CSG_Grid *pGrid = pParameters->Get_Parameter("GRID")->asGrid(); pParameters->Get_Parameter("INTERPOL")->Set_Enabled( pGrid && pGrid->Get_Projection().Get_Type() == SG_PROJ_TYPE_CS_Projected && pParameters->Get_Parameter("COLOURING")->asInt() < 4 ); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_to_KML::On_Execute(void) { //----------------------------------------------------- bool bDelete = false; CSG_Module *pModule; CSG_Grid *pGrid = Parameters("GRID" )->asGrid(), Image; CSG_Grid *pShade = Parameters("SHADE")->asGrid(); //----------------------------------------------------- int Method = Parameters("COLOURING")->asInt(); if( Method == 5 ) // same as in graphical user interface { if( !SG_UI_DataObject_asImage(pGrid, &Image) ) { Error_Set("could not retrieve colour coding from graphical user interface."); return( false ); } Image.Set_Name (pGrid->Get_Name ()); Image.Set_Description(pGrid->Get_Description()); Image.Flip(); pGrid = &Image; Method = 4; // rgb coded values } //----------------------------------------------------- if( pGrid->Get_Projection().Get_Type() == SG_PROJ_TYPE_CS_Undefined ) { Message_Add(_TL("layer uses undefined coordinate system, assuming geographic coordinates")); } else if( pGrid->Get_Projection().Get_Type() != SG_PROJ_TYPE_CS_Geographic ) { Message_Add(CSG_String::Format("\n%s (%s: %s)\n", _TL("re-projection to geographic coordinates"), _TL("original"), pGrid->Get_Projection().Get_Name().c_str()), false); if( (pModule = SG_Get_Module_Library_Manager().Get_Module("pj_proj4", 4)) == NULL ) // Coordinate Transformation (Grid) { return( false ); } pModule->Settings_Push(); if( pModule->Set_Parameter("CRS_PROJ4" , SG_T("+proj=longlat +ellps=WGS84 +datum=WGS84")) && pModule->Set_Parameter("INTERPOLATION", Method < 4 && Parameters("INTERPOL")->asBool() ? 4 : 0) && pModule->Set_Parameter("SOURCE" , pGrid) && pModule->Execute() ) { bDelete = true; pGrid = pModule->Get_Parameters("TARGET")->Get_Parameter("GRID")->asGrid(); if( pShade && pModule->Set_Parameter("SOURCE", pShade) && pModule->Execute() ) { pShade = pModule->Get_Parameters("TARGET")->Get_Parameter("GRID")->asGrid(); } else { pShade = NULL; } } pModule->Settings_Pop(); if( !bDelete ) { Message_Add(CSG_String::Format("\n%s: %s\n", _TL("re-projection"), _TL("failed")), false); return( false ); } } //----------------------------------------------------- if( (pModule = SG_Get_Module_Library_Manager().Get_Module("io_grid_image", 0)) == NULL ) // Export Image { return( false ); } bool bResult = false; pModule->Settings_Push(); if( pModule->Set_Parameter("GRID" , pGrid) && pModule->Set_Parameter("SHADE" , pShade) && pModule->Set_Parameter("FILE_KML" , true) && pModule->Set_Parameter("FILE" , Parameters("FILE")) && pModule->Set_Parameter("COLOURING" , Method) && pModule->Set_Parameter("COL_PALETTE" , Parameters("COL_PALETTE")) && pModule->Set_Parameter("STDDEV" , Parameters("STDDEV")) && pModule->Set_Parameter("STRETCH" , Parameters("STRETCH")) && pModule->Set_Parameter("LUT" , Parameters("LUT")) && (SG_UI_Get_Window_Main() || pModule->Set_Parameter("SHADE_BRIGHT", Parameters("SHADE_BRIGHT"))) && pModule->Execute() ) { bResult = true; } pModule->Settings_Pop(); //----------------------------------------------------- if( bDelete ) { delete(pGrid); if( pShade ) { delete(pShade); } } //--------------------------------------------------------- #define ZIP_ADD_FILE(zip, fn) {\ wxFileInputStream *pInput;\ \ if( SG_File_Exists(fn) && (pInput = new wxFileInputStream(fn)) != NULL )\ {\ zip.PutNextEntry(SG_File_Get_Name(fn, true).c_str());\ zip.Write(*pInput);\ delete(pInput);\ }\ } //--------------------------------------------------------- if( Parameters("OUTPUT")->asInt() != 0 ) // create kmz { CSG_String Filename = Parameters("FILE")->asString(); SG_File_Set_Extension(Filename, "kmz"); wxDir dir; wxString file; //------------------------------------------------- if( dir.Open(SG_File_Get_Path(Filename).c_str()) && dir.GetFirst(&file, wxString::Format("%s.*", SG_File_Get_Name(Filename, false).c_str()), wxDIR_FILES) ) { CSG_Strings Files; do { if( !SG_File_Cmp_Extension(file, SG_T("kmz")) ) { Files += SG_File_Make_Path(SG_File_Get_Path(Filename), file); } } while( dir.GetNext(&file) ); dir.Close(); //--------------------------------------------- wxZipOutputStream Zip(new wxFileOutputStream(Filename.c_str())); for(int i=0; iasInt() != 1 ) // delete kml, image and associated files { SG_File_Delete(Files[i]); } } } } //----------------------------------------------------- return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_from_KML::CGrid_from_KML(void) { Set_Name (_TL("Import Grids from KML")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "Uses 'Import Image' tool to load the ground overlay image files associated with the kml. " )); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("KML/KMZ File"), _TL(""), CSG_String::Format("%s|%s", _TL("KML/KMZ Files"), SG_T("*.kml;*.kmz"), _TL("All Files" ), SG_T("*.*") ), NULL, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_from_KML::On_Execute(void) { //----------------------------------------------------- wxString Dir, File = Parameters("FILE")->asString(); //----------------------------------------------------- bool bKMZ = SG_File_Cmp_Extension(File, SG_T("kmz")); if( !bKMZ ) { Dir = SG_File_Get_Path(File).c_str(); } else // unzip to temporary directory { Dir = wxFileName::CreateTempFileName("kml_"); wxRemoveFile(Dir); wxFileName::Mkdir(Dir); wxZipEntry *pEntry; wxZipInputStream Zip(new wxFileInputStream(File)); while( (pEntry = Zip.GetNextEntry()) != NULL ) { wxFileName fn(Dir, pEntry->GetName()); wxFileOutputStream *pOutput = new wxFileOutputStream(fn.GetFullPath()); pOutput->Write(Zip); delete(pOutput); delete(pEntry); if( !fn.GetExt().CmpNoCase("kml") ) { File = fn.GetFullPath(); } } } //----------------------------------------------------- CSG_MetaData KML; if( !KML.Load(&File) ) { Error_Fmt("%s [%s]", _TL("failed to load file"), File.wc_str()); return( false ); } //----------------------------------------------------- m_pGrids = Parameters("GRIDS")->asGridList(); m_pGrids->Del_Items(); Load_KML(Dir, KML); //----------------------------------------------------- if( bKMZ && wxDirExists(Dir) ) { wxFileName::Rmdir(Dir, wxPATH_RMDIR_FULL|wxPATH_RMDIR_RECURSIVE); } //----------------------------------------------------- return( m_pGrids->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_from_KML::Load_KML(const SG_Char *Dir, const CSG_MetaData &KML) { for(int i=0; iCmp_Name("GroundOverlay") ) { Load_Overlay(Dir, *KML.Get_Child(i)); } else { Load_KML (Dir, *KML.Get_Child(i)); } } return( true ); } //--------------------------------------------------------- bool CGrid_from_KML::Load_Overlay(const SG_Char *Dir, const CSG_MetaData &KML) { //----------------------------------------------------- if( !KML("Icon") || !KML["Icon"]("HRef") ) { Error_Set(_TL("missing icon tags")); return( false ); } //----------------------------------------------------- CSG_Rect r; if( !KML("LatLonBox") || !KML["LatLonBox"]("North") || !KML["LatLonBox"]["North"].Get_Content().asDouble(r.m_rect.yMax) || !KML["LatLonBox"]("South") || !KML["LatLonBox"]["South"].Get_Content().asDouble(r.m_rect.yMin) || !KML["LatLonBox"]("East" ) || !KML["LatLonBox"]["East" ].Get_Content().asDouble(r.m_rect.xMax) || !KML["LatLonBox"]("West" ) || !KML["LatLonBox"]["West" ].Get_Content().asDouble(r.m_rect.xMin) ) { Error_Set(_TL("failed to load georeference for KML ground overlay")); return( false ); } //----------------------------------------------------- wxFileName fn(KML["Icon"]["HRef"].Get_Content().c_str()); if( !fn.FileExists() ) { fn.SetPath(Dir); } CSG_Data_Manager Data; CSG_String FullPath = fn.GetFullPath().wc_str(); if( !Data.Add(FullPath) || !Data.Get_Grid_System(0) || !Data.Get_Grid_System(0)->Get(0) ) { Error_Fmt("%s: %s", _TL("failed to load KML ground overlay icon"), fn.GetFullPath().wc_str()); } //----------------------------------------------------- CSG_Grid *pIcon = (CSG_Grid *)Data.Get_Grid_System(0)->Get(0); CSG_Grid *pGrid = SG_Create_Grid(pIcon->Get_Type(), pIcon->Get_NX(), pIcon->Get_NY(), r.Get_YRange() / (pIcon->Get_NY() - 1), r.Get_XMin(), r.Get_YMin()); if( KML("Name") && !KML["Name"].Get_Content().is_Empty() ) pGrid->Set_Name(KML["Name"].Get_Content()); if( KML("Description") && !KML["Description"].Get_Content().is_Empty() ) pGrid->Set_Name(KML["Description"].Get_Content()); pGrid->Get_Projection().Assign("+proj=longlat +ellps=WGS84 +datum=WGS84", SG_PROJ_FMT_Proj4); #pragma omp parallel for for(int y=0; yGet_NY(); y++) { for(int x=0; xGet_NX(); x++) { pGrid->Set_Value(x, y, pIcon->asDouble(x, y)); } } m_pGrids->Add_Item(pGrid); DataObject_Add(pGrid); DataObject_Set_Parameter(pGrid, "COLORS_TYPE", 6); // Color Classification Type: RGB //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid_image/MLB_Interface.cpp0000664000175000017500000001133312565125414024317 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2542 2015-07-15 12:31:48Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // image_io // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // 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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Images") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2005") ); case MLB_INFO_Description: return( _TL("Image Import/Export.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Grid") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "grid_export.h" #include "grid_import.h" #include "grid_to_kml.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CGrid_Export ); case 1: return( new CGrid_Import ); case 2: return( new CGrid_to_KML ); case 3: return( new CGrid_from_KML ); default: return( NULL ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/io/io_grid_image/Makefile.am0000664000175000017500000000161512565125414023257 0ustar00oconradoconrad00000000000000if 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` 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 = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libio_grid_image.la libio_grid_image_la_SOURCES =\ grid_export.cpp\ grid_import.cpp\ grid_to_kml.cpp\ MLB_Interface.cpp\ grid_export.h\ grid_import.h\ grid_to_kml.h\ MLB_Interface.h libio_grid_image_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/io/io_grid_image/MLB_Interface.h0000664000175000017500000000773212565125414023774 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 2089 2014-04-04 12:37:27Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // image_io // // // //-------------------------------------------------------// // // // MLB_Interface.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_grid_image_H #define HEADER_INCLUDED__io_grid_image_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_grid_image_EXPORTS #define io_grid_image_EXPORT _SAGA_DLL_EXPORT #else #define io_grid_image_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_grid_image_H saga-2.2.3/src/modules/io/io_virtual/0000775000175000017500000000000012634325744020624 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_virtual/pc_get_grid_spcvf.h0000664000175000017500000001457012565125414024446 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_get_grid_spcvf.h 2385 2015-02-01 15:19:57Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // pc_get_grid_spcvf.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pc_get_grid_spcvf_H #define HEADER_INCLUDED__pc_get_grid_spcvf_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPointCloud_Get_Grid_SPCVF_Base { public: CPointCloud_Get_Grid_SPCVF_Base(void); virtual ~CPointCloud_Get_Grid_SPCVF_Base(void); void Initialise (int iOutputs, CSG_Rect AOI, CSG_Shapes *pShapes, int iFieldName, bool bMultiple, bool bAddOverlap, double dOverlap, CSG_String sFilename, CSG_Parameter_File_Name *pFilePath, CSG_Parameter_Grid_List *pGridList, double dCellsize, bool bFitToCells, int iMethod, bool bConstrain, int iField, double dMinAttrRange, double dMaxAttrRange); void Finalise (void); bool Get_Subset (int iFieldToGrid); void Write_Subset(CSG_Grid *pGrid, int iAOI, int iDatasets, double dPoints); protected: private: int m_iOutputs; CSG_Rect m_AOI; CSG_Shapes *m_pShapes; int m_iFieldName; bool m_bMultiple, m_bAddOverlap; double m_dOverlap; CSG_String m_sFileName; CSG_Parameter_File_Name *m_pFilePath; CSG_Parameter_Grid_List *m_pGridList; double m_dCellsize; bool m_bFitToCells; int m_iMethod; bool m_bConstrain; int m_iField; double m_dMinAttrRange, m_dMaxAttrRange; }; //--------------------------------------------------------- class CPointCloud_Get_Grid_SPCVF : public CSG_Module { public: CPointCloud_Get_Grid_SPCVF(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Point Cloud") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: CPointCloud_Get_Grid_SPCVF_Base m_Get_Grid_SPCVF; }; //--------------------------------------------------------- class CPointCloud_Get_Grid_SPCVF_Interactive : public CSG_Module_Interactive { public: CPointCloud_Get_Grid_SPCVF_Interactive(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Point Cloud") ); } protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: CSG_Point m_ptDown; CPointCloud_Get_Grid_SPCVF_Base m_Get_Grid_SPCVF; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pc_get_grid_spcvf_H saga-2.2.3/src/modules/io/io_virtual/pc_tileshape_from_spcvf.h0000664000175000017500000001103212565125414025651 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_tileshape_from_spcvf.h 2012 2014-02-24 13:55:07Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // pc_tileshape_from_spcvf.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pc_tileshape_from_spcvf_H #define HEADER_INCLUDED__pc_tileshape_from_spcvf_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPointCloud_Create_Tileshape_From_SPCVF : public CSG_Module { public: CPointCloud_Create_Tileshape_From_SPCVF(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Point Cloud") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pc_tileshape_from_spcvf_H saga-2.2.3/src/modules/io/io_virtual/Makefile.in0000664000175000017500000005631312622651167022677 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/io_virtual DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_virtual_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libio_virtual_la_OBJECTS = MLB_Interface.lo \ pc_tileshape_from_spcvf.lo pc_create_spcvf.lo \ pc_get_grid_spcvf.lo pc_get_subset_spcvf.lo \ pc_remove_overlap_from_spcvf.lo libio_virtual_la_OBJECTS = $(am_libio_virtual_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_virtual_la_SOURCES) DIST_SOURCES = $(libio_virtual_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 2359 2014-12-27 12:46:46Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @SAGA_UNICODE_FALSE@DEP_DEFS = -fPIC `wx-config --unicode=no --static=no --cxxflags` $(DBGFLAGS) @SAGA_UNICODE_TRUE@DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` -D_SAGA_UNICODE $(DBGFLAGS) @SAGA_UNICODE_FALSE@DEP_LFLG = -fPIC -shared `wx-config --unicode=no --static=no --libs` @SAGA_UNICODE_TRUE@DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` @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) $(DEP_DEFS) $(UC_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LFLG) pkglib_LTLIBRARIES = libio_virtual.la libio_virtual_la_SOURCES = \ MLB_Interface.cpp\ pc_tileshape_from_spcvf.cpp\ pc_create_spcvf.cpp\ pc_get_grid_spcvf.cpp\ pc_get_subset_spcvf.cpp\ pc_remove_overlap_from_spcvf.cpp\ MLB_Interface.h\ pc_tileshape_from_spcvf.h\ pc_create_spcvf.h\ pc_get_grid_spcvf.h\ pc_get_subset_spcvf.h\ pc_remove_overlap_from_spcvf.h libio_virtual_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) --foreign src/modules/io/io_virtual/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_virtual/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_virtual.la: $(libio_virtual_la_OBJECTS) $(libio_virtual_la_DEPENDENCIES) $(EXTRA_libio_virtual_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_virtual_la_OBJECTS) $(libio_virtual_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_create_spcvf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_get_grid_spcvf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_get_subset_spcvf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_remove_overlap_from_spcvf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_tileshape_from_spcvf.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/io/io_virtual/pc_get_grid_spcvf.cpp0000664000175000017500000006571612565125414025011 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_get_grid_spcvf.cpp 2439 2015-03-16 13:35:26Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // pc_get_grid_spcvf.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_get_grid_spcvf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_Get_Grid_SPCVF_Base::CPointCloud_Get_Grid_SPCVF_Base(void) { m_pShapes = NULL; m_pFilePath = NULL; m_pGridList = NULL; } //--------------------------------------------------------- CPointCloud_Get_Grid_SPCVF_Base::~CPointCloud_Get_Grid_SPCVF_Base(void) { Finalise(); } //--------------------------------------------------------- void CPointCloud_Get_Grid_SPCVF_Base::Initialise(int iOutputs, CSG_Rect AOI, CSG_Shapes *pShapes, int iFieldName, bool bMultiple, bool bAddOverlap, double dOverlap, CSG_String sFileName, CSG_Parameter_File_Name *pFilePath, CSG_Parameter_Grid_List *pGridList, double dCellsize, bool bFitToCells, int iMethod, bool bConstrain, int iField, double dMinAttrRange, double dMaxAttrRange) { m_iOutputs = iOutputs; m_AOI = AOI; m_pShapes = pShapes; m_iFieldName = iFieldName; m_bMultiple = bMultiple; m_bAddOverlap = bAddOverlap; m_dOverlap = dOverlap; m_sFileName = sFileName; m_pFilePath = pFilePath; m_pGridList = pGridList; m_dCellsize = dCellsize; m_bFitToCells = bFitToCells; m_iMethod = iMethod; m_bConstrain = bConstrain; m_iField = iField; m_dMinAttrRange = dMinAttrRange; m_dMaxAttrRange = dMaxAttrRange; return; } //--------------------------------------------------------- void CPointCloud_Get_Grid_SPCVF_Base::Finalise(void) { m_pShapes = NULL; m_pFilePath = NULL; m_pGridList = NULL; return; } //--------------------------------------------------------- bool CPointCloud_Get_Grid_SPCVF_Base::Get_Subset(int iFieldToGrid) { CSG_String sVersion, sPathSPCVF, sMethodPaths; double dBBoxXMin, dBBoxYMin, dBBoxXMax, dBBoxYMax; CSG_Rect BBoxSPCVF; CSG_MetaData SPCVF; //----------------------------------------------------- if( !SPCVF.Create(m_sFileName) || SPCVF.Get_Name().CmpNoCase(SG_T("SPCVFDataset")) ) { SG_UI_Msg_Add_Error(_TL("Please provide a valid *.scpvf file!")); return( false ); } CSG_MetaData *pHeader = SPCVF.Get_Child(SG_T("Header")); if( pHeader != NULL ) { int iFieldCount; pHeader->Get_Child(SG_T("Attributes"))->Get_Property(SG_T("Count"), iFieldCount); if( iFieldToGrid < 0 || iFieldToGrid >= iFieldCount ) { SG_UI_Msg_Add_Error(_TL("Attribute field number to grid is out of range!")); return( false ); } if( m_bConstrain ) { if( m_iField >= iFieldCount ) { SG_UI_Msg_Add_Error(_TL("Constraining attribute field number is out of range!")); return( false ); } } } //----------------------------------------------------- SPCVF.Get_Property(SG_T("Version"), sVersion); SPCVF.Get_Property(SG_T("Paths"), sMethodPaths); if( !sMethodPaths.CmpNoCase(SG_T("absolute")) ) { sPathSPCVF = SG_T(""); } else if( !sMethodPaths.CmpNoCase(SG_T("relative")) ) { sPathSPCVF = SG_File_Get_Path(m_sFileName); sPathSPCVF.Replace(SG_T("\\"), SG_T("/")); } else { SG_UI_Msg_Add_Error(_TL("Encountered invalid path description in *.spcvf file!")); return( false ); } //----------------------------------------------------- if( !sVersion.CmpNoCase(SG_T("1.0")) ) { SPCVF.Get_Child(SG_T("BBox"))->Get_Property(SG_T("XMin"), dBBoxXMin); SPCVF.Get_Child(SG_T("BBox"))->Get_Property(SG_T("YMin"), dBBoxYMin); SPCVF.Get_Child(SG_T("BBox"))->Get_Property(SG_T("XMax"), dBBoxXMax); SPCVF.Get_Child(SG_T("BBox"))->Get_Property(SG_T("YMax"), dBBoxYMax); } else // 1.1 { CSG_MetaData *pHeader = SPCVF.Get_Child(SG_T("Header")); pHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("XMin"), dBBoxXMin); pHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("YMin"), dBBoxYMin); pHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("XMax"), dBBoxXMax); pHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("YMax"), dBBoxYMax); } BBoxSPCVF.Assign(dBBoxXMin, dBBoxYMin, dBBoxXMax, dBBoxYMax); //----------------------------------------------------- int iDatasets = 0; CSG_Grid *pGrid = NULL; double dPoints = 0.0; for(int iAOI=0; iAOI 1 ) { SG_UI_Process_Set_Text(CSG_String::Format(_TL("Processing AOI %d ..."), iAOI + 1)); } else { SG_UI_Process_Set_Text(_TL("Processing AOI ...")); } if( m_bMultiple ) { iDatasets = 0; } if( m_pShapes != NULL ) { if( m_pShapes->Get_Selection_Count() > 0 && !m_pShapes->is_Selected(iAOI) ) { continue; } m_AOI = m_pShapes->Get_Shape(iAOI)->Get_Extent(); } if( m_bAddOverlap ) { m_AOI.Inflate(m_dOverlap, false); } else { m_dOverlap = 0.0; } if( m_AOI.Intersects(BBoxSPCVF) == INTERSECTION_None ) { SG_UI_Msg_Add(_TL("AOI does not intersect bounding box of SPCVF, nothing to do!"), true); continue; } //----------------------------------------------------- CSG_MetaData *pDatasets = SPCVF.Get_Child(SG_T("Datasets")); CSG_Strings sFilePaths; for(int i=0; iGet_Children_Count(); i++) { CSG_MetaData *pDataset = pDatasets->Get_Child(i); CSG_MetaData *pBBox = pDataset->Get_Child(SG_T("BBox")); pBBox->Get_Property(SG_T("XMin"), dBBoxXMin); pBBox->Get_Property(SG_T("YMin"), dBBoxYMin); pBBox->Get_Property(SG_T("XMax"), dBBoxXMax); pBBox->Get_Property(SG_T("YMax"), dBBoxYMax); CSG_Rect BBox(dBBoxXMin, dBBoxYMin, dBBoxXMax, dBBoxYMax); if( m_AOI.Intersects(BBox) > INTERSECTION_None ) { if( m_pShapes != NULL && !m_bAddOverlap && m_pShapes->Get_Shape(iAOI)->Intersects(BBox) == INTERSECTION_None ) { continue; } CSG_String sFilePath; pDataset->Get_Property(SG_T("File"), sFilePath); sFilePath.Prepend(sPathSPCVF); sFilePaths.Add(sFilePath); } } if( sFilePaths.Get_Count() == 0 ) { SG_UI_Msg_Add(_TL("AOI does not intersect with any bounding box of the SPCVF datasets, nothing to do!"), true); continue; } //----------------------------------------------------- CSG_Grid_System System; int x, y; if( m_bMultiple ) { dPoints = 0.0; } for(int i=0; iAssign_NoData(); } bool bFound = false; for(int iPoint=0; iPointGet_Count(); iPoint++) { if( m_AOI.Get_XMin() <= pPC->Get_X(iPoint) && pPC->Get_X(iPoint) < m_AOI.Get_XMax() && m_AOI.Get_YMin() <= pPC->Get_Y(iPoint) && pPC->Get_Y(iPoint) < m_AOI.Get_YMax() ) { if( m_pShapes != NULL && !m_bAddOverlap ) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)m_pShapes->Get_Shape(iAOI); if( !pPolygon->Contains(pPC->Get_X(iPoint), pPC->Get_Y(iPoint)) ) continue; } if( m_bConstrain ) { if( pPC->Get_Value(iPoint, m_iField) < m_dMinAttrRange || pPC->Get_Value(iPoint, m_iField) > m_dMaxAttrRange) { continue; } } if( System.Get_World_to_Grid(x, y, pPC->Get_X(iPoint), pPC->Get_Y(iPoint)) ) { switch( m_iMethod ) { default: case 0: if( pGrid->is_NoData(x, y) || pGrid->asDouble(x, y) > pPC->Get_Value(iPoint, iFieldToGrid) ) { pGrid->Set_Value(x, y, pPC->Get_Value(iPoint, iFieldToGrid)); } break; case 1: if( pGrid->is_NoData(x, y) || pGrid->asDouble(x, y) < pPC->Get_Value(iPoint, iFieldToGrid) ) { pGrid->Set_Value(x, y, pPC->Get_Value(iPoint, iFieldToGrid)); } break; } bFound = true; dPoints++; } } } if( bFound ) { iDatasets++; } delete( pPC ); } //--------------------------------------------------------- if( m_bMultiple ) { if( pGrid != NULL && dPoints == 0.0 ) { SG_UI_Msg_Add(_TL("AOI does not intersect with any point of the SPCVF datasets, nothing to do!"), true); delete( pGrid ); pGrid = NULL; continue; } Write_Subset(pGrid, iAOI, iDatasets, dPoints); pGrid = NULL; } } //--------------------------------------------------------- if( !m_bMultiple && pGrid != NULL) { if( pGrid != NULL && dPoints == 0.0 ) { SG_UI_Msg_Add(_TL("AOI does not intersect with any point of the SPCVF datasets, nothing to do!"), true); delete( pGrid ); return( true ); } Write_Subset(pGrid, 0, iDatasets, dPoints); } return( true ); } //--------------------------------------------------------- void CPointCloud_Get_Grid_SPCVF_Base::Write_Subset(CSG_Grid *pGrid, int iAOI, int iDatasets, double dPoints) { CSG_String sPath = SG_T(""); if( m_pFilePath != NULL ) { sPath = m_pFilePath->asString(); sPath += SG_T("/"); } if( m_bMultiple ) { if( m_iFieldName > -1 ) { pGrid->Set_Name(CSG_String::Format(SG_T("%s%s"), sPath.c_str(), m_pShapes->Get_Record(iAOI)->asString(m_iFieldName))); } else { pGrid->Set_Name(CSG_String::Format(SG_T("%s%d_%d"), sPath.c_str(), (int)(m_AOI.Get_XMin() + m_dOverlap), (int)(m_AOI.Get_YMin() + m_dOverlap))); } } else { pGrid->Set_Name(CSG_String::Format(SG_T("%spc_subset_%s"), sPath.c_str(), SG_File_Get_Name(m_sFileName, false).c_str())); } SG_UI_Msg_Add(CSG_String::Format(_TL("%.0f points from %d dataset(s) written to output grid %s."), dPoints, iDatasets, pGrid->Get_Name()), true); if( m_pFilePath == NULL ) { m_pGridList->Add_Item(pGrid); } else { pGrid->Save(pGrid->Get_Name()); delete( pGrid ); } return; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_Get_Grid_SPCVF::CPointCloud_Get_Grid_SPCVF(void) { Set_Name (_TL("Get Grid from Virtual Point Cloud")); Set_Author (SG_T("V. Wichmann, LASERDATA GmbH (c) 2014")); Set_Description (_TW( "The module allows one to retrieve a grid from a virtual " "point cloud dataset by applying the provided area-of-interest " "(AOI). The extent of the AOI can be provided either as polygon " "shapefile, grid or by coordinates. Optionally, an overlap can " "be added to the AOI. In case an overlap is used and the AOI " "is provided as polygon shapfile, only the bounding boxes of the " "polygons are used.\n" "With polygon shapefiles additional functionality is available:\n" "* in case one or more polygons are selected, only the selected " "polygons are used.\n" "* in case the shapefile contains several polygons a grid " "dataset is outputted for each polygon. In case the " "'Tilename' attribute is provided, the output files are named " "by this attribute. Otherwise the output file names are build " "from the lower left coordinate of each tile.\n" "The derived datasets can be outputted either as grid " "list or written to an output directory. For the latter, " "you must provide a valid file path with the 'Optional Output " "Filepath' parameter.\n" "Optionally, the query can be constrained by providing an " "attribute field and a value range that must be met.\n" "A virtual point cloud dataset is a simple XML format " "with the file extension .spcvf, which can be created " "with the 'Create Virtual Point Cloud Dataset' module.\n\n" )); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILENAME" , _TL("Filename"), _TL("The full path and name of the .spcvf file"), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("SAGA Point Cloud Virtual Format (*.spcvf)") , SG_T("*.spcvf"), _TL("All Files") , SG_T("*.*") ) ); Parameters.Add_Grid_List( NULL , "GRID_OUT" , _TL("Grid"), _TL("The output grid(s)"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILEPATH" , _TL("Optional Output Filepath"), _TL("The full path to which the output(s) should be written. Leave empty to output the datasets as grid list."), (const wchar_t *)0, (const wchar_t *)0, true, true, false ); Parameters.Add_Value( NULL , "ATTR_FIELD_GRID" , _TL("Attribute Field to Grid"), _TL("The attribute field to grid. Field numbers start with 1, so elevation is attribute field 3."), PARAMETER_TYPE_Int, 1, 3, true ); Parameters.Add_Value( NULL , "CELL_SIZE" , _TL("Cellsize"), _TL("Cellsize of the output grid [map units]"), PARAMETER_TYPE_Double, 1.0, 0.001, true ); Parameters.Add_Choice( NULL , "GRID_SYSTEM_FIT" , _TL("Grid System Fit"), _TL("Choose how to align the ouput grid system to the AOI"), CSG_String::Format(SG_T("%s|%s|"), _TL("nodes"), _TL("cells") ), 1 ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Aggregation"), _TL("Choose how to aggregate the values"), CSG_String::Format(SG_T("%s|%s|"), _TL("lowest"), _TL("highest") ), 1 ); Parameters.Add_Value( NULL , "CONSTRAIN_QUERY" , _TL("Constrain Query"), _TL("Check this parameter to constrain the query by an attribute range."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( Parameters("CONSTRAIN_QUERY") , "ATTR_FIELD" , _TL("Attribute Field"), _TL("The attribute field to use as constraint. Field numbers start with 1."), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Range( Parameters("CONSTRAIN_QUERY") , "VALUE_RANGE" , _TL("Value Range"), _TL("Minimum and maximum of attribute range []."), 2.0, 2.0 ); CSG_Parameter *pNode = Parameters.Add_Node(NULL, "NODE_AOI", _TL("AOI"), _TL("AOI Input Settings")); CSG_Parameter *pNodeField = Parameters.Add_Shapes( pNode , "AOI_SHP" , _TL("Shape"), _TL("Shapefile describing the AOI."), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field( pNodeField , "FIELD_TILENAME", _TL("Tilename"), _TL("Attribute used for naming the output file(s)"), true ); Parameters.Add_Grid( pNode , "AOI_GRID" , _TL("Grid"), _TL("Grid describing the AOI."), PARAMETER_INPUT_OPTIONAL, false ); Parameters.Add_Range( pNode , "AOI_XRANGE" , _TL("X-Extent"), _TL("Minimum and maximum x-coordinate of AOI."), 0.0, 0.0 ); Parameters.Add_Range( pNode , "AOI_YRANGE" , _TL("Y-Extent"), _TL("Minimum and maximum y-coordinate of AOI."), 0.0, 0.0 ); Parameters.Add_Value( pNode , "AOI_ADD_OVERLAP" , _TL("Add Overlap"), _TL("Add overlap to AOI"), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( Parameters("AOI_ADD_OVERLAP") , "OVERLAP" , _TL("Overlap"), _TL("Overlap [map units]"), PARAMETER_TYPE_Double, 50.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPointCloud_Get_Grid_SPCVF::On_Execute(void) { CSG_String sFileName; CSG_Parameter_Grid_List *pGridList = NULL; CSG_Parameter_File_Name *pFilePath = NULL; int iFieldToGrid; double dCellsize; bool bFitToCells; int iMethod; bool bConstrain; int iField; double dMinAttrRange, dMaxAttrRange; CSG_Shapes *pShapes; int iFieldName; CSG_Grid *pAOIGrid = NULL; double dAoiXMin, dAoiYMin, dAoiXMax, dAoiYMax; bool bAddOverlap; double dOverlap; bool bMultiple; int iOutputs = 1; CSG_Rect AOI; //----------------------------------------------------- sFileName = Parameters("FILENAME")->asString(); pGridList = Parameters("GRID_OUT")->asGridList(); pFilePath = Parameters("FILEPATH")->asFilePath(); iFieldToGrid = Parameters("ATTR_FIELD_GRID")->asInt() - 1; dCellsize = Parameters("CELL_SIZE")->asDouble(); bFitToCells = Parameters("GRID_SYSTEM_FIT")->asBool(); iMethod = Parameters("METHOD")->asInt(); bConstrain = Parameters("CONSTRAIN_QUERY")->asBool(); iField = Parameters("ATTR_FIELD")->asInt() - 1; dMinAttrRange = Parameters("VALUE_RANGE")->asRange()->Get_LoVal(); dMaxAttrRange = Parameters("VALUE_RANGE")->asRange()->Get_HiVal(); pShapes = Parameters("AOI_SHP")->asShapes(); iFieldName = Parameters("FIELD_TILENAME")->asInt(); pAOIGrid = Parameters("AOI_GRID")->asGrid(); dAoiXMin = Parameters("AOI_XRANGE")->asRange()->Get_LoVal(); dAoiXMax = Parameters("AOI_XRANGE")->asRange()->Get_HiVal(); dAoiYMin = Parameters("AOI_YRANGE")->asRange()->Get_LoVal(); dAoiYMax = Parameters("AOI_YRANGE")->asRange()->Get_HiVal(); bAddOverlap = Parameters("AOI_ADD_OVERLAP")->asBool(); dOverlap = Parameters("OVERLAP")->asDouble(); if( pShapes == NULL ) { bMultiple = false; } else { bMultiple = true; } CSG_String sPath = pFilePath->asString(); if( sPath.Length() <= 1 ) { pFilePath = NULL; } //----------------------------------------------------- if( pShapes == NULL && pAOIGrid == NULL && (dAoiXMin == dAoiXMax || dAoiYMin == dAoiYMax) ) { SG_UI_Msg_Add_Error(_TL("Please provide a valid AOI!")); return( false ); } //----------------------------------------------------- if( pShapes != NULL ) { iOutputs = pShapes->Get_Count(); } else if( pAOIGrid != NULL ) { AOI = pAOIGrid->Get_System().Get_Extent(); } else { AOI.Assign(dAoiXMin, dAoiYMin, dAoiXMax, dAoiYMax); } //--------------------------------------------------------- m_Get_Grid_SPCVF.Initialise(iOutputs, AOI, pShapes, iFieldName, bMultiple, bAddOverlap, dOverlap, sFileName, pFilePath, pGridList, dCellsize, bFitToCells, iMethod, bConstrain, iField, dMinAttrRange, dMaxAttrRange); bool bResult = m_Get_Grid_SPCVF.Get_Subset(iFieldToGrid); m_Get_Grid_SPCVF.Finalise(); return( bResult ); } //--------------------------------------------------------- int CPointCloud_Get_Grid_SPCVF::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CONSTRAIN_QUERY")) ) { pParameters->Get_Parameter("ATTR_FIELD" )->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("VALUE_RANGE" )->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("AOI_ADD_OVERLAP")) ) { pParameters->Get_Parameter("OVERLAP" )->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("AOI_SHP")) ) { pParameters->Get_Parameter("FIELD_TILENAME" )->Set_Enabled(pParameter->asShapes() != NULL); } //----------------------------------------------------- return (1); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_Get_Grid_SPCVF_Interactive::CPointCloud_Get_Grid_SPCVF_Interactive(void) { Set_Name (_TL("Get Grid from Virtual Point Cloud")); Set_Author (SG_T("V. Wichmann, LASERDATA GmbH (c) 2014")); Set_Description (_TW( "The module allows one to retrieve a grid from a virtual " "point cloud dataset by dragging a box (AOI) in a Map View.\n" "Optionally, the query can be constrained by providing an " "attribute field and a value range that must be met.\n" "A virtual point cloud dataset is a simple XML format " "with the file extension .spcvf, which can be created " "with the 'Create Virtual Point Cloud Dataset' module.\n\n" )); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILENAME" , _TL("Filename"), _TL("The full path and name of the .spcvf file"), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("SAGA Point Cloud Virtual Format (*.spcvf)") , SG_T("*.spcvf"), _TL("All Files") , SG_T("*.*") ) ); Parameters.Add_Grid_List( NULL , "GRID_OUT" , _TL("Grid"), _TL("The output grid(s)"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "ATTR_FIELD_GRID" , _TL("Attribute Field to Grid"), _TL("The attribute field to grid. Field numbers start with 1, so elevation is attribute field 3."), PARAMETER_TYPE_Int, 1, 3, true ); Parameters.Add_Value( NULL , "CELL_SIZE" , _TL("Cellsize"), _TL("Cellsize of the output grid [map units]"), PARAMETER_TYPE_Double, 1.0, 0.001, true ); Parameters.Add_Choice( NULL , "GRID_SYSTEM_FIT" , _TL("Grid System Fit"), _TL("Choose how to align the ouput grid system to the AOI"), CSG_String::Format(SG_T("%s|%s|"), _TL("nodes"), _TL("cells") ), 1 ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Aggregation"), _TL("Choose how to aggregate the values"), CSG_String::Format(SG_T("%s|%s|"), _TL("lowest"), _TL("highest") ), 1 ); Parameters.Add_Value( NULL , "CONSTRAIN_QUERY" , _TL("Constrain Query"), _TL("Check this parameter to constrain the query by an attribute range."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( Parameters("CONSTRAIN_QUERY") , "ATTR_FIELD" , _TL("Attribute Field"), _TL("The attribute field to use as constraint. Field numbers start with 1."), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Range( Parameters("CONSTRAIN_QUERY") , "VALUE_RANGE" , _TL("Value Range"), _TL("Minimum and maximum of attribute range []."), 2.0, 2.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPointCloud_Get_Grid_SPCVF_Interactive::On_Execute(void) { return( true ); } //--------------------------------------------------------- bool CPointCloud_Get_Grid_SPCVF_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 AOI(m_ptDown.Get_X(), m_ptDown.Get_Y(), ptWorld.Get_X(), ptWorld.Get_Y()); // as long as this module only supports to drag a box, we initialize it with a fake overlap in order // to use CSG_Rect instead of CSG_Shape for point in polygon check in Get_Subset(): m_Get_Grid_SPCVF.Initialise(1, AOI, NULL, -1, false, true, 0.0, Parameters("FILENAME")->asString(), NULL, Parameters("GRID_OUT")->asGridList(), Parameters("CELL_SIZE")->asDouble(), Parameters("GRID_SYSTEM_FIT")->asBool(), Parameters("METHOD")->asInt(), Parameters("CONSTRAIN_QUERY")->asBool(), Parameters("ATTR_FIELD")->asInt()-1, Parameters("VALUE_RANGE")->asRange()->Get_LoVal(), Parameters("VALUE_RANGE")->asRange()->Get_HiVal()); bool bResult = m_Get_Grid_SPCVF.Get_Subset(Parameters("ATTR_FIELD_GRID")->asInt()-1); if( bResult ) { CSG_Grid *pGrid = Parameters("GRID_OUT")->asGridList()->asGrid(Parameters("GRID_OUT")->asGridList()->Get_Count()-1); DataObject_Update(pGrid, SG_UI_DATAOBJECT_SHOW_LAST_MAP); } m_Get_Grid_SPCVF.Finalise(); return( bResult ); } return( false ); } //--------------------------------------------------------- int CPointCloud_Get_Grid_SPCVF_Interactive::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CONSTRAIN_QUERY")) ) { pParameters->Get_Parameter("ATTR_FIELD" )->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("VALUE_RANGE" )->Set_Enabled(pParameter->asBool()); } //----------------------------------------------------- return (1); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_virtual/pc_remove_overlap_from_spcvf.cpp0000664000175000017500000002170012565125414027256 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_remove_overlap_from_spcvf.cpp 2359 2014-12-27 12:46:46Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // pc_remove_overlap_from_spcvf.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_remove_overlap_from_spcvf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_Remove_Overlap_From_SPCVF::CPointCloud_Remove_Overlap_From_SPCVF(void) { Set_Name (_TL("Remove Overlap from Virtual Point Cloud Tiles")); Set_Author (SG_T("V. Wichmann, LASERDATA GmbH (c) 2014")); Set_Description (_TW( "The module allows to remove the overlap from point cloud " "tiles created from a virtual point cloud dataset. The " "tiles must have been created with an overlap and a spcvf " "tile info file must have been outputted too. The latter " "decribes the original bounding boxes of the tiles (i.e. " "without overlap) and is used by this module to remove " "the overlap.\n" "A virtual point cloud dataset is a simple XML format " "with the file extension .spcvf, which can be created " "with the 'Create Virtual Point Cloud Dataset' module. " "Point cloud tiles with an overlap are usually created " "from such an virtual point cloud dataset with the " "'Get Subset from Virtual Point Cloud' module.\n\n" )); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILENAME" , _TL("Tile Info File"), _TL("The full path and name of the spcvf tile info file describing the point cloud tiles without overlap"), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("SAGA Point Cloud Virtual Format Tile Info (*.spcvf_tile_info)"), SG_T("*.spcvf_tile_info"), _TL("All Files") , SG_T("*.*") ) ); Parameters.Add_FilePath( NULL , "FILEPATH" , _TL("Output Filepath"), _TL("The full path to which the point cloud tiles without overlap should be written."), (const wchar_t *)0, (const wchar_t *)0, true, true, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPointCloud_Remove_Overlap_From_SPCVF::On_Execute(void) { CSG_String sFileName; CSG_Parameter_File_Name *pFilePath = NULL; CSG_MetaData SPCVF_Tile_Info; CSG_String sPathSPCVF, sFilePath; double dBBoxXMin, dBBoxYMin, dBBoxXMax, dBBoxYMax; //----------------------------------------------------- sFileName = Parameters("FILENAME")->asString(); pFilePath = Parameters("FILEPATH")->asFilePath(); //----------------------------------------------------- if( !pFilePath->is_Valid() || !pFilePath->is_Directory() ) { SG_UI_Msg_Add_Error(_TL("Please provide a valid output file path!")); return( false ); } if( !SPCVF_Tile_Info.Create(sFileName) || SPCVF_Tile_Info.Get_Name().CmpNoCase(SG_T("SPCVF_Tile_Info")) ) { SG_UI_Msg_Add_Error(_TL("Please provide a valid *.scpvf_tile_info file!")); return( false ); } //----------------------------------------------------- CSG_String sMethodPaths; SPCVF_Tile_Info.Get_Property(SG_T("Paths"), sMethodPaths); if( !sMethodPaths.CmpNoCase(SG_T("absolute")) ) { sPathSPCVF = SG_T(""); } else if( !sMethodPaths.CmpNoCase(SG_T("relative")) ) { sPathSPCVF = SG_File_Get_Path(sFileName); sPathSPCVF.Replace(SG_T("\\"), SG_T("/")); } else { SG_UI_Msg_Add_Error(_TL("Encountered invalid path description in *.spcvf_tile_info file!")); return( false ); } //----------------------------------------------------- CSG_MetaData *pDatasets = SPCVF_Tile_Info.Get_Child(SG_T("Tiles")); for(int i=0; iGet_Children_Count(); i++) { CSG_MetaData *pDataset = pDatasets->Get_Child(i); CSG_MetaData *pBBox = pDataset->Get_Child(SG_T("BBox")); pBBox->Get_Property(SG_T("XMin"), dBBoxXMin); pBBox->Get_Property(SG_T("YMin"), dBBoxYMin); pBBox->Get_Property(SG_T("XMax"), dBBoxXMax); pBBox->Get_Property(SG_T("YMax"), dBBoxYMax); CSG_Rect BBox(dBBoxXMin, dBBoxYMin, dBBoxXMax, dBBoxYMax); CSG_String sFilePath; pDataset->Get_Property(SG_T("File"), sFilePath); sFilePath.Prepend(sPathSPCVF); //----------------------------------------------------- CSG_PointCloud *pPC = SG_Create_PointCloud(sFilePath); CSG_PointCloud *pPC_out = SG_Create_PointCloud(pPC); for(int iPoint=0; iPointGet_Count(); iPoint++) { if( dBBoxXMin <= pPC->Get_X(iPoint) && pPC->Get_X(iPoint) < dBBoxXMax && dBBoxYMin <= pPC->Get_Y(iPoint) && pPC->Get_Y(iPoint) < dBBoxYMax ) { pPC_out->Add_Point(pPC->Get_X(iPoint), pPC->Get_Y(iPoint), pPC->Get_Z(iPoint)); for(int iField=0; iFieldGet_Attribute_Count(); iField++) { pPC_out->Set_Attribute(iField, pPC->Get_Attribute(iPoint, iField)); } } } if( pPC_out->Get_Point_Count() > 0 ) { CSG_String sPath; sPath = pFilePath->asString(); sPath += SG_T("/"); pPC_out->Set_Name(CSG_String::Format(SG_T("%s%s"), sPath.c_str(), SG_File_Get_Name(pPC->Get_Name(), false).c_str())); pPC_out->Save(pPC_out->Get_Name()); } else { SG_UI_Msg_Add(CSG_String::Format(_TL("Point Cloud %s is empty after removing overlap, skipping dataset!"), SG_File_Get_Name(pPC->Get_Name(), false).c_str()), true); } delete( pPC ); delete( pPC_out ); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_virtual/pc_create_spcvf.h0000664000175000017500000001073412565125414024123 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_create_spcvf.h 1976 2014-02-09 15:05:12Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // pc_create_spcvf.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pc_create_spcvf_H #define HEADER_INCLUDED__pc_create_spcvf_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPointCloud_Create_SPCVF : public CSG_Module { public: CPointCloud_Create_SPCVF(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Point Cloud") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pc_create_spcvf_H saga-2.2.3/src/modules/io/io_virtual/pc_tileshape_from_spcvf.cpp0000664000175000017500000002635612565125414026223 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_tileshape_from_spcvf.cpp 2390 2015-02-02 15:11:13Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // pc_tileshape_from_spcvf.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_tileshape_from_spcvf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_Create_Tileshape_From_SPCVF::CPointCloud_Create_Tileshape_From_SPCVF(void) { Set_Name (_TL("Create Tileshape from Virtual Point Cloud")); Set_Author (SG_T("V. Wichmann, LASERDATA GmbH (c) 2014")); Set_Description (_TW( "The module allows to create a polygon shapefile with the " "bounding boxes of a virtual point cloud dataset. Additionally, " "the header information of the chosen virtual point cloud " "dataset is reported (since SPCVFDataset version 1.1).\n" "A virtual point cloud dataset is a simple XML format " "with the file extension .spcvf, which can be created " "with the 'Create Virtual Point Cloud Dataset' module.\n\n" )); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILENAME" , _TL("Filename"), _TL("The full path and name of the .spcvf file"), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("SAGA Point Cloud Virtual Format (*.spcvf)") , SG_T("*.spcvf"), _TL("All Files") , SG_T("*.*") ) ); Parameters.Add_Shapes( NULL , "TILE_SHP" , _TL("Tileshape"), _TL("Polygon shapefile describing the bounding boxes of spcvf tiles."), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPointCloud_Create_Tileshape_From_SPCVF::On_Execute(void) { CSG_String sFileName; CSG_Shapes *pShapes; CSG_MetaData SPCVF; CSG_String sPathSPCVF, sFilePath; int iPoints; double dBBoxXMin, dBBoxYMin, dBBoxXMax, dBBoxYMax, dZMin, dZMax; //----------------------------------------------------- sFileName = Parameters("FILENAME")->asString(); pShapes = Parameters("TILE_SHP")->asShapes(); //----------------------------------------------------- if( !SPCVF.Create(sFileName) || SPCVF.Get_Name().CmpNoCase(SG_T("SPCVFDataset")) ) { SG_UI_Msg_Add_Error(_TL("Please provide a valid *.scpvf file!")); return( false ); } //----------------------------------------------------- CSG_String sMethodPaths; SPCVF.Get_Property(SG_T("Paths"), sMethodPaths); if( !sMethodPaths.CmpNoCase(SG_T("absolute")) ) { sPathSPCVF = SG_T(""); } else if( !sMethodPaths.CmpNoCase(SG_T("relative")) ) { sPathSPCVF = SG_File_Get_Path(sFileName); sPathSPCVF.Replace(SG_T("\\"), SG_T("/")); } else { SG_UI_Msg_Add_Error(_TL("Encountered invalid path description in *.spcvf file!")); return( false ); } //----------------------------------------------------- CSG_MetaData *pSPCVFHeader = SPCVF.Get_Child(SG_T("Header")); if( pSPCVFHeader != NULL ) // i.e. we have a file version >= 1.1 { int iValue; double dValue; CSG_String sValue; CSG_Projection projSPCVF; SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL("Metadata from Header:"), true); pSPCVFHeader->Get_Child(SG_T("Datasets"))->Get_Property(SG_T("Count"), iValue); SG_UI_Msg_Add(CSG_String::Format(_TL("Total number of referenced datasets: %d"), iValue), true); pSPCVFHeader->Get_Child(SG_T("Points"))->Get_Property(SG_T("Count"), sValue); SG_UI_Msg_Add(CSG_String::Format(_TL("Total number of points: %s"), sValue.c_str()), true); pSPCVFHeader->Get_Child(SG_T("SRS"))->Get_Property(SG_T("Projection"), sValue); SG_UI_Msg_Add(CSG_String::Format(_TL("Spatial Reference System: %s"), sValue.c_str()), true); if( pSPCVFHeader->Get_Child(SG_T("SRS"))->Get_Property(SG_T("WKT"), sValue) ) SG_UI_Msg_Add(CSG_String::Format(_TL("WKT: %s"), sValue.c_str()), true); pSPCVFHeader->Get_Child(SG_T("NoData"))->Get_Property(SG_T("Value"), dValue); SG_UI_Msg_Add(CSG_String::Format(_TL("NoData Value: %.6f"), dValue), true); SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL("Overall Bounding Box:"), true); pSPCVFHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("XMin"), dValue); SG_UI_Msg_Add(CSG_String::Format(_TL("XMin: %.6f"), dValue), true); pSPCVFHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("YMin"), dValue); SG_UI_Msg_Add(CSG_String::Format(_TL("YMin: %.6f"), dValue), true); pSPCVFHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("XMax"), dValue); SG_UI_Msg_Add(CSG_String::Format(_TL("XMax: %.6f"), dValue), true); pSPCVFHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("YMax"), dValue); SG_UI_Msg_Add(CSG_String::Format(_TL("YMax: %.6f"), dValue), true); pSPCVFHeader->Get_Child(SG_T("ZStats"))->Get_Property(SG_T("ZMin"), dValue); SG_UI_Msg_Add(CSG_String::Format(_TL("ZMin: %.6f"), dValue), true); pSPCVFHeader->Get_Child(SG_T("ZStats"))->Get_Property(SG_T("ZMax"), dValue); SG_UI_Msg_Add(CSG_String::Format(_TL("ZMax: %.6f"), dValue), true); SG_UI_Msg_Add(SG_T(""), true); pSPCVFHeader->Get_Child(SG_T("Attributes"))->Get_Property(SG_T("Count"), iValue); SG_UI_Msg_Add(CSG_String::Format(_TL("Number of attribute fields: %d"), iValue), true); for (int iField=0; iFieldGet_Child(SG_T("Attributes"))->Get_Child(CSG_String::Format(SG_T("Field_%d"), iField + 1)); pField->Get_Property(SG_T("Name"), sValue); SG_UI_Msg_Add(CSG_String::Format(_TL("Field %d: Name=\"%s\" "), iField + 1, sValue.c_str()), true); pField->Get_Property(SG_T("Type"), sValue); SG_UI_Msg_Add(CSG_String::Format(_TL("Type=\"%s\""), sValue.c_str()), false); } } //----------------------------------------------------- pShapes->Destroy(); pShapes->Add_Field(_TL("ID"), SG_DATATYPE_Int); pShapes->Add_Field(_TL("Filepath"), SG_DATATYPE_String); pShapes->Add_Field(_TL("File"), SG_DATATYPE_String); pShapes->Add_Field(_TL("Points"), SG_DATATYPE_Int); if( pSPCVFHeader != NULL ) { pShapes->Add_Field(_TL("ZMin"), SG_DATATYPE_Double); pShapes->Add_Field(_TL("ZMax"), SG_DATATYPE_Double); } pShapes->Set_Name(CSG_String::Format(_TL("Tileshape_%s"), SG_File_Get_Name(sFileName, false).c_str())); //----------------------------------------------------- CSG_MetaData *pDatasets = SPCVF.Get_Child(SG_T("Datasets")); for(int i=0; iGet_Children_Count(); i++) { CSG_MetaData *pDataset = pDatasets->Get_Child(i); CSG_MetaData *pBBox = pDataset->Get_Child(SG_T("BBox")); pDataset->Get_Property(SG_T("File"), sFilePath); pDataset->Get_Property(SG_T("Points"), iPoints); pBBox->Get_Property(SG_T("XMin"), dBBoxXMin); pBBox->Get_Property(SG_T("YMin"), dBBoxYMin); pBBox->Get_Property(SG_T("XMax"), dBBoxXMax); pBBox->Get_Property(SG_T("YMax"), dBBoxYMax); //----------------------------------------------------- CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Add_Point(dBBoxXMin, dBBoxYMin); pShape->Add_Point(dBBoxXMin, dBBoxYMax); pShape->Add_Point(dBBoxXMax, dBBoxYMax); pShape->Add_Point(dBBoxXMax, dBBoxYMin); pShape->Set_Value(0, i + 1); if( sPathSPCVF.Length() == 0 ) // absolute paths { pShape->Set_Value(1, sFilePath.BeforeLast('/')); pShape->Set_Value(2, sFilePath.AfterLast('/')); } else // relative paths { pShape->Set_Value(1, sPathSPCVF); pShape->Set_Value(2, sFilePath); } pShape->Set_Value(3, iPoints); if( pSPCVFHeader != NULL ) { pDataset->Get_Property(SG_T("ZMin"), dZMin); pDataset->Get_Property(SG_T("ZMax"), dZMax); pShape->Set_Value(4, dZMin); pShape->Set_Value(5, dZMax); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_virtual/pc_get_subset_spcvf.h0000664000175000017500000001503112565125414025017 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_get_subset_spcvf.h 2384 2015-02-01 15:18:44Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // pc_get_subset_spcvf.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pc_get_subset_spcvf_H #define HEADER_INCLUDED__pc_get_subset_spcvf_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPointCloud_Get_Subset_SPCVF_Base { public: CPointCloud_Get_Subset_SPCVF_Base(void); virtual ~CPointCloud_Get_Subset_SPCVF_Base(void); bool Initialise (int iOutputs, CSG_Rect AOI, CSG_Shapes *pShapes, int iFieldName, bool bMultiple, bool bAddOverlap, double dOverlap, CSG_String sFileNameTileInfo, CSG_String sFilename, CSG_Parameter_File_Name *pFilePath, CSG_Parameter_PointCloud_List *pPointCloudList, bool bConstrain, int iField, double dMinAttrRange, double dMaxAttrRange, bool bCopyAttr, CSG_String sAttrList); void Finalise (void); bool Get_Subset (bool bCopyAttr); void Write_Subset(CSG_PointCloud *pPC_out, int iAOI, int iDatasets, CSG_MetaData *pSPCVF_Tiles, bool bAbsolutePaths); protected: private: int m_iOutputs; CSG_Rect m_AOI; CSG_Shapes *m_pShapes; int m_iFieldName; bool m_bMultiple, m_bAddOverlap; double m_dOverlap; CSG_String m_sFileNameTileInfo; CSG_String m_sFileName; CSG_Parameter_File_Name *m_pFilePath; CSG_Parameter_PointCloud_List *m_pPointCloudList; bool m_bConstrain; int m_iField; double m_dMinAttrRange, m_dMaxAttrRange; std::vector m_vAttrMapper; }; //--------------------------------------------------------- class CPointCloud_Get_Subset_SPCVF : public CSG_Module { public: CPointCloud_Get_Subset_SPCVF(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Point Cloud") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: CPointCloud_Get_Subset_SPCVF_Base m_Get_Subset_SPCVF; }; //--------------------------------------------------------- class CPointCloud_Get_Subset_SPCVF_Interactive : public CSG_Module_Interactive { public: CPointCloud_Get_Subset_SPCVF_Interactive(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Point Cloud") ); } protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: CSG_Point m_ptDown; CPointCloud_Get_Subset_SPCVF_Base m_Get_Subset_SPCVF; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pc_get_subset_spcvf_H saga-2.2.3/src/modules/io/io_virtual/pc_remove_overlap_from_spcvf.h0000664000175000017500000001105212565125414026722 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_remove_overlap_from_spcvf.h 2359 2014-12-27 12:46:46Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // pc_remove_overlap_from_spcvf.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pc_remove_overlap_from_spcvf_H #define HEADER_INCLUDED__pc_remove_overlap_from_spcvf_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPointCloud_Remove_Overlap_From_SPCVF : public CSG_Module { public: CPointCloud_Remove_Overlap_From_SPCVF(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Point Cloud") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pc_remove_overlap_from_spcvf_H saga-2.2.3/src/modules/io/io_virtual/MLB_Interface.cpp0000664000175000017500000001214512565125414023720 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 2359 2014-12-27 12:46:46Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Virtual") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("SAGA User Group Associaton (c) 2014") ); case MLB_INFO_Description: return( _TL("Tools for the handling of virtual datasets.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Virtual") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "pc_create_spcvf.h" #include "pc_get_subset_spcvf.h" #include "pc_tileshape_from_spcvf.h" #include "pc_get_grid_spcvf.h" #include "pc_remove_overlap_from_spcvf.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CPointCloud_Create_SPCVF ); case 1: return( new CPointCloud_Get_Subset_SPCVF ); case 2: return( new CPointCloud_Create_Tileshape_From_SPCVF ); case 3: return( new CPointCloud_Get_Subset_SPCVF_Interactive ); case 4: return( new CPointCloud_Get_Grid_SPCVF ); case 5: return( new CPointCloud_Get_Grid_SPCVF_Interactive ); case 6: return( new CPointCloud_Remove_Overlap_From_SPCVF ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/io/io_virtual/Makefile.am0000664000175000017500000000224112565125414022652 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 2359 2014-12-27 12:46:46Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LFLG) pkglib_LTLIBRARIES = libio_virtual.la libio_virtual_la_SOURCES =\ MLB_Interface.cpp\ pc_tileshape_from_spcvf.cpp\ pc_create_spcvf.cpp\ pc_get_grid_spcvf.cpp\ pc_get_subset_spcvf.cpp\ pc_remove_overlap_from_spcvf.cpp\ MLB_Interface.h\ pc_tileshape_from_spcvf.h\ pc_create_spcvf.h\ pc_get_grid_spcvf.h\ pc_get_subset_spcvf.h\ pc_remove_overlap_from_spcvf.h libio_virtual_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) saga-2.2.3/src/modules/io/io_virtual/MLB_Interface.h0000664000175000017500000000771012565125414023367 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1976 2014-02-09 15:05:12Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_virtual_H #define HEADER_INCLUDED__io_virtual_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_virtual_EXPORTS #define io_virtual_EXPORT _SAGA_DLL_EXPORT #else #define io_virtual_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_virtual_H saga-2.2.3/src/modules/io/io_virtual/pc_get_subset_spcvf.cpp0000664000175000017500000007742312565125414025367 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_get_subset_spcvf.cpp 2439 2015-03-16 13:35:26Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // pc_get_subset_spcvf.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_get_subset_spcvf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_Get_Subset_SPCVF_Base::CPointCloud_Get_Subset_SPCVF_Base(void) { m_pShapes = NULL; m_pFilePath = NULL; m_pPointCloudList = NULL; m_vAttrMapper.clear(); } //--------------------------------------------------------- CPointCloud_Get_Subset_SPCVF_Base::~CPointCloud_Get_Subset_SPCVF_Base(void) { Finalise(); } //--------------------------------------------------------- bool CPointCloud_Get_Subset_SPCVF_Base::Initialise(int iOutputs, CSG_Rect AOI, CSG_Shapes *pShapes, int iFieldName, bool bMultiple, bool bAddOverlap, double dOverlap, CSG_String sFileNameTileInfo, CSG_String sFileName, CSG_Parameter_File_Name *pFilePath, CSG_Parameter_PointCloud_List *pPointCloudList, bool bConstrain, int iField, double dMinAttrRange, double dMaxAttrRange, bool bCopyAttr, CSG_String sAttrList) { m_iOutputs = iOutputs; m_AOI = AOI; m_pShapes = pShapes; m_iFieldName = iFieldName; m_bMultiple = bMultiple; m_bAddOverlap = bAddOverlap; m_dOverlap = dOverlap; m_sFileNameTileInfo = sFileNameTileInfo; m_sFileName = sFileName; m_pFilePath = pFilePath; m_pPointCloudList = pPointCloudList; m_bConstrain = bConstrain; m_iField = iField; m_dMinAttrRange = dMinAttrRange; m_dMaxAttrRange = dMaxAttrRange; if (!bCopyAttr) { CSG_String_Tokenizer tkz_fields(sAttrList, ";", SG_TOKEN_STRTOK); CSG_String token; int iValue; std::vector vValues; while( tkz_fields.Has_More_Tokens() ) { token = tkz_fields.Get_Next_Token(); if( token.Length() == 0 ) break; if( !token.asInt(iValue) ) { SG_UI_Msg_Add_Error(_TL("Error parsing attribute fields: can't convert to number!")); return( false ); } iValue -= 1; if( iValue < 0) { SG_UI_Msg_Add_Error(_TL("Error parsing attribute fields: field index out of range!")); return( false ); } else vValues.push_back(iValue); } std::sort(vValues.begin(), vValues.end()); if( vValues.at(0) != 0 || vValues.at(1) != 1 || vValues.at(2) != 2) { SG_UI_Msg_Add_Error(_TL("Attribute fields one to three (x;y;z) are mandatory!")); return( false ); } m_vAttrMapper.clear(); for(int i=3; i<(int)vValues.size(); i++) { m_vAttrMapper.push_back(vValues.at(i) - 3); } } return( true ); } //--------------------------------------------------------- void CPointCloud_Get_Subset_SPCVF_Base::Finalise(void) { m_pShapes = NULL; m_pFilePath = NULL; m_pPointCloudList = NULL; m_vAttrMapper.clear(); return; } //--------------------------------------------------------- bool CPointCloud_Get_Subset_SPCVF_Base::Get_Subset(bool bCopyAttr) { CSG_String sVersion, sPathSPCVF, sMethodPaths; double dBBoxXMin, dBBoxYMin, dBBoxXMax, dBBoxYMax; CSG_Rect BBoxSPCVF; CSG_MetaData SPCVF; CSG_MetaData SPCVF_Tile_Info; CSG_MetaData *pSPCVF_Tiles = NULL; bool bAbsolutePaths = false; //----------------------------------------------------- if( !SPCVF.Create(m_sFileName) || SPCVF.Get_Name().CmpNoCase(SG_T("SPCVFDataset")) ) { SG_UI_Msg_Add_Error(_TL("Please provide a valid *.scpvf file!")); return( false ); } if( !bCopyAttr || m_bConstrain ) { CSG_MetaData *pHeader = SPCVF.Get_Child(SG_T("Header")); if( pHeader != NULL ) { int iFieldCount; pHeader->Get_Child(SG_T("Attributes"))->Get_Property(SG_T("Count"), iFieldCount); if( !bCopyAttr ) { if( m_vAttrMapper.at(m_vAttrMapper.size()-1) >= iFieldCount-3 ) { SG_UI_Msg_Add_Error(_TL("Attribute field number to copy is out of range!")); return( false ); } } if( m_bConstrain ) { if( m_iField < 0 || m_iField >= iFieldCount ) { SG_UI_Msg_Add_Error(_TL("Constraining attribute field number is out of range!")); return( false ); } } } } //----------------------------------------------------- SPCVF.Get_Property(SG_T("Version"), sVersion); SPCVF.Get_Property(SG_T("Paths"), sMethodPaths); if( !sMethodPaths.CmpNoCase(SG_T("absolute")) ) { sPathSPCVF = SG_T(""); bAbsolutePaths = true; } else if( !sMethodPaths.CmpNoCase(SG_T("relative")) ) { sPathSPCVF = SG_File_Get_Path(m_sFileName); sPathSPCVF.Replace(SG_T("\\"), SG_T("/")); } else { SG_UI_Msg_Add_Error(_TL("Encountered invalid path description in *.spcvf file!")); return( false ); } //----------------------------------------------------- if( !sVersion.CmpNoCase(SG_T("1.0")) ) { SPCVF.Get_Child(SG_T("BBox"))->Get_Property(SG_T("XMin"), dBBoxXMin); SPCVF.Get_Child(SG_T("BBox"))->Get_Property(SG_T("YMin"), dBBoxYMin); SPCVF.Get_Child(SG_T("BBox"))->Get_Property(SG_T("XMax"), dBBoxXMax); SPCVF.Get_Child(SG_T("BBox"))->Get_Property(SG_T("YMax"), dBBoxYMax); } else // 1.1 { CSG_MetaData *pHeader = SPCVF.Get_Child(SG_T("Header")); pHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("XMin"), dBBoxXMin); pHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("YMin"), dBBoxYMin); pHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("XMax"), dBBoxXMax); pHeader->Get_Child(SG_T("BBox"))->Get_Property(SG_T("YMax"), dBBoxYMax); } BBoxSPCVF.Assign(dBBoxXMin, dBBoxYMin, dBBoxXMax, dBBoxYMax); //----------------------------------------------------- if( !m_sFileNameTileInfo.is_Empty() ) { SPCVF_Tile_Info.Set_Name(SG_T("SPCVF_Tile_Info")); SPCVF_Tile_Info.Add_Property(SG_T("Version"), SG_T("1.0")); if( bAbsolutePaths ) { SPCVF_Tile_Info.Add_Property(SG_T("Paths"), SG_T("absolute")); } else { SPCVF_Tile_Info.Add_Property(SG_T("Paths"), SG_T("relative")); } pSPCVF_Tiles = SPCVF_Tile_Info.Add_Child(SG_T("Tiles")); } //----------------------------------------------------- int iDatasets = 0; CSG_PointCloud *pPC_out = NULL; for(int iAOI=0; iAOI 1 ) { SG_UI_Process_Set_Text(CSG_String::Format(_TL("Processing AOI %d ..."), iAOI + 1)); } else { SG_UI_Process_Set_Text(_TL("Processing AOI ...")); } if( m_bMultiple ) { iDatasets = 0; } if( m_pShapes != NULL ) { if( m_pShapes->Get_Selection_Count() > 0 && !m_pShapes->is_Selected(iAOI) ) { continue; } m_AOI = m_pShapes->Get_Shape(iAOI)->Get_Extent(); } if( m_bAddOverlap ) { m_AOI.Inflate(m_dOverlap, false); } else { m_dOverlap = 0.0; } if( m_AOI.Intersects(BBoxSPCVF) == INTERSECTION_None ) { SG_UI_Msg_Add(_TL("AOI does not intersect bounding box of SPCVF, nothing to do!"), true); continue; } //----------------------------------------------------- CSG_MetaData *pDatasets = SPCVF.Get_Child(SG_T("Datasets")); CSG_Strings sFilePaths; for(int i=0; iGet_Children_Count(); i++) { CSG_MetaData *pDataset = pDatasets->Get_Child(i); CSG_MetaData *pBBox = pDataset->Get_Child(SG_T("BBox")); pBBox->Get_Property(SG_T("XMin"), dBBoxXMin); pBBox->Get_Property(SG_T("YMin"), dBBoxYMin); pBBox->Get_Property(SG_T("XMax"), dBBoxXMax); pBBox->Get_Property(SG_T("YMax"), dBBoxYMax); CSG_Rect BBox(dBBoxXMin, dBBoxYMin, dBBoxXMax, dBBoxYMax); if( m_AOI.Intersects(BBox) > INTERSECTION_None ) { if( m_pShapes != NULL && !m_bAddOverlap && m_pShapes->Get_Shape(iAOI)->Intersects(BBox) == INTERSECTION_None ) { continue; } CSG_String sFilePath; pDataset->Get_Property(SG_T("File"), sFilePath); sFilePath.Prepend(sPathSPCVF); sFilePaths.Add(sFilePath); } } if( sFilePaths.Get_Count() == 0 ) { SG_UI_Msg_Add(_TL("AOI does not intersect with any bounding box of the SPCVF datasets, nothing to do!"), true); continue; } //----------------------------------------------------- for(int i=0; i= pPC->Get_Attribute_Count() ) continue; pPC_out->Add_Field(pPC->Get_Attribute_Name(m_vAttrMapper.at(iField)), pPC->Get_Attribute_Type(m_vAttrMapper.at(iField))); } } } bool bFound = false; for(int iPoint=0; iPointGet_Count(); iPoint++) { if( m_AOI.Get_XMin() <= pPC->Get_X(iPoint) && pPC->Get_X(iPoint) < m_AOI.Get_XMax() && m_AOI.Get_YMin() <= pPC->Get_Y(iPoint) && pPC->Get_Y(iPoint) < m_AOI.Get_YMax() ) { if( m_pShapes != NULL && !m_bAddOverlap ) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)m_pShapes->Get_Shape(iAOI); if( !pPolygon->Contains(pPC->Get_X(iPoint), pPC->Get_Y(iPoint)) ) continue; } if( m_bConstrain ) { if( pPC->Get_Value(iPoint, m_iField) < m_dMinAttrRange || pPC->Get_Value(iPoint, m_iField) > m_dMaxAttrRange) { continue; } } pPC_out->Add_Point(pPC->Get_X(iPoint), pPC->Get_Y(iPoint), pPC->Get_Z(iPoint)); if( bCopyAttr ) { for(int iField=0; iFieldGet_Attribute_Count(); iField++) { pPC_out->Set_Attribute(iField, pPC->Get_Attribute(iPoint, iField)); } } else { for(int iField=0; iField<(int)m_vAttrMapper.size(); iField++) { if( iField >= pPC->Get_Attribute_Count() ) continue; pPC_out->Set_Attribute(iField, pPC->Get_Attribute(iPoint, m_vAttrMapper.at(iField))); } } bFound = true; } } if( bFound ) { iDatasets++; } delete( pPC ); } //--------------------------------------------------------- if( m_bMultiple ) { if( pPC_out != NULL && pPC_out->Get_Count() == 0 ) { SG_UI_Msg_Add(_TL("AOI does not intersect with any point of the SPCVF datasets, nothing to do!"), true); delete( pPC_out ); pPC_out = NULL; continue; } Write_Subset(pPC_out, iAOI, iDatasets, pSPCVF_Tiles, bAbsolutePaths); pPC_out = NULL; } } //--------------------------------------------------------- if( !m_bMultiple && pPC_out != NULL) { if( pPC_out != NULL && pPC_out->Get_Count() == 0 ) { SG_UI_Msg_Add(_TL("AOI does not intersect with any point of the SPCVF datasets, nothing to do!"), true); delete( pPC_out ); return( true ); } Write_Subset(pPC_out, 0, iDatasets, pSPCVF_Tiles, bAbsolutePaths); } //----------------------------------------------------- if( !m_sFileNameTileInfo.is_Empty() ) { if( !SPCVF_Tile_Info.Save(m_sFileNameTileInfo) ) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unable to save file %s!"), m_sFileNameTileInfo.c_str())); return( false ); } } return( true ); } //--------------------------------------------------------- void CPointCloud_Get_Subset_SPCVF_Base::Write_Subset(CSG_PointCloud *pPC_out, int iAOI, int iDatasets, CSG_MetaData *pSPCVF_Tiles, bool bAbsolutePaths) { CSG_String sPath = SG_T(""); if( m_pFilePath != NULL ) { sPath = m_pFilePath->asString(); sPath += SG_T("/"); } if( m_bMultiple ) { if( m_iFieldName > -1 ) { pPC_out->Set_Name(CSG_String::Format(SG_T("%s%s"), sPath.c_str(), m_pShapes->Get_Record(iAOI)->asString(m_iFieldName))); } else { pPC_out->Set_Name(CSG_String::Format(SG_T("%s%d_%d"), sPath.c_str(), (int)(m_AOI.Get_XMin() + m_dOverlap), (int)(m_AOI.Get_YMin() + m_dOverlap))); } } else { pPC_out->Set_Name(CSG_String::Format(SG_T("%spc_subset_%s"), sPath.c_str(), SG_File_Get_Name(m_sFileName, false).c_str())); } //----------------------------------------------------- if( pSPCVF_Tiles != NULL ) { CSG_MetaData *pDataset = pSPCVF_Tiles->Add_Child(SG_T("PointCloud")); CSG_String sTilePath; if( bAbsolutePaths ) sTilePath = pPC_out->Get_Name(); else sTilePath = SG_File_Get_Path_Relative(SG_File_Get_Path(m_sFileNameTileInfo), pPC_out->Get_Name()); sTilePath.Replace(SG_T("\\"), SG_T("/")); sTilePath.Append(SG_T(".spc")); pDataset->Add_Property(SG_T("File"), sTilePath); //----------------------------------------------------- CSG_MetaData *pBBox = pDataset->Add_Child(SG_T("BBox")); pBBox->Add_Property(SG_T("XMin"), m_AOI.Get_XMin() + m_dOverlap); pBBox->Add_Property(SG_T("YMin"), m_AOI.Get_YMin() + m_dOverlap); pBBox->Add_Property(SG_T("XMax"), m_AOI.Get_XMax() - m_dOverlap); pBBox->Add_Property(SG_T("YMax"), m_AOI.Get_YMax() - m_dOverlap); } //----------------------------------------------------- SG_UI_Msg_Add(CSG_String::Format(_TL("%d points from %d dataset(s) written to output point cloud %s."), pPC_out->Get_Count(), iDatasets, pPC_out->Get_Name()), true); if( m_pFilePath == NULL ) { m_pPointCloudList->Add_Item(pPC_out); } else { pPC_out->Save(pPC_out->Get_Name()); delete( pPC_out ); } return; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_Get_Subset_SPCVF::CPointCloud_Get_Subset_SPCVF(void) { Set_Name (_TL("Get Subset from Virtual Point Cloud")); Set_Author (SG_T("V. Wichmann, LASERDATA GmbH (c) 2014")); Set_Description (_TW( "The module allows to retrieve a point cloud from a virtual " "point cloud dataset by applying the provided area-of-interest " "(AOI). The extent of the AOI can be provided either as polygon " "shapefile, grid or by coordinates. Optionally, an overlap can " "be added to the AOI and a spcvf tile info file can be outputted. " "The latter can be used to remove the overlap later.\n" "In case an overlap is used and the AOI " "is provided as polygon shapfile, only the bounding boxes of the " "polygons are used.\n" "With polygon shapefiles additional functionality is available:\n" "* in case one or more polygons are selected, only the selected " "polygons are used.\n" "* in case the shapefile contains several polygons and the " "'One Point Cloud per Polygon' parameter is checked, a point " "cloud dataset is outputted for each polygon. In case the " "'Tilename' attribute is provided, the output files are named " "by this attribute. Otherwise the output file names are build " "from the lower left coordinate of each tile.\n" "The derived datasets can be outputted either as point cloud " "list or written to an output directory. For the latter, " "you must provide a valid file path with the 'Optional Output " "Filepath' parameter.\n" "Optionally, the query can be constrained by providing an " "attribute field and a value range that must be met.\n" "A virtual point cloud dataset is a simple XML format " "with the file extension .spcvf, which can be created " "with the 'Create Virtual Point Cloud Dataset' module.\n\n" )); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILENAME" , _TL("Filename"), _TL("The full path and name of the .spcvf file"), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("SAGA Point Cloud Virtual Format (*.spcvf)") , SG_T("*.spcvf"), _TL("All Files") , SG_T("*.*") ) ); Parameters.Add_PointCloud_List( NULL , "PC_OUT" , _TL("Point Cloud"), _TL("The output point cloud(s)"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILEPATH" , _TL("Optional Output Filepath"), _TL("The full path to which the output(s) should be written. Leave empty to output the datasets as point cloud list."), (const wchar_t *)0, (const wchar_t *)0, true, true, false ); Parameters.Add_Value( NULL , "COPY_ATTR" , _TL("Copy existing Attributes"), _TL("Copy attributes from input to output point cloud."), PARAMETER_TYPE_Bool, true ); Parameters.Add_String( Parameters("COPY_ATTR") , "ATTRIBUTE_LIST" , _TL("Copy Attributes"), _TL("Field numbers (starting from 1) of the attributes to copy, separated by semicolon; fields one to three (x;y;z) are mandatory."), SG_T("1;2;3") ); Parameters.Add_Value( NULL , "CONSTRAIN_QUERY" , _TL("Constrain Query"), _TL("Check this parameter to constrain the query by an attribute range."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( Parameters("CONSTRAIN_QUERY") , "ATTR_FIELD" , _TL("Attribute Field"), _TL("The attribute field to use as constraint. Field numbers start with 1."), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Range( Parameters("CONSTRAIN_QUERY") , "VALUE_RANGE" , _TL("Value Range"), _TL("Minimum and maximum of attribute range []."), 2.0, 2.0 ); CSG_Parameter *pNode = Parameters.Add_Node(NULL, "NODE_AOI", _TL("AOI"), _TL("AOI Input Settings")); CSG_Parameter *pNodeField = Parameters.Add_Shapes( pNode , "AOI_SHP" , _TL("Shape"), _TL("Shapefile describing the AOI."), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field( pNodeField , "FIELD_TILENAME", _TL("Tilename"), _TL("Attribute used for naming the output file(s)"), true ); Parameters.Add_Grid( pNode , "AOI_GRID" , _TL("Grid"), _TL("Grid describing the AOI."), PARAMETER_INPUT_OPTIONAL, false ); Parameters.Add_Range( pNode , "AOI_XRANGE" , _TL("X-Extent"), _TL("Minimum and maximum x-coordinate of AOI."), 0.0, 0.0 ); Parameters.Add_Range( pNode , "AOI_YRANGE" , _TL("Y-Extent"), _TL("Minimum and maximum y-coordinate of AOI."), 0.0, 0.0 ); Parameters.Add_Value( pNode , "AOI_ADD_OVERLAP" , _TL("Add Overlap"), _TL("Add overlap to AOI"), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( Parameters("AOI_ADD_OVERLAP") , "OVERLAP" , _TL("Overlap"), _TL("Overlap [map units]"), PARAMETER_TYPE_Double, 50.0, 0.0, true ); Parameters.Add_FilePath( Parameters("AOI_ADD_OVERLAP") , "FILENAME_TILE_INFO" , _TL("Optional Tile Info Filename"), _TW("The full path and name of an optional spcvf tile info file. " "Such a file contains information about the bounding boxes without " "overlap and can be used to remove the overlap from the tiles later. " "Leave empty to not output such a file."), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("SAGA Point Cloud Virtual Format Tile Info (*.spcvf_tile_info)"), SG_T("*.spcvf_tile_info"), _TL("All Files") , SG_T("*.*") ), NULL, true, false, false ); Parameters.Add_Value( pNode , "ONE_PC_PER_POLYGON" , _TL("One Point Cloud per Polygon"), _TL("Write one point cloud dataset for each polygon"), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPointCloud_Get_Subset_SPCVF::On_Execute(void) { CSG_String sFileName; CSG_Parameter_PointCloud_List *pPointCloudList = NULL; CSG_Parameter_File_Name *pFilePath = NULL; bool bConstrain; int iField; double dMinAttrRange, dMaxAttrRange; CSG_Shapes *pShapes; int iFieldName; CSG_Grid *pGrid = NULL; double dAoiXMin, dAoiYMin, dAoiXMax, dAoiYMax; bool bAddOverlap; double dOverlap; CSG_String sFileNameTileInfo; bool bMultiple; int iOutputs = 1; CSG_Rect AOI; bool bCopyAttr; CSG_String sAttrList; //----------------------------------------------------- sFileName = Parameters("FILENAME")->asString(); pPointCloudList = Parameters("PC_OUT")->asPointCloudList(); pFilePath = Parameters("FILEPATH")->asFilePath(); bConstrain = Parameters("CONSTRAIN_QUERY")->asBool(); iField = Parameters("ATTR_FIELD")->asInt() - 1; dMinAttrRange = Parameters("VALUE_RANGE")->asRange()->Get_LoVal(); dMaxAttrRange = Parameters("VALUE_RANGE")->asRange()->Get_HiVal(); pShapes = Parameters("AOI_SHP")->asShapes(); iFieldName = Parameters("FIELD_TILENAME")->asInt(); pGrid = Parameters("AOI_GRID")->asGrid(); dAoiXMin = Parameters("AOI_XRANGE")->asRange()->Get_LoVal(); dAoiXMax = Parameters("AOI_XRANGE")->asRange()->Get_HiVal(); dAoiYMin = Parameters("AOI_YRANGE")->asRange()->Get_LoVal(); dAoiYMax = Parameters("AOI_YRANGE")->asRange()->Get_HiVal(); bAddOverlap = Parameters("AOI_ADD_OVERLAP")->asBool(); dOverlap = Parameters("OVERLAP")->asDouble(); sFileNameTileInfo = Parameters("FILENAME_TILE_INFO")->asString(); bMultiple = Parameters("ONE_PC_PER_POLYGON")->asBool(); bCopyAttr = Parameters("COPY_ATTR")->asBool(); sAttrList = Parameters("ATTRIBUTE_LIST")->asString(); if( pShapes == NULL ) { bMultiple = false; } CSG_String sPath = pFilePath->asString(); if( sPath.Length() <= 1 ) { pFilePath = NULL; } //----------------------------------------------------- if( pShapes == NULL && pGrid == NULL && (dAoiXMin == dAoiXMax || dAoiYMin == dAoiYMax) ) { SG_UI_Msg_Add_Error(_TL("Please provide a valid AOI!")); return( false ); } //----------------------------------------------------- if( pShapes != NULL ) { iOutputs = pShapes->Get_Count(); } else if( pGrid != NULL ) { AOI = pGrid->Get_System().Get_Extent(); } else { AOI.Assign(dAoiXMin, dAoiYMin, dAoiXMax, dAoiYMax); } if( !m_Get_Subset_SPCVF.Initialise(iOutputs, AOI, pShapes, iFieldName, bMultiple, bAddOverlap, dOverlap, sFileNameTileInfo, sFileName, pFilePath, pPointCloudList, bConstrain, iField, dMinAttrRange, dMaxAttrRange, bCopyAttr, sAttrList) ) { return( false ); } bool bResult = m_Get_Subset_SPCVF.Get_Subset(bCopyAttr); //--------------------------------------------------------- if( SG_UI_Get_Window_Main() ) { for(int i=0; iGet_Count(); i++) { CSG_Parameters sParms; DataObject_Get_Parameters(pPointCloudList->asPointCloud(i), sParms); if( sParms("METRIC_ZRANGE") ) { sParms("METRIC_ZRANGE")->asRange()->Set_Range(pPointCloudList->asPointCloud(i)->Get_Minimum(2), pPointCloudList->asPointCloud(i)->Get_Maximum(2)); } DataObject_Set_Parameters(pPointCloudList->asPointCloud(i), sParms); DataObject_Update(pPointCloudList->asPointCloud(i)); } } m_Get_Subset_SPCVF.Finalise(); return( bResult ); } //--------------------------------------------------------- int CPointCloud_Get_Subset_SPCVF::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("COPY_ATTR")) ) { pParameters->Get_Parameter("ATTRIBUTE_LIST" )->Set_Enabled(pParameter->asBool() == false); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CONSTRAIN_QUERY")) ) { pParameters->Get_Parameter("ATTR_FIELD" )->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("VALUE_RANGE" )->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("AOI_ADD_OVERLAP")) ) { pParameters->Get_Parameter("OVERLAP" )->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("FILENAME_TILE_INFO" )->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("AOI_SHP")) ) { pParameters->Get_Parameter("FIELD_TILENAME" )->Set_Enabled(pParameter->asShapes() != NULL); pParameters->Get_Parameter("ONE_PC_PER_POLYGON" )->Set_Enabled(pParameter->asShapes() != NULL); } //----------------------------------------------------- return (1); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_Get_Subset_SPCVF_Interactive::CPointCloud_Get_Subset_SPCVF_Interactive(void) { Set_Name (_TL("Get Subset from Virtual Point Cloud")); Set_Author (SG_T("V. Wichmann, LASERDATA GmbH (c) 2014")); Set_Description (_TW( "The module allows to retrieve a point cloud from a virtual " "point cloud dataset by dragging a box (AOI) in a Map View.\n" "Optionally, the query can be constrained by providing an " "attribute field and a value range that must be met.\n" "A virtual point cloud dataset is a simple XML format " "with the file extension .spcvf, which can be created " "with the 'Create Virtual Point Cloud Dataset' module.\n\n" )); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILENAME" , _TL("Filename"), _TL("The full path and name of the .spcvf file"), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("SAGA Point Cloud Virtual Format (*.spcvf)") , SG_T("*.spcvf"), _TL("All Files") , SG_T("*.*") ) ); Parameters.Add_PointCloud_Output( NULL , "PC_OUT" , _TL("Point Cloud"), _TL("The output point cloud") ); Parameters.Add_Value( NULL , "COPY_ATTR" , _TL("Copy existing Attributes"), _TL("Copy attributes from input to output point cloud."), PARAMETER_TYPE_Bool, true ); Parameters.Add_String( Parameters("COPY_ATTR") , "ATTRIBUTE_LIST" , _TL("Copy Attributes"), _TL("Field numbers (starting from 1) of the attributes to copy, separated by semicolon; fields one to three (x;y;z) are mandatory."), SG_T("1;2;3") ); Parameters.Add_Value( NULL , "CONSTRAIN_QUERY" , _TL("Constrain Query"), _TL("Check this parameter to constrain the query by an attribute range."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( Parameters("CONSTRAIN_QUERY") , "ATTR_FIELD" , _TL("Attribute Field"), _TL("The attribute field to use as constraint. Field numbers start with 1."), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Range( Parameters("CONSTRAIN_QUERY") , "VALUE_RANGE" , _TL("Value Range"), _TL("Minimum and maximum of attribute range []."), 2.0, 2.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPointCloud_Get_Subset_SPCVF_Interactive::On_Execute(void) { return( true ); } //--------------------------------------------------------- bool CPointCloud_Get_Subset_SPCVF_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 AOI(m_ptDown.Get_X(), m_ptDown.Get_Y(), ptWorld.Get_X(), ptWorld.Get_Y()); CSG_Parameter_PointCloud_List PointCloudList(NULL, PARAMETER_INFORMATION); // as long as this module only supports to drag a box, we initialize it with a fake overlap in order // to use CSG_Rect instead of CSG_Shape for point in polygon check in Get_Subset(): if( !m_Get_Subset_SPCVF.Initialise(1, AOI, NULL, -1, false, true, 0.0, SG_T(""), Parameters("FILENAME")->asString(), NULL, &PointCloudList, Parameters("CONSTRAIN_QUERY")->asBool(), Parameters("ATTR_FIELD")->asInt()-1, Parameters("VALUE_RANGE")->asRange()->Get_LoVal(), Parameters("VALUE_RANGE")->asRange()->Get_HiVal(), Parameters("COPY_ATTR")->asBool(), Parameters("ATTRIBUTE_LIST")->asString()) ) { return( false ); } bool bResult = m_Get_Subset_SPCVF.Get_Subset(Parameters("COPY_ATTR")->asBool()); if( bResult ) { Parameters("PC_OUT")->Set_Value(PointCloudList.asPointCloud(0)); CSG_PointCloud *pPC = Parameters("PC_OUT")->asPointCloud(); CSG_Parameters sParms; DataObject_Get_Parameters(pPC, sParms); if( sParms("METRIC_ZRANGE") ) { sParms("METRIC_ZRANGE")->asRange()->Set_Range(pPC->Get_Minimum(2), pPC->Get_Maximum(2)); } DataObject_Set_Parameters(pPC, sParms); DataObject_Update(pPC, SG_UI_DATAOBJECT_SHOW_LAST_MAP); } m_Get_Subset_SPCVF.Finalise(); return( bResult ); } return( false ); } //--------------------------------------------------------- int CPointCloud_Get_Subset_SPCVF_Interactive::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("COPY_ATTR")) ) { pParameters->Get_Parameter("ATTRIBUTE_LIST" )->Set_Enabled(pParameter->asBool() == false); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CONSTRAIN_QUERY")) ) { pParameters->Get_Parameter("ATTR_FIELD" )->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("VALUE_RANGE" )->Set_Enabled(pParameter->asBool()); } //----------------------------------------------------- return (1); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_virtual/pc_create_spcvf.cpp0000664000175000017500000003412312565125414024454 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pc_create_spcvf.cpp 2405 2015-02-13 10:34:33Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_virtual // // // //-------------------------------------------------------// // // // pc_create_spcvf.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_create_spcvf.h" #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_Create_SPCVF::CPointCloud_Create_SPCVF(void) { Set_Name (_TL("Create Virtual Point Cloud Dataset")); Set_Author (SG_T("V. Wichmann, LASERDATA GmbH (c) 2014")); Set_Description (_TW( "The module allows one to create a virtual point cloud dataset " "from a set of SAGA point cloud files. For a large number of " "files, it is advised to use an input file list, i.e. a text " "file with the full path to an input point cloud on each line.\n" "A virtual point cloud " "dataset is a simple XML format with the file extension .spcvf, " "which describes a mosaic of individual point cloud files. Such " "a virtual point cloud dataset can be used for seamless data " "access with the 'Get Subset from Virtual Point Cloud' module.\n" "All point cloud input datasets must share the same attribute " "table structure, NoData value and projection.\n\n" )); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILES" , _TL("Input Files"), _TL("The input point cloud files to use"), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("SAGA Point Clouds") , SG_T("*.spc"), _TL("All Files") , SG_T("*.*") ), NULL, false, false, true ); Parameters.Add_FilePath( NULL , "INPUT_FILE_LIST" , _TL("Input File List"), _TL("A text file with the full path to an input point cloud on each line"), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("Text Files") , SG_T("*.txt"), _TL("All Files") , SG_T("*.*") ), NULL, false, false, false ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("Filename"), _TL("The full path and name of the .spcvf file"), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("SAGA Point Cloud Virtual Format (*.spcvf)") , SG_T("*.spcvf"), _TL("All Files") , SG_T("*.*") ), NULL, true, false, false ); Parameters.Add_Choice( NULL , "METHOD_PATHS" , _TL("File Paths"), _TL("Choose how to handle file paths. With relative paths, you can package the *.spcvf and your point cloud tiles easily."), CSG_String::Format(SG_T("%s|%s"), _TL("absolute"), _TL("relative") ), 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPointCloud_Create_SPCVF::On_Execute(void) { CSG_Strings sFiles; CSG_String sFileInputList, sFileName; int iMethodPaths; CSG_MetaData SPCVF; CSG_Projection projSPCVF; double dNoData; std::vector vFieldTypes; std::vector vFieldNames; double dBBoxXMin = std::numeric_limits::max(); double dBBoxYMin = std::numeric_limits::max(); double dBBoxXMax = std::numeric_limits::min(); double dBBoxYMax = std::numeric_limits::min(); int iSkipped = 0, iEmpty = 0; int iDatasetCount = 0; double dPointCount = 0.0; double dZMin = std::numeric_limits::max(); double dZMax = std::numeric_limits::min(); //----------------------------------------------------- sFileName = Parameters("FILENAME")->asString(); iMethodPaths = Parameters("METHOD_PATHS")->asInt(); sFileInputList = Parameters("INPUT_FILE_LIST")->asString(); //----------------------------------------------------- if( !Parameters("FILES")->asFilePath()->Get_FilePaths(sFiles) && sFileInputList.Length() <= 0 ) { SG_UI_Msg_Add_Error(_TL("Please provide some input files!")); return( false ); } //----------------------------------------------------- if( sFiles.Get_Count() <= 0 ) { CSG_Table *pTable = new CSG_Table(); if( !pTable->Create(sFileInputList, TABLE_FILETYPE_Text_NoHeadLine) ) { SG_UI_Msg_Add_Error(_TL("Input file list could not be opened!")); delete( pTable ); return( false ); } sFiles.Clear(); for (int i=0; iGet_Record_Count(); i++) { sFiles.Add(pTable->Get_Record(i)->asString(0)); } delete( pTable ); } //----------------------------------------------------- SPCVF.Set_Name(SG_T("SPCVFDataset")); SPCVF.Add_Property(SG_T("Version"), SG_T("1.1")); switch( iMethodPaths ) { default: case 0: SPCVF.Add_Property(SG_T("Paths"), SG_T("absolute")); break; case 1: SPCVF.Add_Property(SG_T("Paths"), SG_T("relative")); break; } //----------------------------------------------------- CSG_MetaData *pSPCVFHeader = SPCVF.Add_Child( SG_T("Header")); CSG_MetaData *pSPCVFFiles = pSPCVFHeader->Add_Child( SG_T("Datasets")); CSG_MetaData *pSPCVFPoints = pSPCVFHeader->Add_Child( SG_T("Points")); CSG_MetaData *pSRS = pSPCVFHeader->Add_Child( SG_T("SRS")); CSG_MetaData *pSPCVFBBox = pSPCVFHeader->Add_Child( SG_T("BBox")); CSG_MetaData *pSPCVFZStats = pSPCVFHeader->Add_Child( SG_T("ZStats")); CSG_MetaData *pSPCVFNoData = pSPCVFHeader->Add_Child( SG_T("NoData")); CSG_MetaData *pSPCVFAttr = pSPCVFHeader->Add_Child( SG_T("Attributes")); CSG_MetaData *pSPCVFDatasets = NULL; //----------------------------------------------------- for(int i=0; iGet_Projection(); dNoData = pPC->Get_NoData_Value(); pSPCVFNoData->Add_Property(SG_T("Value"), dNoData); pSPCVFAttr->Add_Property(SG_T("Count"), pPC->Get_Field_Count()); for(int iField=0; iFieldGet_Field_Count(); iField++) { vFieldTypes.push_back(pPC->Get_Field_Type(iField)); vFieldNames.push_back(pPC->Get_Field_Name(iField)); CSG_MetaData *pSPCVFField = pSPCVFAttr->Add_Child(CSG_String::Format(SG_T("Field_%d"), iField + 1)); pSPCVFField->Add_Property(SG_T("Name"), pPC->Get_Field_Name(iField)); pSPCVFField->Add_Property(SG_T("Type"), gSG_Data_Type_Identifier[pPC->Get_Field_Type(iField)]); } if( projSPCVF.is_Okay() ) { pSRS->Add_Property(SG_T("Projection"), projSPCVF.Get_Name()); pSRS->Add_Property(SG_T("WKT"), projSPCVF.Get_WKT()); } else { pSRS->Add_Property(SG_T("Projection"), SG_T("Undefined Coordinate System")); } pSPCVFDatasets = SPCVF.Add_Child(SG_T("Datasets")); } else // validate projection, NoData value and table structure { bool bSkip = false; if( pPC->Get_Field_Count() != (int)vFieldTypes.size() ) { bSkip = true; } if( !bSkip && projSPCVF.is_Okay() ) { if ( !pPC->Get_Projection().is_Okay() || SG_STR_CMP(pPC->Get_Projection().Get_WKT(), projSPCVF.Get_WKT()) ) { bSkip = true; } } if( !bSkip ) { for(int iField=0; iFieldGet_Field_Count(); iField++) { if( pPC->Get_Field_Type(iField) != vFieldTypes.at(iField) ) { bSkip = true; break; } if( SG_STR_CMP(pPC->Get_Field_Name(iField), vFieldNames.at(iField)) ) { bSkip = true; break; } } } if( bSkip ) { SG_UI_Msg_Add(CSG_String::Format(_TL("Skipping dataset %s because of incompatibility with the first input dataset!"), sFiles[i].c_str()), true); delete( pPC ); iSkipped++; continue; } } //----------------------------------------------------- if( pPC->Get_Point_Count() <= 0 ) { delete( pPC ); iEmpty++; continue; } //----------------------------------------------------- CSG_MetaData *pDataset = pSPCVFDatasets->Add_Child(SG_T("PointCloud")); CSG_String sFilePath; switch( iMethodPaths ) { default: case 0: sFilePath = SG_File_Get_Path_Absolute(sFiles.Get_String(i)); break; case 1: sFilePath = SG_File_Get_Path_Relative(SG_File_Get_Path(sFileName), sFiles.Get_String(i)); break; } sFilePath.Replace(SG_T("\\"), SG_T("/")); pDataset->Add_Property(SG_T("File"), sFilePath); pDataset->Add_Property(SG_T("Points"), pPC->Get_Point_Count()); pDataset->Add_Property(SG_T("ZMin"), pPC->Get_ZMin()); pDataset->Add_Property(SG_T("ZMax"), pPC->Get_ZMax()); //----------------------------------------------------- CSG_MetaData *pBBox = pDataset->Add_Child(SG_T("BBox")); pBBox->Add_Property(SG_T("XMin"), pPC->Get_Extent().Get_XMin()); pBBox->Add_Property(SG_T("YMin"), pPC->Get_Extent().Get_YMin()); pBBox->Add_Property(SG_T("XMax"), pPC->Get_Extent().Get_XMax()); pBBox->Add_Property(SG_T("YMax"), pPC->Get_Extent().Get_YMax()); if( dBBoxXMin > pPC->Get_Extent().Get_XMin() ) dBBoxXMin = pPC->Get_Extent().Get_XMin(); if( dBBoxYMin > pPC->Get_Extent().Get_YMin() ) dBBoxYMin = pPC->Get_Extent().Get_YMin(); if( dBBoxXMax < pPC->Get_Extent().Get_XMax() ) dBBoxXMax = pPC->Get_Extent().Get_XMax(); if( dBBoxYMax < pPC->Get_Extent().Get_YMax() ) dBBoxYMax = pPC->Get_Extent().Get_YMax(); iDatasetCount += 1; dPointCount += pPC->Get_Point_Count(); if( dZMin > pPC->Get_ZMin() ) dZMin = pPC->Get_ZMin(); if( dZMax < pPC->Get_ZMax() ) dZMax = pPC->Get_ZMax(); delete( pPC ); } //----------------------------------------------------- pSPCVFBBox->Add_Property(SG_T("XMin"), dBBoxXMin); pSPCVFBBox->Add_Property(SG_T("YMin"), dBBoxYMin); pSPCVFBBox->Add_Property(SG_T("XMax"), dBBoxXMax); pSPCVFBBox->Add_Property(SG_T("YMax"), dBBoxYMax); pSPCVFFiles->Add_Property(SG_T("Count"), iDatasetCount); pSPCVFPoints->Add_Property(SG_T("Count"), CSG_String::Format(SG_T("%.0f"), dPointCount)); pSPCVFZStats->Add_Property(SG_T("ZMin"), dZMin); pSPCVFZStats->Add_Property(SG_T("ZMax"), dZMax); //----------------------------------------------------- if( !SPCVF.Save(sFileName) ) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unable to save %s file!"), sFileName.c_str())); return( false ); } //----------------------------------------------------- if( iSkipped > 0 ) { SG_UI_Msg_Add(CSG_String::Format(_TL("WARNING: %d dataset(s) skipped because of incompatibilities!"), iSkipped), true); } if( iEmpty > 0 ) { SG_UI_Msg_Add(CSG_String::Format(_TL("WARNING: %d dataset(s) skipped because they are empty!"), iEmpty), true); } SG_UI_Msg_Add(CSG_String::Format(_TL("SPCVF successfully created from %d dataset(s)."), iDatasetCount), true); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gps/0000775000175000017500000000000012634325743017726 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_gps/GPSBabel.cpp0000664000175000017500000001042612565125414022010 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GPSBabel.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* GPSBabel.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "GPSBabel.h" CSG_String sGPSBabelID[] = { "geo", "gpsman", "gpx", "magellan", "mapsend", "pcx", "mapsource", "gpsutil", "tiger", "csv", "xmap", "dna", "psp", "cetus", "gpspilot", "magnav", "garmin", "mxf", "holux", "ozi", "tpg", "tmpro" }; CGPSBabel::CGPSBabel(){ Parameters.Set_Name(_TL("GPSBabel")); Parameters.Set_Description(_TW( "An interface to the GPSBabel software" "(c) 2005 by Victor Olaya\r\nemail: volaya@ya.com")); Parameters.Add_FilePath(NULL, "BASEPATH", _TL("GPSBabel path"), _TL("GPSBabel path"), _TL(""), _TL(""), false, true); Parameters.Add_FilePath(NULL, "INPUT", _TL("Input file"), _TL(""), _TL("All Files|*.*|")); Parameters.Add_Choice(NULL, "FORMATIN", _TL("Input format"), _TL(""), _TW("Geocaching.com .loc|" "GPSman|" "GPX XML|" "Magellan protocol|" "Magellan Mapsend|" "Garmin PCX5|" "Garmin Mapsource|" "gpsutil|" "U.S. Census Bureau Tiger Mapping Service|" "Comma separated values|" "Delorme Topo USA4/XMap Conduit|" "Navitrak DNA marker format|" "MS PocketStreets 2002 Pushpin|" "Cetus for Palm/OS|" "GPSPilot Tracker for Palm/OS|" "Magellan NAV Companion for PalmOS|" "Garmin serial protocol|" "MapTech Exchange Format|" "Holux (gm-100) .wpo Format|" "OziExplorer Waypoint|" "National Geographic Topo .tpg|" "TopoMapPro Places File|" ), 0); Parameters.Add_FilePath(NULL, "OUTPUT", _TL("Output file"), _TL(""), _TL("All Files|*.*|"), _TL(""), true, false); Parameters.Add_Choice(NULL, "FORMATOUT", _TL("Output format"), _TL(""), _TW("Geocaching.com .loc|" "GPSman|" "GPX XML|" "Magellan protocol|" "Magellan Mapsend|" "Garmin PCX5|" "Garmin Mapsource|" "gpsutil|" "U.S. Census Bureau Tiger Mapping Service|" "Comma separated values|" "Delorme Topo USA4/XMap Conduit|" "Navitrak DNA marker format|" "MS PocketStreets 2002 Pushpin|" "Cetus for Palm/OS|" "GPSPilot Tracker for Palm/OS|" "Magellan NAV Companion for PalmOS|" "Garmin serial protocol|" "MapTech Exchange Format|" "Holux (gm-100) .wpo Format|" "OziExplorer Waypoint|" "National Geographic Topo .tpg|" "TopoMapPro Places File|"), 0); }//constructor CGPSBabel::~CGPSBabel(){ }//destructor bool CGPSBabel::On_Execute(void){ CSG_String sCmd; CSG_String sInputFile = Parameters("INPUT")->asString(); CSG_String sOutputFile = Parameters("OUTPUT")->asString(); CSG_String sBasePath = Parameters("BASEPATH")->asString(); int iInputFormat = Parameters("FORMATIN")->asInt(); int iOutputFormat = Parameters("FORMATOUT")->asInt(); sCmd = sBasePath + SG_T("\\") + SG_T("gpsbabel.exe ") + SG_T("-i ") + sGPSBabelID[iInputFormat] + SG_T(" ") + SG_T("-f ") + sInputFile + SG_T(" ") + SG_T("-o ") + sGPSBabelID[iOutputFormat] + SG_T(" ") + SG_T("-F ") + sOutputFile + SG_T(" "); system(sCmd.b_str()); return true; }//methodsaga-2.2.3/src/modules/io/io_gps/Makefile.in0000664000175000017500000005421212622651165021774 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/io_gps DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) 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) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_gps_la_SOURCES) DIST_SOURCES = $(libio_gps_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_gps.la libio_gps_la_SOURCES = \ GPSBabel.cpp\ gpx2shp.cpp\ MLB_Interface.cpp\ GPSBabel.h\ gpx2shp.h\ MLB_Interface.h libio_gps_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) --foreign src/modules/io/io_gps/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_gps/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_gps.la: $(libio_gps_la_OBJECTS) $(libio_gps_la_DEPENDENCIES) $(EXTRA_libio_gps_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_gps_la_OBJECTS) $(libio_gps_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPSBabel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpx2shp.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/io/io_gps/gpx2shp.h0000664000175000017500000000247312565125414021474 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gpx2shp.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* GPX2SHP.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CGPX2SHP : public CSG_Module { public: CGPX2SHP(void); virtual ~CGPX2SHP(void); protected: virtual bool On_Execute(void); }; saga-2.2.3/src/modules/io/io_gps/MLB_Interface.cpp0000664000175000017500000001154712565125414023030 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for an Automated Geo-Scientific Analysis // // // // Module Library: // // Models // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for an Automated // // Geo-Scientific Analysis'. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("GPS Tools") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("Victor Olaya (c) 2004") ); case MLB_INFO_Description: return( _TL("Tools for GPS data handling.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|GPS Import") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "gpx2shp.h" #include "GPSBabel.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 CGPX2SHP; break; case 1: pModule = new CGPSBabel; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/io/io_gps/Makefile.am0000664000175000017500000000115412565125414021757 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_gps.la libio_gps_la_SOURCES =\ GPSBabel.cpp\ gpx2shp.cpp\ MLB_Interface.cpp\ GPSBabel.h\ gpx2shp.h\ MLB_Interface.h libio_gps_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/io/io_gps/MLB_Interface.h0000664000175000017500000000765712565125414022504 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Terrain_Analysis // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_gps_H #define HEADER_INCLUDED__io_gps_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_gps_EXPORTS #define io_gps_EXPORT _SAGA_DLL_EXPORT #else #define io_gps_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_gps_H saga-2.2.3/src/modules/io/io_gps/GPSBabel.h0000664000175000017500000000250012565125414021447 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: GPSBabel.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* GPSBabel.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CGPSBabel : public CSG_Module { public: CGPSBabel(void); virtual ~CGPSBabel(void); protected: virtual bool On_Execute(void); }; saga-2.2.3/src/modules/io/io_gps/gpx2shp.cpp0000664000175000017500000000744212565125414022030 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gpx2shp.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* GPX2SHP.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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "gpx2shp.h" CGPX2SHP::CGPX2SHP(){ Parameters.Set_Name(_TL("GPX to shapefile")); Parameters.Set_Description(_TW( "Converts a GPX file into a Shapefile (.shp)" "(c) 2005 by Victor Olaya\r\nemail: volaya@ya.com") ); Parameters.Add_FilePath(NULL, "BASEPATH", _TL("Gpx2shp path"), _TL("Gpx2shp path"), _TL(""), _TL(""), false, true); Parameters.Add_FilePath(NULL, "FILE", _TL("GPX file"), _TL(""), _TL("GPX files (*.gpx)|*.gpx|All Files|*.*") ); Parameters.Add_Value(NULL, "TRACKPOINTS", _TL("Convert track points"), _TL("Convert track points"), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(NULL, "WAYPOINTS", _TL("Convert way points"), _TL("Convert way points"), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(NULL, "ROUTES", _TL("Convert routes"), _TL("Convert routes"), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(NULL, "ADD", _TL("Load shapefile"), _TL("Load shapefile after conversion"), PARAMETER_TYPE_Bool, true); }//constructor CGPX2SHP::~CGPX2SHP(){ }//destructor bool CGPX2SHP::On_Execute(void){ CSG_String sCmd; CSG_String sFile = Parameters("FILE")->asString(); CSG_String sBasePath = Parameters("BASEPATH")->asString(); CSG_String sShapefile; bool bWaypoints = Parameters("WAYPOINTS")->asBool(); bool bTrackpoints = Parameters("TRACKPOINTS")->asBool(); bool bRoutes = Parameters("ROUTES")->asBool(); bool bAdd = Parameters("ADD")->asBool(); CSG_Shapes *pShapes; sCmd = sBasePath + SG_T("\\gpx2shp "); if (bWaypoints){ sCmd += SG_T("-w "); }//if if (bTrackpoints){ sCmd += SG_T("-t "); }//if if (bRoutes){ sCmd += SG_T("-r "); }//if sCmd += sFile; system(sCmd.b_str()); if( bAdd ) { CSG_String sDir(SG_File_Get_Path(sFile)), sName(SG_File_Get_Name(sFile, false)); //------------------------------------------------- sFile = SG_File_Make_Path(sDir, sName + SG_T("_wpt"), SG_T("shp")); pShapes = SG_Create_Shapes(sFile); if( pShapes->is_Valid() ) DataObject_Add(pShapes, false); else delete(pShapes); //------------------------------------------------- sFile = SG_File_Make_Path(sDir, sName + SG_T("_trk"), SG_T("shp")); pShapes = SG_Create_Shapes(sFile); if( pShapes->is_Valid() ) DataObject_Add(pShapes, false); else delete(pShapes); //------------------------------------------------- sFile = SG_File_Make_Path(sDir, sName + SG_T("_rte"), SG_T("shp")); pShapes = SG_Create_Shapes(sFile); if( pShapes->is_Valid() ) DataObject_Add(pShapes, false); else delete(pShapes); }//if return true; }//methodsaga-2.2.3/src/modules/io/Makefile.in0000664000175000017500000004626712622651165020527 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-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 \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = io_esri_e00 io_gdal io_gps io_grid io_grid_grib2 \ io_shapes io_shapes_dxf io_shapes_las io_table io_virtual \ io_grid_image 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@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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@ @WITH_GUI_FALSE@SUBDIRS = io_esri_e00 io_gdal io_gps io_grid io_grid_grib2 io_shapes io_shapes_dxf io_shapes_las io_table io_virtual @WITH_GUI_TRUE@SUBDIRS = io_esri_e00 io_gdal io_gps io_grid io_grid_grib2 io_grid_image io_shapes io_shapes_dxf io_shapes_las io_table io_virtual 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) --foreign src/modules/io/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/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. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ 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" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 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; \ $(am__define_uniq_tagged_files); \ 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-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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 \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am 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-am 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: saga-2.2.3/src/modules/io/io_grid_grib2/0000775000175000017500000000000012634325743021147 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_grid_grib2/Makefile.in0000664000175000017500000010554212622651166023221 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/io_grid_grib2 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_grid_grib2_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am__dirstamp = $(am__leading_dot)dirstamp am_libio_grid_grib2_la_OBJECTS = ./g2clib-1.0.4/cmplxpack.lo \ ./g2clib-1.0.4/compack.lo ./g2clib-1.0.4/comunpack.lo \ ./g2clib-1.0.4/dec_jpeg2000.lo ./g2clib-1.0.4/dec_png.lo \ ./g2clib-1.0.4/drstemplates.lo ./g2clib-1.0.4/enc_jpeg2000.lo \ ./g2clib-1.0.4/enc_png.lo ./g2clib-1.0.4/g2_addfield.lo \ ./g2clib-1.0.4/g2_addgrid.lo ./g2clib-1.0.4/g2_addlocal.lo \ ./g2clib-1.0.4/g2_create.lo ./g2clib-1.0.4/g2_free.lo \ ./g2clib-1.0.4/g2_getfld.lo ./g2clib-1.0.4/g2_gribend.lo \ ./g2clib-1.0.4/g2_info.lo ./g2clib-1.0.4/g2_miss.lo \ ./g2clib-1.0.4/g2_unpack1.lo ./g2clib-1.0.4/g2_unpack2.lo \ ./g2clib-1.0.4/g2_unpack3.lo ./g2clib-1.0.4/g2_unpack4.lo \ ./g2clib-1.0.4/g2_unpack5.lo ./g2clib-1.0.4/g2_unpack6.lo \ ./g2clib-1.0.4/g2_unpack7.lo ./g2clib-1.0.4/gbits.lo \ ./g2clib-1.0.4/getdim.lo ./g2clib-1.0.4/getpoly.lo \ ./g2clib-1.0.4/gridtemplates.lo ./g2clib-1.0.4/int_power.lo \ ./g2clib-1.0.4/jpcpack.lo ./g2clib-1.0.4/jpcunpack.lo \ ./g2clib-1.0.4/misspack.lo ./g2clib-1.0.4/mkieee.lo \ ./g2clib-1.0.4/pack_gp.lo ./g2clib-1.0.4/pdstemplates.lo \ ./g2clib-1.0.4/pngpack.lo ./g2clib-1.0.4/pngunpack.lo \ ./g2clib-1.0.4/rdieee.lo ./g2clib-1.0.4/reduce.lo \ ./g2clib-1.0.4/seekgb.lo ./g2clib-1.0.4/simpack.lo \ ./g2clib-1.0.4/simunpack.lo ./g2clib-1.0.4/specpack.lo \ ./g2clib-1.0.4/specunpack.lo grib2_import.lo MLB_Interface.lo libio_grid_grib2_la_OBJECTS = $(am_libio_grid_grib2_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(libio_grid_grib2_la_SOURCES) DIST_SOURCES = $(libio_grid_grib2_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @SAGA_UNICODE_TRUE@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 $(LOCAL_INCS) AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS) $(GOMPFLAGS) #AM_LDFLAGS = -fPIC -shared -avoid-version -lpq -ljasper AM_LDFLAGS = -fPIC -shared -avoid-version $(LOCAL_LIBS) -ljasper pkglib_LTLIBRARIES = libio_grid_grib2.la libio_grid_grib2_la_SOURCES = \ ./g2clib-1.0.4/cmplxpack.c\ ./g2clib-1.0.4/compack.c\ ./g2clib-1.0.4/comunpack.c\ ./g2clib-1.0.4/dec_jpeg2000.c\ ./g2clib-1.0.4/dec_png.c\ ./g2clib-1.0.4/drstemplates.c\ ./g2clib-1.0.4/enc_jpeg2000.c\ ./g2clib-1.0.4/enc_png.c\ ./g2clib-1.0.4/g2_addfield.c\ ./g2clib-1.0.4/g2_addgrid.c\ ./g2clib-1.0.4/g2_addlocal.c\ ./g2clib-1.0.4/g2_create.c\ ./g2clib-1.0.4/g2_free.c\ ./g2clib-1.0.4/g2_getfld.c\ ./g2clib-1.0.4/g2_gribend.c\ ./g2clib-1.0.4/g2_info.c\ ./g2clib-1.0.4/g2_miss.c\ ./g2clib-1.0.4/g2_unpack1.c\ ./g2clib-1.0.4/g2_unpack2.c\ ./g2clib-1.0.4/g2_unpack3.c\ ./g2clib-1.0.4/g2_unpack4.c\ ./g2clib-1.0.4/g2_unpack5.c\ ./g2clib-1.0.4/g2_unpack6.c\ ./g2clib-1.0.4/g2_unpack7.c\ ./g2clib-1.0.4/gbits.c\ ./g2clib-1.0.4/getdim.c\ ./g2clib-1.0.4/getpoly.c\ ./g2clib-1.0.4/gridtemplates.c\ ./g2clib-1.0.4/int_power.c\ ./g2clib-1.0.4/jpcpack.c\ ./g2clib-1.0.4/jpcunpack.c\ ./g2clib-1.0.4/misspack.c\ ./g2clib-1.0.4/mkieee.c\ ./g2clib-1.0.4/pack_gp.c\ ./g2clib-1.0.4/pdstemplates.c\ ./g2clib-1.0.4/pngpack.c\ ./g2clib-1.0.4/pngunpack.c\ ./g2clib-1.0.4/rdieee.c\ ./g2clib-1.0.4/reduce.c\ ./g2clib-1.0.4/seekgb.c\ ./g2clib-1.0.4/simpack.c\ ./g2clib-1.0.4/simunpack.c\ ./g2clib-1.0.4/specpack.c\ ./g2clib-1.0.4/specunpack.c\ ./g2clib-1.0.4/drstemplates.h\ ./g2clib-1.0.4/grib2.h\ ./g2clib-1.0.4/gridtemplates.h\ ./g2clib-1.0.4/pdstemplates.h\ grib2_import.cpp\ MLB_Interface.cpp\ grib2_import.h\ MLB_Interface.h libio_grid_grib2_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .c .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) --foreign src/modules/io/io_grid_grib2/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_grid_grib2/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } g2clib-1.0.4/$(am__dirstamp): @$(MKDIR_P) ./g2clib-1.0.4 @: > g2clib-1.0.4/$(am__dirstamp) g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) ./g2clib-1.0.4/$(DEPDIR) @: > g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/cmplxpack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/compack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/comunpack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/dec_jpeg2000.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/dec_png.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/drstemplates.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/enc_jpeg2000.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/enc_png.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_addfield.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_addgrid.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_addlocal.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_create.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_free.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_getfld.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_gribend.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_info.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_miss.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_unpack1.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_unpack2.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_unpack3.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_unpack4.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_unpack5.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_unpack6.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/g2_unpack7.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/gbits.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/getdim.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/getpoly.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/gridtemplates.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/int_power.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/jpcpack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/jpcunpack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/misspack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/mkieee.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/pack_gp.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/pdstemplates.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/pngpack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/pngunpack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/rdieee.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/reduce.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/seekgb.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/simpack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/simunpack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/specpack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) ./g2clib-1.0.4/specunpack.lo: g2clib-1.0.4/$(am__dirstamp) \ g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) libio_grid_grib2.la: $(libio_grid_grib2_la_OBJECTS) $(libio_grid_grib2_la_DEPENDENCIES) $(EXTRA_libio_grid_grib2_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_grid_grib2_la_OBJECTS) $(libio_grid_grib2_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f ./g2clib-1.0.4/*.$(OBJEXT) -rm -f ./g2clib-1.0.4/*.lo distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grib2_import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/cmplxpack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/compack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/comunpack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/dec_jpeg2000.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/dec_png.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/drstemplates.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/enc_jpeg2000.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/enc_png.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_addfield.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_addgrid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_addlocal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_create.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_free.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_getfld.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_gribend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_miss.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_unpack1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_unpack2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_unpack3.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_unpack4.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_unpack5.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_unpack6.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/g2_unpack7.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/gbits.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/getdim.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/getpoly.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/gridtemplates.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/int_power.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/jpcpack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/jpcunpack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/misspack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/mkieee.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/pack_gp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/pdstemplates.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/pngpack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/pngunpack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/rdieee.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/reduce.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/seekgb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/simpack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/simunpack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/specpack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./g2clib-1.0.4/$(DEPDIR)/specunpack.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf ./g2clib-1.0.4/.libs ./g2clib-1.0.4/_libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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) -rm -f g2clib-1.0.4/$(DEPDIR)/$(am__dirstamp) -rm -f g2clib-1.0.4/$(am__dirstamp) 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) ./g2clib-1.0.4/$(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) ./g2clib-1.0.4/$(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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/io/io_grid_grib2/grib2_import.cpp0000664000175000017500000000717212565125414024255 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grib2_import.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /* * Thomas Schorr 2007 */ #define DEBUG 1 #include "grib2_import.h" #include #include #ifdef _SAGA_LINUX #include #endif #ifdef _SAGA_MSW double rint(double x) { return( (int)(0.5 + x) ); } #endif SGGrib2Import::SGGrib2Import(void) { Set_Name (_TL("Import GRIB2 record")); Set_Author (_TL("Copyright (c) 2007 by Thomas Schorr")); Set_Description (_TW( "Import a GRIB2 record." "Under development." )); Parameters.Add_Grid_Output( NULL , "OUT_GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TW( "GRIdded Binary (GRIB) files|*.grib*;*.grb*|" "GRIB2 files|*.grib2;*.grb2|" "All Files|*.*" ) ); } SGGrib2Import::~SGGrib2Import(void) {} bool SGGrib2Import::On_Execute(void) { size_t num_bytes; FILE *fp; CSG_String FileName; unsigned char *raw, *help; struct stat st; FileName = Parameters("FILE") ->asString(); gf = NULL; if ( stat( FileName.b_str(), &st ) == -1 ) return false; raw = ( unsigned char * ) malloc( st.st_size ); if ( raw == NULL ) return false; if( ( fp = fopen(FileName.b_str(), "rb")) != NULL ) { num_bytes = 0; help = raw; while ( feof( fp ) == 0 && ferror( fp ) == 0 ) { num_bytes = fread( help, sizeof( unsigned char ), 1024, fp ); help += num_bytes; } fclose( fp ); g2_getfld( raw, 1, 1, 1, &gf ); switch ( gf->igdtnum ) { case 0: if ( ! handle_latlon() ) return false; break; case 20: if ( ! handle_polar_stereographic() ) return false; break; default: fprintf( stderr, "unhandled grid definition template no.: %d\n", gf->igdtnum ); if ( ! handle_latlon() ) return false; } pGrid->Set_Name( SG_File_Get_Name(FileName, false) ); // no need to use wx!!! // pGrid->Set_Name( wxFileName( wxString( FileName ) ).GetName() ); Parameters( "OUT_GRID" )->Set_Value( pGrid ); g2_free( gf ); free( raw ); return( true ); } return( false ); } bool SGGrib2Import::handle_latlon( void ) { int x, y, nx, ny; double cellsize, xmin, ymin; if( gf->igdtmpl == NULL || gf->fld == NULL ) // possible if jpeg/png is not supported!? return( false ); nx = ( int ) gf->igdtmpl[ 7 ]; ny = ( int ) gf->igdtmpl[ 8 ]; cellsize = ( double ) ( gf->igdtmpl[ 16 ] * 1e-6 ); xmin = ( double ) ( gf->igdtmpl[ 12 ] * 1e-6 ) + cellsize / 2.0; ymin = ( double ) ( gf->igdtmpl[ 11 ] * 1e-6 ) - 90.0 + cellsize / 2.0; #ifdef DEBUG fprintf( stderr, "%d %d %f %f %f\n", nx, ny, cellsize, xmin, ymin ); #endif if ( ( nx == -1 ) || ( ny == -1 ) || ( ( pGrid = SG_Create_Grid( SG_DATATYPE_Float, nx, ny, cellsize, xmin, ymin ) ) == NULL ) ) return false; for ( x = 0; x < nx; x++ ) { for ( y = 0; y < ny; y ++ ) pGrid->Set_Value( x, ny - y - 1, gf->fld[ y * nx + x ] ); } return true; } bool SGGrib2Import::handle_polar_stereographic( void ) { /* XXX fix me XXX*/ int x, y, nx, ny; double cellsize, xmin, ymin; nx = ( int ) gf->igdtmpl[ 7 ]; ny = ( int ) gf->igdtmpl[ 8 ]; cellsize = ( double ) ( gf->igdtmpl[ 14 ] * 1e-3 ); xmin = ( double ) ( gf->igdtmpl[ 10 ] ); ymin = ( double ) ( gf->igdtmpl[ 9 ] ); #ifdef DEBUG fprintf( stderr, "%d %d %f %f %f\n", nx, ny, cellsize, xmin, ymin ); #endif if ( ( nx == -1 ) || ( ny == -1 ) || ( ( pGrid = SG_Create_Grid( SG_DATATYPE_Float, nx, ny, cellsize, xmin, ymin ) ) == NULL ) ) return false; for ( x = 0; x < nx; x++ ) { for ( y = 0; y < ny; y ++ ) pGrid->Set_Value( x, y, gf->fld[ y * nx + x ] ); } return true; } saga-2.2.3/src/modules/io/io_grid_grib2/MLB_Interface.cpp0000664000175000017500000000224512565125414024244 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /* * Thomas Schorr 2007 */ #include "MLB_Interface.h" CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("GRIB Files") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( _TL("Thomas Schorr (c) 2007") ); case MLB_INFO_Description: return( _TW( "Import and export of GRIdded Binary (GRIB) files using the " "g2clib library of the National Center for Environmental Prediction (NCEP). " "Find more information at " "" "http://www.nco.ncep.noaa.gov/" )); case MLB_INFO_Version: return( _TL("0.1") ); case MLB_INFO_Menu_Path: return( _TL("File|Grid") ); } } #include "grib2_import.h" CSG_Module * Create_Module(int i) { CSG_Module *pModule; switch( i ) { case 0: pModule = new SGGrib2Import; break; default: pModule = NULL; break; } return( pModule ); } //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/io/io_grid_grib2/Makefile.am0000664000175000017500000000404712565125414023204 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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 -DUSE_JPEG2000 -DUSE_PNG CXX_INCS = -I$(top_srcdir)/src/saga_core $(LOCAL_INCS) AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS) $(GOMPFLAGS) #AM_LDFLAGS = -fPIC -shared -avoid-version -lpq -ljasper AM_LDFLAGS = -fPIC -shared -avoid-version $(LOCAL_LIBS) -ljasper pkglib_LTLIBRARIES = libio_grid_grib2.la libio_grid_grib2_la_SOURCES =\ ./g2clib-1.0.4/cmplxpack.c\ ./g2clib-1.0.4/compack.c\ ./g2clib-1.0.4/comunpack.c\ ./g2clib-1.0.4/dec_jpeg2000.c\ ./g2clib-1.0.4/dec_png.c\ ./g2clib-1.0.4/drstemplates.c\ ./g2clib-1.0.4/enc_jpeg2000.c\ ./g2clib-1.0.4/enc_png.c\ ./g2clib-1.0.4/g2_addfield.c\ ./g2clib-1.0.4/g2_addgrid.c\ ./g2clib-1.0.4/g2_addlocal.c\ ./g2clib-1.0.4/g2_create.c\ ./g2clib-1.0.4/g2_free.c\ ./g2clib-1.0.4/g2_getfld.c\ ./g2clib-1.0.4/g2_gribend.c\ ./g2clib-1.0.4/g2_info.c\ ./g2clib-1.0.4/g2_miss.c\ ./g2clib-1.0.4/g2_unpack1.c\ ./g2clib-1.0.4/g2_unpack2.c\ ./g2clib-1.0.4/g2_unpack3.c\ ./g2clib-1.0.4/g2_unpack4.c\ ./g2clib-1.0.4/g2_unpack5.c\ ./g2clib-1.0.4/g2_unpack6.c\ ./g2clib-1.0.4/g2_unpack7.c\ ./g2clib-1.0.4/gbits.c\ ./g2clib-1.0.4/getdim.c\ ./g2clib-1.0.4/getpoly.c\ ./g2clib-1.0.4/gridtemplates.c\ ./g2clib-1.0.4/int_power.c\ ./g2clib-1.0.4/jpcpack.c\ ./g2clib-1.0.4/jpcunpack.c\ ./g2clib-1.0.4/misspack.c\ ./g2clib-1.0.4/mkieee.c\ ./g2clib-1.0.4/pack_gp.c\ ./g2clib-1.0.4/pdstemplates.c\ ./g2clib-1.0.4/pngpack.c\ ./g2clib-1.0.4/pngunpack.c\ ./g2clib-1.0.4/rdieee.c\ ./g2clib-1.0.4/reduce.c\ ./g2clib-1.0.4/seekgb.c\ ./g2clib-1.0.4/simpack.c\ ./g2clib-1.0.4/simunpack.c\ ./g2clib-1.0.4/specpack.c\ ./g2clib-1.0.4/specunpack.c\ ./g2clib-1.0.4/drstemplates.h\ ./g2clib-1.0.4/grib2.h\ ./g2clib-1.0.4/gridtemplates.h\ ./g2clib-1.0.4/pdstemplates.h\ grib2_import.cpp\ MLB_Interface.cpp\ grib2_import.h\ MLB_Interface.h libio_grid_grib2_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/io/io_grid_grib2/MLB_Interface.h0000664000175000017500000000101112565125414023677 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /* * Thomas Schorr 2007 */ #ifndef HEADER_INCLUDED__io_grid_grib2_H #define HEADER_INCLUDED__io_grid_grib2_H #include #ifdef io_grid_grib2_EXPORTS #define io_grid_grib2_EXPORT _SAGA_DLL_EXPORT #else #define io_grid_grib2_EXPORT _SAGA_DLL_IMPORT #endif #endif // #ifndef HEADER_INCLUDED__io_grid_grib2_H saga-2.2.3/src/modules/io/io_grid_grib2/grib2_import.h0000664000175000017500000000140612565125414023714 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grib2_import.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /* * Thomas Schorr 2007 */ #ifndef HEADER_INCLUDED__grib2_import_H #define HEADER_INCLUDED__grib2_import_H #include "MLB_Interface.h" extern "C" { #include "g2clib-1.0.4/grib2.h" } class SGGrib2Import : public CSG_Module { public: SGGrib2Import(void); virtual ~SGGrib2Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: CSG_Grid *pGrid; gribfield *gf; bool handle_latlon( void ); bool handle_polar_stereographic( void ); }; #endif // #ifndef HEADER_INCLUDED__grib2_import_H saga-2.2.3/src/modules/io/io_esri_e00/0000775000175000017500000000000012634325742020542 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_esri_e00/e00compr/0000775000175000017500000000000012634325743022170 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_esri_e00/e00compr/cpl_vsi.h0000664000175000017500000001200412565125414023771 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_vsi.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_vsi.h * * Include file defining the Virtual System Interface (VSI) functions. This * should normally be included by all translators using VSI functions for * accessing system services. It is also used by the GDAL core, and can be * used by higher level applications which adhere to VSI use. * * Most VSI functions are direct analogs of Posix C library functions. * VSI exists to allow ``hooking'' these functions to provide application * specific checking, io redirection and so on. * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.4 1999/02/25 04:48:11 danmo * Added VSIStat() macros specific to _WIN32 (for MSVC++) * * Revision 1.3 1999/01/28 18:31:25 warmerda * Test on _WIN32 rather than WIN32. It seems to be more reliably defined. * * Revision 1.2 1998/12/04 21:42:57 danmo * Added #ifndef WIN32 arounf #include * * Revision 1.1 1998/12/03 18:26:02 warmerda * New * */ #ifndef CPL_VSI_H_INCLUDED #define CPL_VSI_H_INCLUDED #include "cpl_port.h" /* -------------------------------------------------------------------- */ /* We need access to ``struct stat''. */ /* -------------------------------------------------------------------- */ #ifndef _WIN32 # include #endif #include CPL_C_START /* ==================================================================== */ /* stdio file access functions. */ /* ==================================================================== */ FILE CPL_DLL * VSIFOpen( const char *, const char * ); int CPL_DLL VSIFClose( FILE * ); int CPL_DLL VSIFSeek( FILE *, long, int ); long CPL_DLL VSIFTell( FILE * ); void CPL_DLL VSIRewind( FILE * ); size_t CPL_DLL VSIFRead( void *, size_t, size_t, FILE * ); size_t CPL_DLL VSIFWrite( void *, size_t, size_t, FILE * ); char CPL_DLL *VSIFGets( char *, int, FILE * ); int CPL_DLL VSIFPuts( const char *, FILE * ); int CPL_DLL VSIFPrintf( FILE *, const char *, ... ); int CPL_DLL VSIFGetc( FILE * ); int CPL_DLL VSIFPutc( int, FILE * ); int CPL_DLL VSIUngetc( int, FILE * ); int CPL_DLL VSIFEof( FILE * ); /* ==================================================================== */ /* VSIStat() related. */ /* ==================================================================== */ typedef struct stat VSIStatBuf; int CPL_DLL VSIStat( const char *, VSIStatBuf * ); #ifdef _WIN32 # define VSI_ISLNK(x) ( 0 ) /* N/A on Windows */ # define VSI_ISREG(x) ((x) & S_IFREG) # define VSI_ISDIR(x) ((x) & S_IFDIR) # define VSI_ISCHR(x) ((x) & S_IFCHR) # define VSI_ISBLK(x) ( 0 ) /* N/A on Windows */ #else # define VSI_ISLNK(x) S_ISLNK(x) # define VSI_ISREG(x) S_ISREG(x) # define VSI_ISDIR(x) S_ISDIR(x) # define VSI_ISCHR(x) S_ISCHR(x) # define VSI_ISBLK(x) S_ISBLK(x) #endif /* ==================================================================== */ /* Memory allocation */ /* ==================================================================== */ void CPL_DLL *VSICalloc( size_t, size_t ); void CPL_DLL *VSIMalloc( size_t ); void CPL_DLL VSIFree( void * ); void CPL_DLL *VSIRealloc( void *, size_t ); char CPL_DLL *VSIStrdup( const char * ); CPL_C_END #endif /* ndef CPL_VSI_H_INCLUDED */ saga-2.2.3/src/modules/io/io_esri_e00/e00compr/e00compr.h0000664000175000017500000001506512565125414023771 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: e00compr.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /********************************************************************** * $Id: e00compr.h 911 2011-02-14 16:38:15Z reklov_w $ * * Name: e00compr.h * Project: Compressed E00 Read/Write library * Language: ANSI C * Purpose: Header file containing all definitions for the library. * Author: Daniel Morissette, danmo@videotron.ca * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.7 1999/02/25 18:47:40 daniel * Now use CPL for Error handling, Memory allocation, and File access. * * Revision 1.6 1999/01/08 17:40:33 daniel * Added E00Read/WriteCallbakcOpen() * * Revision 1.5 1998/11/13 15:39:45 daniel * Added functions for write support. * * Revision 1.4 1998/11/02 18:37:03 daniel * New file header, and added E00ErrorReset() * * Revision 1.1 1998/10/29 13:26:00 daniel * Initial revision * ********************************************************************** * Copyright (c) 1998, 1999, Daniel Morissette * * All rights reserved. This software may be copied or reproduced, in * all or in part, without the prior written consent of its author, * Daniel Morissette (danmo@videotron.ca). However, any material copied * or reproduced must bear the original copyright notice (above), this * original paragraph, and the original disclaimer (below). * * The entire risk as to the results and performance of the software, * supporting text and other information contained in this file * (collectively called the "Software") is with the user. Although * considerable efforts have been used in preparing the Software, the * author does not warrant the accuracy or completeness of the Software. * In no event will the author be liable for damages, including loss of * profits or consequential damages, arising out of the use of the * Software. * **********************************************************************/ #ifndef _E00COMPR_H_INCLUDED_ #define _E00COMPR_H_INCLUDED_ #ifdef __cplusplus extern "C" { #endif #include #include "cpl_port.h" #include "cpl_conv.h" #include "cpl_error.h" /*===================================================================== Data types and constants =====================================================================*/ #define E00_READ_BUF_SIZE 256 /* E00 lines are always 80 chars or less */ /* for both compressed and uncompressed */ /* files, except the first line (the EXP)*/ /* for which there is no known limit */ /* We'll assume that it can't be longer */ /* than 256 chars */ #define E00_WRITE_BUF_SIZE 256 /* This buffer must be big enough to hold*/ /* at least 2 lines of compressed output */ /* (i.e. 160 chars)... but just in case */ /* compressing a line would ever result */ /* in it becoming bigger than its source */ /* we'll set the size to 256 chars! */ #define E00_COMPR_NONE 0 /* Compression levels to use when writing*/ #define E00_COMPR_PARTIAL 1 #define E00_COMPR_FULL 2 /*--------------------------------------------------------------------- * E00ReadPtr * * A E00ReadPtr handle is used to hold information about the compressed * file currently being read. *--------------------------------------------------------------------*/ struct _E00ReadInfo { FILE *fp; /* Input file handle */ int bEOF; /* Reached EOF? */ int bIsCompressed; /* 1 if file is compressed, 0 if not */ int nInputLineNo; int iInBufPtr; /* Last character processed in szInBuf */ char szInBuf[E00_READ_BUF_SIZE]; /* compressed input buffer */ char szOutBuf[E00_READ_BUF_SIZE];/* uncompressed output buffer */ /* pRefData, pfnReadNextLine() and pfnReadRewind() are used only * when the file is opened with E00ReadCallbackOpen() * (and in this case the FILE *fp defined above is not used) */ void * pRefData; const char * (*pfnReadNextLine)(void *); void (*pfnReadRewind)(void *); }; typedef struct _E00ReadInfo *E00ReadPtr; /*--------------------------------------------------------------------- * E00WritePtr * * A E00WritePtr handle is used to hold information about the * file currently being written. *--------------------------------------------------------------------*/ struct _E00WriteInfo { FILE *fp; /* Output file handle */ int nComprLevel; int nSrcLineNo; int iOutBufPtr; /* Current position in szOutBuf */ char szOutBuf[E00_WRITE_BUF_SIZE]; /* compressed output buffer */ /* pRefData and pfnWriteNextLine() are used only * when the file is opened with E00WriteCallbackOpen() * (and in this case the FILE *fp defined above is not used) */ void *pRefData; int (*pfnWriteNextLine)(void *, const char *); }; typedef struct _E00WriteInfo *E00WritePtr; /*===================================================================== Function prototypes =====================================================================*/ E00ReadPtr E00ReadOpen(const char *pszFname); E00ReadPtr E00ReadCallbackOpen(void *pRefData, const char * (*pfnReadNextLine)(void *), void (*pfnReadRewind)(void *)); void E00ReadClose(E00ReadPtr psInfo); const char *E00ReadNextLine(E00ReadPtr psInfo); void E00ReadRewind(E00ReadPtr psInfo); E00WritePtr E00WriteOpen(const char *pszFname, int nComprLevel); E00WritePtr E00WriteCallbackOpen(void *pRefData, int (*pfnWriteNextLine)(void *, const char *), int nComprLevel); void E00WriteClose(E00WritePtr psInfo); int E00WriteNextLine(E00WritePtr psInfo, const char *pszLine); #ifdef __cplusplus } #endif #endif /* _E00COMPR_H_INCLUDED_ */ saga-2.2.3/src/modules/io/io_esri_e00/e00compr/cpl_conv.c0000664000175000017500000001547712565125414024151 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_conv.c 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_conv.c: Various CPL convenience functions (from cpl_conv.h). * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:00:59 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.4 1999/01/02 20:29:53 warmerda * Allow zero length allocations * * Revision 1.3 1998/12/15 19:01:07 warmerda * Added CPLReadLine(). * * Revision 1.2 1998/12/03 18:30:04 warmerda * Use CPLError() instead of GPSError(). * * Revision 1.1 1998/12/02 19:33:23 warmerda * New * */ #include "cpl_conv.h" /************************************************************************/ /* CPLCalloc() */ /************************************************************************/ void *CPLCalloc( size_t nCount, size_t nSize ) { void *pReturn; if( nSize == 0 ) return NULL; pReturn = VSICalloc( nCount, nSize ); if( pReturn == NULL ) { CPLError( CE_Fatal, CPLE_OutOfMemory, "CPLCalloc(): Out of memory allocating %d bytes.\n", nSize * nCount ); } return pReturn; } /************************************************************************/ /* CPLMalloc() */ /************************************************************************/ void *CPLMalloc( size_t nSize ) { void *pReturn; if( nSize == 0 ) return NULL; pReturn = VSIMalloc( nSize ); if( pReturn == NULL ) { CPLError( CE_Fatal, CPLE_OutOfMemory, "CPLMalloc(): Out of memory allocating %d bytes.\n", nSize ); } return pReturn; } /************************************************************************/ /* CPLRealloc() */ /************************************************************************/ void * CPLRealloc( void * pData, size_t nNewSize ) { void *pReturn; if( pData == NULL ) pReturn = VSIMalloc( nNewSize ); else pReturn = VSIRealloc( pData, nNewSize ); if( pReturn == NULL ) { CPLError( CE_Fatal, CPLE_OutOfMemory, "CPLRealloc(): Out of memory allocating %d bytes.\n", nNewSize ); } return pReturn; } /************************************************************************/ /* CPLStrdup() */ /************************************************************************/ char *CPLStrdup( const char * pszString ) { char *pszReturn; if( pszString == NULL ) pszString = ""; pszReturn = VSIStrdup( pszString ); if( pszReturn == NULL ) { CPLError( CE_Fatal, CPLE_OutOfMemory, "CPLStrdup(): Out of memory allocating %d bytes.\n", strlen(pszString) ); } return( pszReturn ); } /************************************************************************/ /* CPLReadLine() */ /* */ /* Read a line of text from the given file handle, taking care */ /* to capture CR and/or LF and strip off ... equivelent of */ /* DKReadLine(). Pointer to an internal buffer is returned. */ /* The application shouldn't free it, or depend on it's value */ /* past the next call to CPLReadLine() */ /* */ /* TODO: Allow arbitrarily long lines ... currently limited to */ /* 512 characters. */ /************************************************************************/ const char *CPLReadLine( FILE * fp ) { static char *pszRLBuffer = NULL; static int nRLBufferSize = 0; int nLength; /* -------------------------------------------------------------------- */ /* Allocate our working buffer. Eventually this should grow as */ /* needed ... we will implement that aspect later. */ /* -------------------------------------------------------------------- */ if( nRLBufferSize < 512 ) { nRLBufferSize = 512; pszRLBuffer = (char *) CPLRealloc(pszRLBuffer, nRLBufferSize); } /* -------------------------------------------------------------------- */ /* Do the actual read. */ /* -------------------------------------------------------------------- */ if( VSIFGets( pszRLBuffer, nRLBufferSize, fp ) == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* Clear CR and LF off the end. */ /* -------------------------------------------------------------------- */ nLength = strlen(pszRLBuffer); if( nLength > 0 && (pszRLBuffer[nLength-1] == 10 || pszRLBuffer[nLength-1] == 13) ) { pszRLBuffer[--nLength] = '\0'; } if( nLength > 0 && (pszRLBuffer[nLength-1] == 10 || pszRLBuffer[nLength-1] == 13) ) { pszRLBuffer[--nLength] = '\0'; } return( pszRLBuffer ); } saga-2.2.3/src/modules/io/io_esri_e00/e00compr/cpl_error.c0000664000175000017500000001320312565125414024316 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_error.c 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /********************************************************************** * $Id: cpl_error.c 911 2011-02-14 16:38:15Z reklov_w $ * * Name: cpl_error.cpp * Project: CPL - Common Portability Library * Purpose: Error handling functions. * Author: Daniel Morissette, danmo@videotron.ca * ********************************************************************** * Copyright (c) 1998, Daniel Morissette * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ********************************************************************** * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:00:59 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.3 1998/12/15 19:02:27 warmerda * Avoid use of errno as a variable * * Revision 1.2 1998/12/06 02:52:52 warmerda * Implement assert support * * Revision 1.1 1998/12/03 18:26:02 warmerda * New * **********************************************************************/ #include "cpl_error.h" /* static buffer to store the last error message. We'll assume that error * messages cannot be longer than 2000 chars... which is quite reasonable * (that's 25 lines of 80 chars!!!) */ static char gszCPLLastErrMsg[2000] = ""; static int gnCPLLastErrNo = 0; static void (*gpfnCPLErrorHandler)(CPLErr, int, const char *) = NULL; /********************************************************************** * CPLError() * * This function records an error code and displays the error message * to stderr. * * The error code can be accessed later using CPLGetLastErrNo() **********************************************************************/ void CPLError(CPLErr eErrClass, int err_no, const char *fmt, ...) { va_list args; /* Expand the error message */ va_start(args, fmt); vsprintf(gszCPLLastErrMsg, fmt, args); va_end(args); /* If the user provided his own error handling function, then call * it, otherwise print the error to stderr and return. */ gnCPLLastErrNo = err_no; if (gpfnCPLErrorHandler != NULL) { gpfnCPLErrorHandler(eErrClass, err_no, gszCPLLastErrMsg); } else { fprintf(stderr, "ERROR %d: %s\n", gnCPLLastErrNo, gszCPLLastErrMsg); } if( eErrClass == CE_Fatal ) abort(); } /********************************************************************** * CPLErrorReset() * * Erase any traces of previous errors. **********************************************************************/ void CPLErrorReset() { gnCPLLastErrNo = 0; gszCPLLastErrMsg[0] = '\0'; } /********************************************************************** * CPLGetLastErrorNo() * **********************************************************************/ int CPLGetLastErrorNo() { return gnCPLLastErrNo; } /********************************************************************** * CPLGetLastErrorMsg() * **********************************************************************/ const char* CPLGetLastErrorMsg() { return gszCPLLastErrMsg; } /********************************************************************** * CPLSetErrorHandler() * * Allow the library's user to specify his own error handler function. * * A valid error handler is a C function with the following prototype: * * void MyErrorHandler(int errno, const char *msg) * * Pass NULL to come back to the default behavior. **********************************************************************/ void CPLSetErrorHandler(void (*pfnErrorHandler)(CPLErr, int, const char *)) { gpfnCPLErrorHandler = pfnErrorHandler; } /************************************************************************/ /* _CPLAssert() */ /* */ /* This function is called only when an assertion fails. */ /************************************************************************/ void _CPLAssert( const char * pszExpression, const char * pszFile, int iLine ) { CPLError( CE_Fatal, CPLE_AssertionFailed, "Assertion `%s' failed\n" "in file `%s', line %d\n", pszExpression, pszFile, iLine ); } saga-2.2.3/src/modules/io/io_esri_e00/e00compr/cpl_port.h0000664000175000017500000002032012565125414024154 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_port.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_port.h * * Include file providing low level portability services for CPL. This * should be the first include file for any CPL based code. It provides the * following: * * o Includes some standard system include files, such as stdio, and stdlib. * * o Defines CPL_C_START, CPL_C_END macros. * * o Ensures that some other standard macros like NULL are defined. * * o Defines some portability stuff like CPL_MSB, or CPL_LSB. * * o Ensures that core types such as GBool, GInt32, GInt16, GUInt32, * GUInt16, and GByte are defined. * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.9 1999/02/17 01:41:17 warmerda * Added NULL. * * Revision 1.8 1999/02/02 21:32:38 warmerda * Added CPL_{MSB,LSB}WORD{16,32} macros. * * Revision 1.7 1999/02/02 19:02:36 warmerda * Removed duplicates of base types, and CPL_LSB * * Revision 1.6 1999/01/28 18:36:06 warmerda * Ensure WIN32 is defined on Windows. * * Revision 1.5 1999/01/28 05:26:12 danmo * Added byte swapping macros. * * Revision 1.4 1998/12/15 19:05:30 warmerda * added errno.h * * Revision 1.3 1998/12/14 04:50:07 warmerda * Added DBMALLOC support * * Revision 1.2 1998/12/04 21:38:40 danmo * Changed str*casecmp() to str*icmp() for WIN32 * * Revision 1.1 1998/12/03 18:26:02 warmerda * New * */ #ifndef CPL_BASE_H_INCLUDED #define CPL_BASE_H_INCLUDED /* ==================================================================== */ /* We will use WIN32 as a standard windows define. */ /* ==================================================================== */ #if defined(_WIN32) && !defined(WIN32) # define WIN32 #endif /* ==================================================================== */ /* Standard include files. */ /* ==================================================================== */ #include #include #include #include #include #include #ifdef DBMALLOC #include #endif /* ==================================================================== */ /* Base portability stuff ... this stuff may need to be */ /* modified for new platforms. */ /* ==================================================================== */ /*--------------------------------------------------------------------- * types for 16 and 32 bits integers, etc... *--------------------------------------------------------------------*/ #if UINT_MAX == 65535 typedef long GInt32; typedef unsigned long GUInt32; #else typedef int GInt32; typedef unsigned int GUInt32; #endif typedef short GInt16; typedef unsigned short GUInt16; typedef unsigned char GByte; typedef int GBool; /* ==================================================================== */ /* Other standard services. */ /* ==================================================================== */ #ifdef __cplusplus # define CPL_C_START extern "C" { # define CPL_C_END } #else # define CPL_C_START # define CPL_C_END #endif /* # define CPL_DLL __declspec(dllexport) */ #define CPL_DLL #ifndef NULL # define NULL 0 #endif #ifndef FALSE # define FALSE 0 #endif #ifndef TRUE # define TRUE 1 #endif #ifndef MAX # define MIN(a,b) ((ab) ? a : b) #endif #ifndef NULL #define NULL 0 #endif #ifndef ABS # define ABS(x) ((x<0) ? (-1*(x)) : x) #endif #ifndef EQUAL #ifdef WIN32 # define EQUALN(a,b,n) (strnicmp(a,b,n)==0) # define EQUAL(a,b) (stricmp(a,b)==0) #else # define EQUALN(a,b,n) (strncasecmp(a,b,n)==0) # define EQUAL(a,b) (strcasecmp(a,b)==0) #endif #endif /*--------------------------------------------------------------------- * CPL_LSB and CPL_MSB * Only one of these 2 macros should be defined and specifies the byte * ordering for the current platform. * This should be defined in the Makefile, but if it is not then * the default is CPL_LSB (Intel ordering, LSB first). *--------------------------------------------------------------------*/ #if ! ( defined(CPL_LSB) || defined(CPL_MSB) ) #define CPL_LSB #endif /*--------------------------------------------------------------------- * Little endian <==> big endian byte swap macros. *--------------------------------------------------------------------*/ #define CPL_SWAP16(x) \ ((GUInt16)( \ (((GUInt16)(x) & 0x00ffU) << 8) | \ (((GUInt16)(x) & 0xff00U) >> 8) )) #define CPL_SWAP32(x) \ ((GUInt32)( \ (((GUInt32)(x) & (GUInt32)0x000000ffUL) << 24) | \ (((GUInt32)(x) & (GUInt32)0x0000ff00UL) << 8) | \ (((GUInt32)(x) & (GUInt32)0x00ff0000UL) >> 8) | \ (((GUInt32)(x) & (GUInt32)0xff000000UL) >> 24) )) /* Until we have a safe 64 bits integer data type defined, we'll replace m * this version of the CPL_SWAP64() macro with a less efficient one. */ /* #define CPL_SWAP64(x) \ ((uint64)( \ (uint64)(((uint64)(x) & (uint64)0x00000000000000ffULL) << 56) | \ (uint64)(((uint64)(x) & (uint64)0x000000000000ff00ULL) << 40) | \ (uint64)(((uint64)(x) & (uint64)0x0000000000ff0000ULL) << 24) | \ (uint64)(((uint64)(x) & (uint64)0x00000000ff000000ULL) << 8) | \ (uint64)(((uint64)(x) & (uint64)0x000000ff00000000ULL) >> 8) | \ (uint64)(((uint64)(x) & (uint64)0x0000ff0000000000ULL) >> 24) | \ (uint64)(((uint64)(x) & (uint64)0x00ff000000000000ULL) >> 40) | \ (uint64)(((uint64)(x) & (uint64)0xff00000000000000ULL) >> 56) )) */ #define CPL_SWAPDOUBLE(p) { \ double _tmp = *(double *)(p); \ ((GByte *)(p))[0] = ((GByte *)&_tmp)[7]; \ ((GByte *)(p))[1] = ((GByte *)&_tmp)[6]; \ ((GByte *)(p))[2] = ((GByte *)&_tmp)[5]; \ ((GByte *)(p))[3] = ((GByte *)&_tmp)[4]; \ ((GByte *)(p))[4] = ((GByte *)&_tmp)[3]; \ ((GByte *)(p))[5] = ((GByte *)&_tmp)[2]; \ ((GByte *)(p))[6] = ((GByte *)&_tmp)[1]; \ ((GByte *)(p))[7] = ((GByte *)&_tmp)[0]; \ } #ifdef CPL_MSB # define CPL_MSBWORD16(x) (x) # define CPL_LSBWORD16(x) CPL_SWAP16(x) # define CPL_MSBWORD32(x) (x) # define CPL_LSBWORD32(x) CPL_SWAP32(x) #else # define CPL_LSBWORD16(x) (x) # define CPL_MSBWORD16(x) CPL_SWAP16(x) # define CPL_LSBWORD32(x) (x) # define CPL_MSBWORD32(x) CPL_SWAP32(x) #endif #endif /* ndef CPL_BASE_H_INCLUDED */ saga-2.2.3/src/modules/io/io_esri_e00/e00compr/e00read.c0000664000175000017500000005366512565125414023567 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: e00read.c 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /********************************************************************** * $Id: e00read.c 911 2011-02-14 16:38:15Z reklov_w $ * * Name: e00read.c * Project: Compressed E00 Read/Write library * Language: ANSI C * Purpose: Functions to read Compressed E00 files and return a stream * of uncompressed lines. * Author: Daniel Morissette, danmo@videotron.ca * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.8 1999/02/25 18:45:56 daniel * Now use CPL for Error handling, Memory allocation, and File access * * Revision 1.7 1999/01/08 17:39:08 daniel * Added E00ReadCallbackOpen() * * Revision 1.6 1998/11/13 16:34:08 daniel * Fixed '\r' problem when reading E00 files from a PC under Unix * * Revision 1.5 1998/11/13 15:48:08 daniel * Simplified the decoding of the compression codes for numbers * (use a logical rule instead of going case by case) * * Revision 1.4 1998/11/02 18:34:29 daniel * Added E00ErrorReset() calls. Replace "EXP 1" by "EXP 0" on read. * * Revision 1.1 1998/10/29 13:26:00 daniel * Initial revision * ********************************************************************** * Copyright (c) 1998, 1999, Daniel Morissette * * All rights reserved. This software may be copied or reproduced, in * all or in part, without the prior written consent of its author, * Daniel Morissette (danmo@videotron.ca). However, any material copied * or reproduced must bear the original copyright notice (above), this * original paragraph, and the original disclaimer (below). * * The entire risk as to the results and performance of the software, * supporting text and other information contained in this file * (collectively called the "Software") is with the user. Although * considerable efforts have been used in preparing the Software, the * author does not warrant the accuracy or completeness of the Software. * In no event will the author be liable for damages, including loss of * profits or consequential damages, arising out of the use of the * Software. * **********************************************************************/ #include #include #include #include #include "e00compr.h" static void _ReadNextSourceLine(E00ReadPtr psInfo); static const char *_UncompressNextLine(E00ReadPtr psInfo); /********************************************************************** * _E00ReadTestOpen() * * Given a pre-initialized E00ReadPtr, this function will make sure * that the file is really a E00 file, and also establish if it is * compressed or not... setting the structure members by the same way. * * Returns NULL (and destroys the E00ReadPtr) if the file does not * appear to be a valid E00 file. **********************************************************************/ static E00ReadPtr _E00ReadTestOpen(E00ReadPtr psInfo) { /* Check that the file is in E00 format. */ _ReadNextSourceLine(psInfo); if (!psInfo->bEOF && strncmp(psInfo->szInBuf, "EXP ", 4) == 0) { /* We should be in presence of a valid E00 file... * Is the file compressed or not? * * Note: we cannot really rely on the number that follows the EXP to * establish if the file is compressed since we sometimes encounter * uncompressed files that start with a "EXP 1" line!!! * * The best test is to read the first non-empty line: if the file is * compressed, the first line of data should be 79 or 80 characters * long and contain several '~' characters. */ do { _ReadNextSourceLine(psInfo); }while(!psInfo->bEOF && (psInfo->szInBuf[0] == '\0' || isspace(psInfo->szInBuf[0])) ); if (!psInfo->bEOF && (strlen(psInfo->szInBuf)==79 || strlen(psInfo->szInBuf)==80) && strchr(psInfo->szInBuf, '~') != NULL ) psInfo->bIsCompressed = 1; /* Move the Read ptr ready to read at the beginning of the file */ E00ReadRewind(psInfo); } else { CPLFree(psInfo); psInfo = NULL; } return psInfo; } /********************************************************************** * E00ReadOpen() * * Try to open a E00 file given its filename and return a E00ReadPtr handle. * * Returns NULL if the file could not be opened or if it does not * appear to be a valid E00 file. **********************************************************************/ E00ReadPtr E00ReadOpen(const char *pszFname) { E00ReadPtr psInfo = NULL; FILE *fp; CPLErrorReset(); /* Open the file */ fp = VSIFOpen(pszFname, "rt"); if (fp == NULL) { CPLError(CE_Failure, CPLE_OpenFailed, "Failed to open %s: %s", pszFname, strerror(errno)); return NULL; } /* File was succesfully opened, allocate and initialize a * E00ReadPtr handle and check that the file is valid. */ psInfo = (E00ReadPtr)CPLCalloc(1, sizeof(struct _E00ReadInfo)); psInfo->fp = fp; psInfo = _E00ReadTestOpen(psInfo); if (psInfo == NULL) { CPLError(CE_Failure, CPLE_OpenFailed, "%s is not a valid E00 file.", pszFname); } return psInfo; } /********************************************************************** * E00ReadCallbackOpen() * * This is an alternative to E00ReadOpen() for cases where you want to * do all the file management yourself. You open/close the file yourself * and provide 2 callback functions: to read from the file and rewind the * file pointer. pRefData is your handle on the physical file and can * be whatever you want... it is not used by the library, it will be * passed directly to your 2 callback functions when they are called. * * The callback functions must have the following C prototype: * * const char *myReadNextLine(void *pRefData); * void myReadRewind(void *pRefData); * * myReadNextLine() should return a reference to its own internal * buffer, or NULL if an error happens or EOF is reached. * * E00ReadCallbackOpen() returns a E00ReadPtr handle or NULL if the file * does not appear to be a valid E00 file. **********************************************************************/ E00ReadPtr E00ReadCallbackOpen(void *pRefData, const char * (*pfnReadNextLine)(void *), void (*pfnReadRewind)(void *)) { E00ReadPtr psInfo = NULL; CPLErrorReset(); /* Make sure we received valid function pointers */ if (pfnReadNextLine == NULL || pfnReadRewind == NULL) { CPLError(CE_Failure, CPLE_IllegalArg, "Invalid function pointers!"); return NULL; } /* Allocate and initialize a * E00ReadPtr handle and check that the file is valid. */ psInfo = (E00ReadPtr)CPLCalloc(1, sizeof(struct _E00ReadInfo)); psInfo->pRefData = pRefData; psInfo->pfnReadNextLine = pfnReadNextLine; psInfo->pfnReadRewind = pfnReadRewind; psInfo = _E00ReadTestOpen(psInfo); if (psInfo == NULL) { CPLError(CE_Failure, CPLE_OpenFailed, "This is not a valid E00 file."); } return psInfo; } /********************************************************************** * E00ReadClose() * * Close input file and release any memory used by the E00ReadPtr. **********************************************************************/ void E00ReadClose(E00ReadPtr psInfo) { CPLErrorReset(); if (psInfo) { if (psInfo->fp) VSIFClose(psInfo->fp); CPLFree(psInfo); } } /********************************************************************** * E00ReadRewind() * * Rewind the E00ReadPtr. Allows to start another read pass on the * input file. **********************************************************************/ void E00ReadRewind(E00ReadPtr psInfo) { CPLErrorReset(); psInfo->szInBuf[0] = psInfo->szOutBuf[0] = '\0'; psInfo->iInBufPtr = 0; psInfo->nInputLineNo = 0; if (psInfo->pfnReadRewind == NULL) VSIRewind(psInfo->fp); else psInfo->pfnReadRewind(psInfo->pRefData); psInfo->bEOF = 0; } /********************************************************************** * E00ReadNextLine() * * Return the next line of input from the E00 file or NULL if we reached EOF. * * Returns a reference to an internal buffer whose contents will be valid * only until the next call to this function. **********************************************************************/ const char *E00ReadNextLine(E00ReadPtr psInfo) { const char *pszLine = NULL; char *pszPtr; CPLErrorReset(); if (psInfo && !psInfo->bEOF) { if (!psInfo->bIsCompressed) { /* Uncompressed file... return line directly. */ _ReadNextSourceLine(psInfo); pszLine = psInfo->szInBuf; } else if (psInfo->bIsCompressed && psInfo->nInputLineNo == 0) { /* Header line in a compressed file... return line * after replacing "EXP 1" with "EXP 0". E00ReadOpen() * has already verified that this line starts with "EXP " */ _ReadNextSourceLine(psInfo); if ( (pszPtr = strstr(psInfo->szInBuf, " 1")) != NULL) pszPtr[1] = '0'; pszLine = psInfo->szInBuf; } else { if (psInfo->nInputLineNo == 1) { /* We just read the header line... reload the input buffer */ _ReadNextSourceLine(psInfo); } /* Uncompress the next line of input and return it */ pszLine = _UncompressNextLine(psInfo); } /* If we just reached EOF then make sure we don't add an extra * empty line at the end of the uncompressed oputput. */ if (psInfo->bEOF && strlen(pszLine) == 0) pszLine = NULL; } return pszLine; } /********************************************************************** * _ReadNextSourceLine() * * Loads the next line from the source file in psInfo. * * psInfo->bEOF should be checked after this call. **********************************************************************/ static void _ReadNextSourceLine(E00ReadPtr psInfo) { if (!psInfo->bEOF) { psInfo->iInBufPtr = 0; psInfo->szInBuf[0] = '\0'; /* Read either using fgets() or psInfo->pfnReadNextLine() * depending on the way the file was opened... */ if (psInfo->pfnReadNextLine == NULL) { if (VSIFGets(psInfo->szInBuf,E00_READ_BUF_SIZE,psInfo->fp) == NULL) { /* We reached EOF */ psInfo->bEOF = 1; } } else { const char *pszLine; pszLine = psInfo->pfnReadNextLine(psInfo->pRefData); if (pszLine) { strncpy(psInfo->szInBuf, pszLine, E00_READ_BUF_SIZE); } else { /* We reached EOF */ psInfo->bEOF = 1; } } if (!psInfo->bEOF) { /* A new line was succesfully read. Remove trailing '\n' if any. * (Note: For Unix systems, we also have to check for '\r') */ int nLen; nLen = strlen(psInfo->szInBuf); while(nLen > 0 && (psInfo->szInBuf[nLen-1] == '\n' || psInfo->szInBuf[nLen-1] == '\r' ) ) { nLen--; psInfo->szInBuf[nLen] = '\0'; } psInfo->nInputLineNo++; } } } /********************************************************************** * _GetNextSourceChar() * * Returns the next char from the source file input buffer... and * reload the input buffer when necessary... this function makes the * whole input file appear as one huge null-terminated string with * no line delimiters. * * Will return '\0' when EOF is reached. **********************************************************************/ static char _GetNextSourceChar(E00ReadPtr psInfo) { char c = '\0'; if (!psInfo->bEOF) { if (psInfo->szInBuf[psInfo->iInBufPtr] == '\0') { _ReadNextSourceLine(psInfo); c = _GetNextSourceChar(psInfo); } else { c = psInfo->szInBuf[psInfo->iInBufPtr++]; } } return c; } /********************************************************************** * _UngetSourceChar() * * Reverse the effect of the previous call to _GetNextSourceChar() by * moving the input buffer pointer back 1 character. * * This function can be called only once per call to _GetNextSourceChar() * (i.e. you cannot unget more than one character) otherwise the pointer * could move before the beginning of the input buffer. **********************************************************************/ static void _UngetSourceChar(E00ReadPtr psInfo) { if (psInfo->iInBufPtr > 0) psInfo->iInBufPtr--; else { /* This error can happen only if _UngetSourceChar() is called * twice in a row (which should never happen!). */ CPLError(CE_Failure, CPLE_AssertionFailed, "UNEXPECTED INTERNAL ERROR: _UngetSourceChar() " "failed while reading line %d.", psInfo->nInputLineNo); } } /********************************************************************** * _UncompressNextLine() * * Uncompress one line of input and return a reference to an internal * buffer containing the uncompressed output. **********************************************************************/ static const char *_UncompressNextLine(E00ReadPtr psInfo) { char c; int bEOL = 0; /* Set to 1 when End of Line reached */ int iOutBufPtr = 0, i, n; int iDecimalPoint, bOddNumDigits, iCurDigit; char *pszExp; int bPreviousCodeWasNumeric = 0; while(!bEOL && (c=_GetNextSourceChar(psInfo)) != '\0') { if (c != '~') { /* Normal character... just copy it */ psInfo->szOutBuf[iOutBufPtr++] = c; bPreviousCodeWasNumeric = 0; } else /* c == '~' */ { /* ======================================================== * Found an encoded sequence. * =======================================================*/ c = _GetNextSourceChar(psInfo); /* -------------------------------------------------------- * Compression level 1: only spaces, '~' and '\n' are encoded * -------------------------------------------------------*/ if (c == ' ') { /* "~ " followed by number of spaces */ c = _GetNextSourceChar(psInfo); n = c - ' '; for(i=0; iszOutBuf[iOutBufPtr++] = ' '; bPreviousCodeWasNumeric = 0; } else if (c == '}') { /* "~}" == '\n' */ bEOL = 1; bPreviousCodeWasNumeric = 0; } else if (bPreviousCodeWasNumeric) { /* If the previous code was numeric, then the only valid code * sequences are the ones above: "~ " and "~}". If we end up * here, it is because the number was followed by a '~' but * this '~' was not a code, it only marked the end of a * number that was not followed by any space. * * We should simply ignore the '~' and return the character * that follows it directly. */ psInfo->szOutBuf[iOutBufPtr++] = c; bPreviousCodeWasNumeric = 0; } else if (c == '~' || c == '-') { /* "~~" and "~-" are simple escape sequences for '~' and '-' */ psInfo->szOutBuf[iOutBufPtr++] = c; } /* -------------------------------------------------------- * Compression level 2: numeric values are encoded. * * All codes for this level are in the form "~ c0 c1 c2 ... cn" * where: * * ~ marks the beginning of a new code sequence * * c0 is a single character code defining the format * of the number (decimal position, exponent, * and even or odd number of digits) * * c1 c2 ... cn each of these characters represent a pair of * digits of the encoded value with '!' == 00 * values 92..99 are encoded on 2 chars that * must be added to each other * (i.e. 92 == }!, 93 == }", ...) * * The sequence ends with a ' ' or a '~' character * -------------------------------------------------------*/ else if (c >= '!' && c <= 'z') { /* The format code defines 3 characteristics of the final number: * - Presence of a decimal point and its position * - Presence of an exponent, and its sign * - Odd or even number of digits */ n = c - '!'; iDecimalPoint = n % 15; /* 0 = no decimal point */ bOddNumDigits = n / 45; /* 0 = even num.digits, 1 = odd */ n = n / 15; if ( n % 3 == 1 ) pszExp = "E+"; else if (n % 3 == 2 ) pszExp = "E-"; else pszExp = NULL; /* Decode the c1 c2 ... cn value and apply the format. * Read characters until we encounter a ' ' or a '~' */ iCurDigit = 0; while((c=_GetNextSourceChar(psInfo)) != '\0' && c != ' ' && c != '~') { n = c - '!'; if (n == 92 && (c=_GetNextSourceChar(psInfo)) != '\0') n += c - '!'; psInfo->szOutBuf[iOutBufPtr++] = '0' + n/10; if (++iCurDigit == iDecimalPoint) psInfo->szOutBuf[iOutBufPtr++] = '.'; psInfo->szOutBuf[iOutBufPtr++] = '0' + n%10; if (++iCurDigit == iDecimalPoint) psInfo->szOutBuf[iOutBufPtr++] = '.'; } if (c == '~' || c == ' ') { bPreviousCodeWasNumeric = 1; _UngetSourceChar(psInfo); } /* If odd number of digits, then flush the last one */ if (bOddNumDigits) iOutBufPtr--; /* Insert the exponent string before the 2 last digits * (we assume the exponent string is 2 chars. long) */ if (pszExp) { for(i=0; i<2;i++) { psInfo->szOutBuf[iOutBufPtr] = psInfo->szOutBuf[iOutBufPtr-2]; psInfo->szOutBuf[iOutBufPtr-2] = pszExp[i]; iOutBufPtr++; } } } else { /* Unsupported code sequence... this is a possibility * given the fact that this library was written by * reverse-engineering the format! * * Send an error to the user and abort. * * If this error ever happens, and you are convinced that * the input file is not corrupted, then please report it to * me at danmo@videotron.ca, quoting the section of the input * file that produced it, and I'll do my best to add support * for this code sequence. */ CPLError(CE_Failure, CPLE_NotSupported, "Unexpected code \"~%c\" encountered in line %d.", c, psInfo->nInputLineNo); /* Force the program to abort by simulating a EOF */ psInfo->bEOF = 1; bEOL = 1; } }/* if c == '~' */ /* E00 lines should NEVER be longer than 80 chars. if we passed * that limit, then the input file is likely corrupt. */ if (iOutBufPtr > 80) { CPLError(CE_Failure, CPLE_FileIO, "Uncompressed line longer than 80 chars. " "Input file possibly corrupt around line %d.", psInfo->nInputLineNo); /* Force the program to abort by simulating a EOF */ psInfo->bEOF = 1; bEOL = 1; } }/* while !EOL */ psInfo->szOutBuf[iOutBufPtr++] = '\0'; return psInfo->szOutBuf; } saga-2.2.3/src/modules/io/io_esri_e00/e00compr/cpl_vsisimple.c0000664000175000017500000002170212565125414025203 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_vsisimple.c 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_vsisimple.cpp * * This is a simple implementation (direct to Posix) of the Virtual System * Interface (VSI). See gdal_vsi.h. * * TODO: * - add some assertions to ensure that arguments are widely legal. For * instance validation of access strings to fopen(). * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.3 1998/12/14 04:50:33 warmerda * Avoid C++ comments so it will be C compilable as well. * * Revision 1.2 1998/12/04 21:42:57 danmo * Added #ifndef WIN32 arounf #include * * Revision 1.1 1998/12/03 18:26:03 warmerda * New * */ #include "cpl_vsi.h" /* for stat() */ #ifndef WIN32 # include #endif #include /************************************************************************/ /* VSIFOpen() */ /************************************************************************/ FILE *VSIFOpen( const char * pszFilename, const char * pszAccess ) { return( fopen( (char *) pszFilename, (char *) pszAccess ) ); } /************************************************************************/ /* VSIFClose() */ /************************************************************************/ int VSIFClose( FILE * fp ) { return( fclose(fp) ); } /************************************************************************/ /* VSIFSeek() */ /************************************************************************/ int VSIFSeek( FILE * fp, long nOffset, int nWhence ) { return( fseek( fp, nOffset, nWhence ) ); } /************************************************************************/ /* VSIFTell() */ /************************************************************************/ long VSIFTell( FILE * fp ) { return( ftell( fp ) ); } /************************************************************************/ /* VSIRewind() */ /************************************************************************/ void VSIRewind( FILE * fp ) { rewind( fp ); } /************************************************************************/ /* VSIFRead() */ /************************************************************************/ size_t VSIFRead( void * pBuffer, size_t nSize, size_t nCount, FILE * fp ) { return( fread( pBuffer, nSize, nCount, fp ) ); } /************************************************************************/ /* VSIFWrite() */ /************************************************************************/ size_t VSIFWrite( void * pBuffer, size_t nSize, size_t nCount, FILE * fp ) { return( fwrite( pBuffer, nSize, nCount, fp ) ); } /************************************************************************/ /* VSIFGets() */ /************************************************************************/ char *VSIFGets( char *pszBuffer, int nBufferSize, FILE * fp ) { return( fgets( pszBuffer, nBufferSize, fp ) ); } /************************************************************************/ /* VSIFGetc() */ /************************************************************************/ int VSIFGetc( FILE * fp ) { return( fgetc( fp ) ); } /************************************************************************/ /* VSIUngetc() */ /************************************************************************/ int VSIUngetc( int c, FILE * fp ) { return( ungetc( c, fp ) ); } /************************************************************************/ /* VSIFPrintf() */ /* */ /* This is a little more complicated than just calling */ /* fprintf() because of the variable arguments. Instead we */ /* have to use vfprintf(). */ /************************************************************************/ int VSIFPrintf( FILE * fp, const char * pszFormat, ... ) { va_list args; int nReturn; va_start( args, pszFormat ); nReturn = vfprintf( fp, pszFormat, args ); va_end( args ); return( nReturn ); } /************************************************************************/ /* VSIFEof() */ /************************************************************************/ int VSIFEof( FILE * fp ) { return( feof( fp ) ); } /************************************************************************/ /* VSIFPuts() */ /************************************************************************/ int VSIFPuts( const char * pszString, FILE * fp ) { return fputs( pszString, fp ); } /************************************************************************/ /* VSIFPutc() */ /************************************************************************/ int VSIFPutc( int nChar, FILE * fp ) { return( fputc( nChar, fp ) ); } /************************************************************************/ /* VSICalloc() */ /************************************************************************/ void *VSICalloc( size_t nCount, size_t nSize ) { return( calloc( nCount, nSize ) ); } /************************************************************************/ /* VSIMalloc() */ /************************************************************************/ void *VSIMalloc( size_t nSize ) { return( malloc( nSize ) ); } /************************************************************************/ /* VSIRealloc() */ /************************************************************************/ void * VSIRealloc( void * pData, size_t nNewSize ) { return( realloc( pData, nNewSize ) ); } /************************************************************************/ /* VSIFree() */ /************************************************************************/ void VSIFree( void * pData ) { if( pData != NULL ) free( pData ); } /************************************************************************/ /* VSIStrdup() */ /************************************************************************/ char *VSIStrdup( const char * pszString ) { return( strdup( pszString ) ); } /************************************************************************/ /* VSIStat() */ /************************************************************************/ int VSIStat( const char * pszFilename, VSIStatBuf * pStatBuf ) { return( stat( pszFilename, pStatBuf ) ); } saga-2.2.3/src/modules/io/io_esri_e00/e00compr/cpl_conv.h0000664000175000017500000000614712565125414024150 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_conv.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_conv.h * * Prototypes, and stuff for various convenience functions. This is intended * to remain light weight. * * $Log: * Revision 1.1 1998/10/18 06:15:11 warmerda * Initial implementation. * */ #ifndef CPL_CONV_H_INCLUDED #define CPL_CONV_H_INCLUDED #include "cpl_port.h" #include "cpl_vsi.h" #include "cpl_error.h" /* -------------------------------------------------------------------- */ /* Safe malloc() API. Thin cover over VSI functions with fatal */ /* error reporting if memory allocation fails. */ /* -------------------------------------------------------------------- */ CPL_C_START void CPL_DLL *CPLMalloc( size_t ); void CPL_DLL *CPLCalloc( size_t, size_t ); void CPL_DLL *CPLRealloc( void *, size_t ); char CPL_DLL *CPLStrdup( const char * ); #define CPLFree VSIFree /* -------------------------------------------------------------------- */ /* Read a line from a text file, and strip of CR/LF. */ /* -------------------------------------------------------------------- */ const char *CPLReadLine( FILE * ); /* -------------------------------------------------------------------- */ /* Fetch a function from DLL / so. */ /* -------------------------------------------------------------------- */ void CPL_DLL *CPLGetSymbol( const char *, const char * ); /* -------------------------------------------------------------------- */ /* Read a directory (cpl_dir.c) */ /* -------------------------------------------------------------------- */ char CPL_DLL **CPLReadDir( const char *pszPath ); CPL_C_END #endif /* ndef CPL_CONV_H_INCLUDED */ saga-2.2.3/src/modules/io/io_esri_e00/e00compr/e00write.c0000664000175000017500000005206412565125414023776 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: e00write.c 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /********************************************************************** * $Id: e00write.c 911 2011-02-14 16:38:15Z reklov_w $ * * Name: e00write.c * Project: Compressed E00 Read/Write library * Language: ANSI C * Purpose: Functions to write Compressed E00 files from a stream of * uncompressed lines. * Author: Daniel Morissette, danmo@videotron.ca * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.5 1999/02/25 18:46:41 daniel * Now use CPL for Error handling, Memory allocation, and File access. * * Revision 1.4 1999/01/08 17:40:01 daniel * Added E00WriteCallbackOpen() * * Revision 1.3 1998/11/13 16:54:23 daniel * Check for '\r' and '\n' at end of input line while compressing, just * in case... * * Revision 1.2 1998/11/13 15:48:42 daniel * Simplified the generation of the compression codes for numbers * (use a logical rule instead of going case by case) * * Revision 1.1 1998/11/13 14:19:51 daniel * Initial revision * ********************************************************************** * Copyright (c) 1998, 1999, Daniel Morissette * * All rights reserved. This software may be copied or reproduced, in * all or in part, without the prior written consent of its author, * Daniel Morissette (danmo@videotron.ca). However, any material copied * or reproduced must bear the original copyright notice (above), this * original paragraph, and the original disclaimer (below). * * The entire risk as to the results and performance of the software, * supporting text and other information contained in this file * (collectively called the "Software") is with the user. Although * considerable efforts have been used in preparing the Software, the * author does not warrant the accuracy or completeness of the Software. * In no event will the author be liable for damages, including loss of * profits or consequential damages, arising out of the use of the * Software. * **********************************************************************/ #include #include #include #include #include #include "e00compr.h" static int _CompressLine(E00WritePtr psInfo, const char *pszLine); static int _WriteNextCompressedLine(E00WritePtr psInfo, int nMaxChars); static int _PrintfNextLine(E00WritePtr psInfo, const char *pszFmt, ...); /********************************************************************** * E00WriteOpen() * * Try to open output file, and alloc/initialize a new E00WritePtr * handle. * * nComprLevel must be one of: * E00_COMPR_NONE, E00_COMPR_PARTIAL or E00_COMPR_FULL * * Returns the new handle, or NULL if the file could not be opened. * E00WriteClose() will eventually have to be called to release * the resources used by the new handle. **********************************************************************/ E00WritePtr E00WriteOpen(const char *pszFname, int nComprLevel) { E00WritePtr psInfo = NULL; FILE *fp; CPLErrorReset(); /* Open the file */ fp = VSIFOpen(pszFname, "wt"); if (fp == NULL) { CPLError(CE_Failure, CPLE_OpenFailed, "Failed to open %s: %s", pszFname, strerror(errno)); return NULL; } /* Allocate and initialize a E00ReadPtr handle. */ psInfo = (E00WritePtr)CPLCalloc(1, sizeof(struct _E00WriteInfo)); psInfo->fp = fp; psInfo->nComprLevel = nComprLevel; return psInfo; } /********************************************************************** * E00WriteCallbackOpen() * * This is an alternative to E00WriteOpen() for cases where you want to * do all the file management yourself. You open/close the file yourself * and provide a callback functions to write one line at a time to the * file. pRefData is your handle on the physical file and can * be whatever you want... it is not used by the library, it will be * passed directly to your callback function when it is called. * * The callback function must have the following C prototype: * * int myWriteNextLine(void *pRefData, const char *pszLine); * * Like printf() does, myWriteNextLine() should return a positive * value on success (the number of chars written) * or -1 if an error happened. * The value passed by the library in pszLine will not be terminated * by a '\n' character... it is assumed that the myWriteNextLine() * implementation will take care of terminating the line with a * '\n' if necessary. * * nComprLevel must be one of: * E00_COMPR_NONE, E00_COMPR_PARTIAL or E00_COMPR_FULL * * E00WriteCallbackOpen() returns a new E00ReadWritePtr handle. * E00WriteClose() will eventually have to be called to release * the resources used by the new handle. **********************************************************************/ E00WritePtr E00WriteCallbackOpen(void *pRefData, int (*pfnWriteNextLine)(void *, const char *), int nComprLevel) { E00WritePtr psInfo = NULL; CPLErrorReset(); /* Make sure we received a valid function pointer */ if (pfnWriteNextLine == NULL) { CPLError(CE_Failure, CPLE_IllegalArg, "Invalid function pointer!"); return NULL; } /* Allocate and initialize a E00ReadPtr handle. */ psInfo = (E00WritePtr)CPLCalloc(1, sizeof(struct _E00WriteInfo)); psInfo->pRefData = pRefData; psInfo->pfnWriteNextLine = pfnWriteNextLine; psInfo->nComprLevel = nComprLevel; return psInfo; } /********************************************************************** * E00WriteClose() * * Close output file and release any memory used by the E00WritePtr. **********************************************************************/ void E00WriteClose(E00WritePtr psInfo) { CPLErrorReset(); if (psInfo) { /* Flush output buffer before closing file. */ if (psInfo->iOutBufPtr > 0) _WriteNextCompressedLine(psInfo, 1); if (psInfo->fp) fclose(psInfo->fp); CPLFree(psInfo); } } /********************************************************************** * E00WriteNextLine() * * Take a line of what should be headed to a uncompressed E00 file, * convert it to the requested compression level, and write the * compressed result to the output file. * * Returns 0 if the line was processed succesfully, or an error number * (> 0) if an error happened. **********************************************************************/ int E00WriteNextLine(E00WritePtr psInfo, const char *pszLine) { char *pszPtr; int nStatus = 0; CPLErrorReset(); if (psInfo && (psInfo->fp || psInfo->pfnWriteNextLine)) { psInfo->nSrcLineNo++; if (psInfo->nComprLevel == E00_COMPR_NONE) { /* Uncompressed file... write line directly. */ nStatus = _PrintfNextLine(psInfo, "%s", pszLine); } else if (psInfo->nSrcLineNo == 1) { /* Header line in a compressed file... write line * after replacing "EXP 0" with "EXP 1". */ if ((pszPtr = strstr(pszLine, " 0")) != NULL) { nStatus = _PrintfNextLine(psInfo, "EXP 1%s", pszPtr+2); } else { /* Write line directly... assume that it contains a valid * EXP prefix! */ nStatus = _PrintfNextLine(psInfo, "%s", pszLine); } } else { /* FULL or PARTIAL compression... compress the current line, * (output goes in psInfo->szOutBuf) */ nStatus = _CompressLine(psInfo, pszLine); while (nStatus == 0 && psInfo->iOutBufPtr >= 80) { /* Time to write the first 80 chars from the output buffer */ nStatus = _WriteNextCompressedLine(psInfo, 0); } } } else { /* This should never happen unless the lib is not properly used * or if an error happened in previous calls and was ignored by * the caller */ CPLError(CE_Failure, CPLE_IllegalArg, "Invalid E00WritePtr handle!"); nStatus = 203; } return nStatus; } /********************************************************************** * _CompressLine() * * Compress one line of input, and store the compressed copy at the * end of psInfo->pszOutBuf. * * Returns 0 if the line was compressed succesfully, or an error number * (> 0) if an error happened. **********************************************************************/ static int _CompressLine(E00WritePtr psInfo, const char *pszLine) { int nStatus = 0; int nDigits, nExpSign, nDotPosition, iCurPos; int numTotalDigits, numExpDigits; char n, *pszCodePos; int nStartOutBufPtr; const char *pszStartSrcPtr; while(*pszLine != '\0' && *pszLine != '\n' && *pszLine != '\r') { /*------------------------------------------------------------- * By default, apply PARTIAL compression * Note that PARTIAL is a subset of FULL compression. *------------------------------------------------------------*/ if (*pszLine == '~') { /* The '~' char is encoded as "~~" */ strcpy( psInfo->szOutBuf+psInfo->iOutBufPtr, "~~"); psInfo->iOutBufPtr += 2; } else if (strncmp(pszLine, " ", 3) == 0) { /* A stream of at least 3 spaces. * Count number of spaces and replace with a "~ n" code */ n=1; while(*(pszLine+1) == ' ') { n++; pszLine++; } strcpy( psInfo->szOutBuf+psInfo->iOutBufPtr, "~ "); psInfo->iOutBufPtr += 2; psInfo->szOutBuf[psInfo->iOutBufPtr++] = ' ' + n; } /*------------------------------------------------------------- * The cases below are specific to FULL compression. *------------------------------------------------------------*/ else if (psInfo->nComprLevel == E00_COMPR_FULL && isdigit(*pszLine)) { /* Keep track of current input/output buffer positions in case * we would have to revert the encoding. This could happen if * the numeric value is less than 4 characters. */ nStartOutBufPtr = psInfo->iOutBufPtr; pszStartSrcPtr = pszLine; /* Reset flags used for parsing numeric format */ nDigits = 0; nDotPosition = 0; /* 0 means no decimal point */ nExpSign = 0; /* 0 means no exponent */ numExpDigits = 0; numTotalDigits = 0; n = 0; /* Prepare the code sequence in the output buffer. * The code value will be set only after the number * is finished parsing. */ psInfo->szOutBuf[psInfo->iOutBufPtr++] = '~'; pszCodePos = psInfo->szOutBuf+psInfo->iOutBufPtr++; /* Scan the numeric sequence, encoding the digits as we read, * and keeping track of decimal point position and exponent. */ for(iCurPos=0; *pszLine != '\0' && numExpDigits<2; pszLine++, iCurPos++) { if (isdigit(*pszLine)) { /* Accumulate pairs of digits */ numTotalDigits++; if (numTotalDigits % 2 == 1) { n = (*pszLine - '0')*10; } else { n += (*pszLine - '0'); if (n >= 92) { /* Pairs of digits > 92 are encoded on 2 chars */ psInfo->szOutBuf[psInfo->iOutBufPtr++] = 92 + '!'; n -= 92; } psInfo->szOutBuf[psInfo->iOutBufPtr++] = n + '!'; } /* Count number of exponent digits to end the loop * once we've read 2 exponent digits */ if (nExpSign != 0) numExpDigits++; } else if (*pszLine == '.' && nDotPosition == 0 && iCurPos < 15) { /* Decimal point position... make sure that we have only * one decimal point, and that it is not beyond the 14th * position. If these conditions are not met then end the * numeric sequence here. */ nDotPosition = iCurPos; } else if (*pszLine == 'E' && (*(pszLine+1) == '-' || *(pszLine+1)=='+') && isdigit(*(pszLine+2)) && isdigit(*(pszLine+3)) && !isdigit(*(pszLine+4)) ) { /* Exponent ... fetch sign, and read only 2 more digits * A "E+" or "E-" MUST be followed by 2 and only 2 digits. * If it's not the case, then the numeric sequence ends * here. */ pszLine++; nExpSign = (*pszLine=='-') ? -1: 1; } else { /* Numeric sequence finished ... stop parsing. */ break; } }/*for ... parsing numeric value*/ /* If the numeric value contains an even number of digits, * then pad the last pair of digits with a zero and encode it. */ if (numTotalDigits % 2 == 1) { psInfo->szOutBuf[psInfo->iOutBufPtr++] = n + '!'; } /* If the character that ends the number is NOT a '~', a ' ' * or a 'end of line' then add a '~' to mark the end of the * number. This extra '~' will be ignored by the uncompress * algorithm. */ if (*(pszLine) != '~' && *(pszLine) != ' ' && *(pszLine) != '\0') { psInfo->szOutBuf[psInfo->iOutBufPtr++] = '~'; } /* At the end of the loop, the read pointer is located on the char * that follows the numeric value. Move it back 1 char so that * processing can continue later with the outer loop. */ pszLine--; /* Check that the parsed value contains enough characters to * justify encoding it. The encoded value should not be * bigger than the original. If the encoded value is the same * size as the original then it is still encoded (a bit silly!). * All numbers < 4 chars are not encoded, and some, such as * "1092" won't either because it would require 5 chars to * encode them. * * If the value should not be encoded, then overwrite the sutff * we started encoding with a direct copy of the numeric value. * * (At this point, iCurPos is equal to the number of chars in the * source value.) */ if ( iCurPos < psInfo->iOutBufPtr - nStartOutBufPtr ) { strncpy(psInfo->szOutBuf+ nStartOutBufPtr, pszStartSrcPtr, iCurPos); psInfo->iOutBufPtr = nStartOutBufPtr + iCurPos; } else { /* Now that we have parsed the numeric value, set the code * based on the characteristics we found. */ *pszCodePos = '!' + ((numTotalDigits % 2 == 1)? 45:0) + (nExpSign?((nExpSign>0)?15:30):0) + nDotPosition; } } else { /* This char cannot be compressed ... output directly. */ psInfo->szOutBuf[psInfo->iOutBufPtr++] = *pszLine; } /* Check for buffer overflow... just in case!!! */ if (psInfo->iOutBufPtr >= E00_WRITE_BUF_SIZE) { /* The buffer size has been set big enough to prevent this error * from ever happening. So if it ever happens, then it's likely * that the input lines were longer than 80 chars, which is the * maximum length of a uncompressed line in a E00 file. */ CPLError(CE_Failure, CPLE_FileIO, "Output buffer overflow!!!."); nStatus = 205; break; } /* Get ready to proceed with next char from input string */ pszLine++; } /* Terminate this line with a newline code * This code applies to both PARTIAL and FULL compresion. */ strcpy( psInfo->szOutBuf+psInfo->iOutBufPtr, "~}"); psInfo->iOutBufPtr += 2; return nStatus; } /********************************************************************** * _WriteNextCompressedLine() * * If bFlushWholeBuffer == 0, write the first 80 characters from * psInfo->szOutBuf, and remove the written chars from szOutBuf. * A '\n' (not counted in nMaxChars) will be written to terminate the * output line. * * Pass bFlushBuffer == 1 to force writing the whole contents of szOutBuf * at once. * * Returns 0 if the line was written succesfully, or an error number * (> 0) if an error happened. **********************************************************************/ static int _WriteNextCompressedLine(E00WritePtr psInfo, int bFlushWholeBuffer) { int nStatus = 0, nToWrite; char *pszSrc, *pszDst; psInfo->szOutBuf[psInfo->iOutBufPtr] = '\0'; if (!bFlushWholeBuffer && psInfo->iOutBufPtr > 80) { /* Write the first 80 chars * Note that a compressed line cannot end with spaces... spaces should * be reported on the next line. */ nToWrite = 80; while(nToWrite > 1 && psInfo->szOutBuf[nToWrite-1] == ' ') nToWrite--; nStatus = _PrintfNextLine(psInfo, "%-.*s", nToWrite, psInfo->szOutBuf); /* Remove these chars from the output buffer */ pszDst = psInfo->szOutBuf; pszSrc = psInfo->szOutBuf+nToWrite; while(*pszSrc != '\0') { *pszDst = *pszSrc; pszDst++; pszSrc++; } psInfo->iOutBufPtr -= nToWrite; } else { /* Just write the buffer contents directly */ nStatus = _PrintfNextLine(psInfo, "%s", psInfo->szOutBuf); psInfo->iOutBufPtr = 0; } return nStatus; } /********************************************************************** * _PrintfNextLine() * * Cover function for fprintf() that will do error checking and * reporting, and either call fprintf() directly or call the callback * provided by the caller if E00WriteCallbackOpen() was used. * * A \n will be automatically appended to the string when it is * written, so no \n should be included at the end of pszFmt. * * Returns 0 on success, or error 204 if it failed. **********************************************************************/ static int _PrintfNextLine(E00WritePtr psInfo, const char *pszFmt, ...) { va_list args; static char szBuf[E00_WRITE_BUF_SIZE]; int nStatus = 0; /* Expand the string to print */ va_start(args, pszFmt); vsprintf(szBuf, pszFmt, args); va_end(args); /* Write the line using the right method */ if (psInfo->pfnWriteNextLine == NULL) { /* Use fprintf() directly */ if ( VSIFPrintf(psInfo->fp, "%s\n", szBuf) < 0) { CPLError(CE_Failure, CPLE_FileIO, "Error writing to file: %s", strerror(errno)); nStatus = 204; } } else { /* Use pfnWritenextLine() callback */ if ( psInfo->pfnWriteNextLine(psInfo->pRefData, szBuf) < 0) { CPLError(CE_Failure, CPLE_FileIO, "Error writing to file."); nStatus = 204; } } return nStatus; } saga-2.2.3/src/modules/io/io_esri_e00/e00compr/cpl_error.h0000664000175000017500000000773012565125414024333 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_error.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /********************************************************************** * $Id: cpl_error.h 911 2011-02-14 16:38:15Z reklov_w $ * * Name: cpl_error.h * Project: CPL - Common Portability Library * Purpose: CPL Error handling * Author: Daniel Morissette, danmo@videotron.ca * ********************************************************************** * Copyright (c) 1998, Daniel Morissette * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ********************************************************************** * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:00:59 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.6 1999/02/17 05:40:47 danmo * Fixed CPLAssert() macro to work with EGCS. * * Revision 1.5 1999/01/11 15:34:29 warmerda * added reserved range comment * * Revision 1.4 1998/12/15 19:02:27 warmerda * Avoid use of errno as a variable * * Revision 1.3 1998/12/06 22:20:42 warmerda * Added error code. * * Revision 1.2 1998/12/06 02:52:52 warmerda * Implement assert support * * Revision 1.1 1998/12/03 18:26:02 warmerda * New * **********************************************************************/ #ifndef _CPL_ERROR_H_INCLUDED_ #define _CPL_ERROR_H_INCLUDED_ #include "cpl_port.h" /*===================================================================== Error handling functions (cpl_error.c) =====================================================================*/ CPL_C_START typedef enum { CE_None = 0, CE_Log = 1, CE_Warning = 2, CE_Failure = 3, CE_Fatal = 4 } CPLErr; void CPL_DLL CPLError(CPLErr eErrClass, int err_no, const char *fmt, ...); void CPL_DLL CPLErrorReset(); int CPL_DLL CPLGetLastErrorNo(); const char CPL_DLL * CPLGetLastErrorMsg(); void CPL_DLL CPLSetErrorHandler(void(*pfnErrorHandler)(CPLErr,int, const char *)); void CPL_DLL _CPLAssert( const char *, const char *, int ); #ifdef DEBUG # define CPLAssert(expr) ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__)) #else # define CPLAssert(expr) #endif CPL_C_END /* ==================================================================== */ /* Well known error codes. */ /* ==================================================================== */ #define CPLE_AppDefined 1 #define CPLE_OutOfMemory 2 #define CPLE_FileIO 3 #define CPLE_OpenFailed 4 #define CPLE_IllegalArg 5 #define CPLE_NotSupported 6 #define CPLE_AssertionFailed 7 #define CPLE_NoWriteAccess 8 /* 100 - 299 reserved for GDAL */ #endif /* _CPL_ERROR_H_INCLUDED_ */ saga-2.2.3/src/modules/io/io_esri_e00/Makefile.in0000664000175000017500000006231512622651165022614 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/io_esri_e00 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_esri_e00_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am__dirstamp = $(am__leading_dot)dirstamp am_libio_esri_e00_la_OBJECTS = ESRI_E00_Import.lo MLB_Interface.lo \ e00compr/cpl_conv.lo e00compr/cpl_error.lo \ e00compr/cpl_vsisimple.lo e00compr/e00read.lo \ e00compr/e00write.lo libio_esri_e00_la_OBJECTS = $(am_libio_esri_e00_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(libio_esri_e00_la_SOURCES) DIST_SOURCES = $(libio_esri_e00_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_esri_e00.la libio_esri_e00_la_SOURCES = \ ESRI_E00_Import.cpp\ MLB_Interface.cpp\ e00compr/cpl_conv.c\ e00compr/cpl_error.c\ e00compr/cpl_vsisimple.c\ e00compr/e00read.c\ e00compr/e00write.c\ ESRI_E00_Import.h\ MLB_Interface.h\ e00compr/cpl_conv.h\ e00compr/cpl_error.h\ e00compr/cpl_port.h\ e00compr/cpl_vsi.h\ e00compr/e00compr.h libio_esri_e00_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .c .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) --foreign src/modules/io/io_esri_e00/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_esri_e00/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } e00compr/$(am__dirstamp): @$(MKDIR_P) e00compr @: > e00compr/$(am__dirstamp) e00compr/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) e00compr/$(DEPDIR) @: > e00compr/$(DEPDIR)/$(am__dirstamp) e00compr/cpl_conv.lo: e00compr/$(am__dirstamp) \ e00compr/$(DEPDIR)/$(am__dirstamp) e00compr/cpl_error.lo: e00compr/$(am__dirstamp) \ e00compr/$(DEPDIR)/$(am__dirstamp) e00compr/cpl_vsisimple.lo: e00compr/$(am__dirstamp) \ e00compr/$(DEPDIR)/$(am__dirstamp) e00compr/e00read.lo: e00compr/$(am__dirstamp) \ e00compr/$(DEPDIR)/$(am__dirstamp) e00compr/e00write.lo: e00compr/$(am__dirstamp) \ e00compr/$(DEPDIR)/$(am__dirstamp) libio_esri_e00.la: $(libio_esri_e00_la_OBJECTS) $(libio_esri_e00_la_DEPENDENCIES) $(EXTRA_libio_esri_e00_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_esri_e00_la_OBJECTS) $(libio_esri_e00_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f e00compr/*.$(OBJEXT) -rm -f e00compr/*.lo distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ESRI_E00_Import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@e00compr/$(DEPDIR)/cpl_conv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@e00compr/$(DEPDIR)/cpl_error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@e00compr/$(DEPDIR)/cpl_vsisimple.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@e00compr/$(DEPDIR)/e00read.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@e00compr/$(DEPDIR)/e00write.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf e00compr/.libs e00compr/_libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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) -rm -f e00compr/$(DEPDIR)/$(am__dirstamp) -rm -f e00compr/$(am__dirstamp) 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) e00compr/$(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) e00compr/$(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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/io/io_esri_e00/ESRI_E00_Import.cpp0000664000175000017500000011613412565125414023751 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ESRI_E00_Import.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 " "GRASS GIS Hompage " "for more information.\n" "The \'E00Compr\' library " "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_Table_List( NULL , "TABLES" , _TL("Tables"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Table_Output( NULL , "TABLE" , _TL("Table"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("ESRI E00 Files|*.e00|All Files|*.*"), NULL, false, false, true ); Parameters.Add_Value( NULL , "BBND" , _TL("Import Extents"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BTIC" , _TL("Import Tick Points"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BTABLES" , _TL("Import Tables"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CESRI_E00_Import::On_Execute(void) { int nLoaded = 0; m_bBnd = Parameters("BBND") ->asBool(); m_bTic = Parameters("BTIC") ->asBool(); m_bTables = Parameters("BTABLES") ->asBool(); m_pTables = Parameters("TABLES") ->asTableList(); m_pShapes = Parameters("SHAPES") ->asShapesList(); m_pGrids = Parameters("GRIDS") ->asGridList(); m_pTables ->Del_Items(); m_pShapes ->Del_Items(); m_pGrids ->Del_Items(); CSG_Strings fNames; if( Parameters("FILE")->asFilePath()->Get_FilePaths(fNames) && fNames.Get_Count() > 0 ) { for(int i=0; i 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const char * CESRI_E00_Import::E00_Read_Line(void) { const char *line = E00ReadNextLine(m_hReadPtr); if( line == NULL ) { FILE *fp = fopen(SG_File_Make_Path(NULL, m_e00_Name, CSG_String::Format(SG_T("e%02d"), m_iFile + 1)), "rb"); if( fp ) { m_iFile++; int nInputLineNo = m_hReadPtr->nInputLineNo; E00ReadRewind(m_hReadPtr); fclose(m_hReadPtr->fp); m_hReadPtr->fp = fp; m_hReadPtr->nInputLineNo = nInputLineNo - 1; line = E00ReadNextLine(m_hReadPtr); } } return( line ); } //--------------------------------------------------------- bool CESRI_E00_Import::E00_Goto_Line(int iLine) { if( m_hReadPtr ) { if( m_iFile == 0 ) { E00ReadRewind(m_hReadPtr); } else { E00ReadClose(m_hReadPtr); m_hReadPtr = E00ReadOpen(m_e00_Name); m_iFile = 0; } while( E00_Read_Line() && m_hReadPtr->nInputLineNo < iLine ); return( m_hReadPtr->nInputLineNo == iLine ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CESRI_E00_Import::Load(const CSG_String &FileName) { bool bResult = false; const char *Line; m_hReadPtr = NULL; m_e00_Name = FileName; m_iFile = 0; //----------------------------------------------------- if( (m_hReadPtr = E00ReadOpen(m_e00_Name)) == NULL ) { Error_Set(CSG_String::Format(SG_T("%s: %s"), _TL("file not found") , FileName.c_str())); } else if( (Line = E00_Read_Line()) == NULL ) { Error_Set(CSG_String::Format(SG_T("%s: %s"), _TL("invalid E00 file"), FileName.c_str())); } else if( strncmp(Line, "EXP", 3) ) { Error_Set(CSG_String::Format(SG_T("%s: %d"), _TL("invalid E00 file"), FileName.c_str())); } //----------------------------------------------------- else { bResult = Load(); } //----------------------------------------------------- if( m_hReadPtr ) { E00ReadClose(m_hReadPtr); } return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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; //----------------------------------------------------- m_pPAT = NULL; m_pAAT = NULL; //----------------------------------------------------- while( (line = E00_Read_Line()) != NULL && strncmp(line, "EOS", 3) ) { current_line = m_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( m_pPAT ? (m_pAAT ? 3 : 2) : (m_pAAT ? 1 : 0) ) { case 0: default: shape_type = offset_arc != 0 ? SHAPE_TYPE_Line : SHAPE_TYPE_Point; break; case 1: // m_pAAT shape_type = SHAPE_TYPE_Line; break; case 2: // m_pPAT shape_type = offset_arc != 0 ? SHAPE_TYPE_Polygon : SHAPE_TYPE_Point; break; case 3: // m_pAAT && m_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 ) { E00_Goto_Line(offset_grd); if( (pGrid = getraster (prec_grd, scale)) != NULL ) { pGrid->Set_Name(SG_File_Get_Name(m_e00_Name, false)); m_pGrids->Add_Item(pGrid); } } //----------------------------------------------------- if( offset_arc != 0 ) { E00_Goto_Line(offset_arc); if( (pShapes = getarcs (prec_arc, scale, shape_type)) != NULL ) { pShapes->Set_Name(SG_File_Get_Name(m_e00_Name, false)); m_pShapes->Add_Item(pShapes); } } //----------------------------------------------------- if( offset_lab != 0 && shape_type == SHAPE_TYPE_Point ) { E00_Goto_Line(offset_lab); if( (pShapes = getsites (prec_lab, scale)) != NULL ) { pShapes->Set_Name(SG_File_Get_Name(m_e00_Name, false)); m_pShapes->Add_Item(pShapes); } } //----------------------------------------------------- if( offset_lab != 0 && shape_type != SHAPE_TYPE_Point ) { E00_Goto_Line(offset_lab); if( (pShapes = getlabels(prec_lab, scale)) != NULL ) { pShapes->Set_Name(SG_File_Get_Name(m_e00_Name, false)); m_pShapes->Add_Item(pShapes); } } //----------------------------------------------------- if( !m_bTables ) { if( m_pPAT ) delete(m_pPAT); if( m_pAAT ) delete(m_pAAT); } 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 = E00_Read_Line()) == 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 = E00_Read_Line()) == NULL ) return( NULL ); sscanf(line, "%lf%lf", &xres, &yres); if( (line = E00_Read_Line()) == NULL ) return( NULL ); sscanf(line, "%lf%lf", &xmin, &ymin); if( (line = E00_Read_Line()) == 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; ySet_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; ySet_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; ySet_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 = E00_Read_Line()) == 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; iPointAdd_Point(x_buf[0] * scale, y_buf[0] * scale); } } } //--------------------------------------------- else // single precision : 2 x,y pairs / line { for(iPoint=0; iPointAdd_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) { //----------------------------------------------------- Process_Set_Text(_TL("Arcs to polygons")); CSG_Shapes *pPolygons = SG_Create_Shapes(SHAPE_TYPE_Polygon); pPolygons->Add_Field("ID", SG_DATATYPE_Int); //----------------------------------------------------- for(int iArc=0; iArcGet_Count() && Set_Progress(iArc, pArcs->Get_Count()); iArc++) { Arcs2Polygon(pArcs, pPolygons, pArcs->Get_Shape(iArc)->asInt(ARC_LPOL)); Arcs2Polygon(pArcs, pPolygons, pArcs->Get_Shape(iArc)->asInt(ARC_RPOL)); } //----------------------------------------------------- delete(pArcs); pPolygons->Make_Clean(); return( pPolygons ); } //--------------------------------------------------------- void CESRI_E00_Import::Arcs2Polygon(CSG_Shapes *pArcs, CSG_Shapes *pPolygons, int id) { //----------------------------------------------------- if( id <= 1 ) { return; } //----------------------------------------------------- CSG_Shapes Segments(SHAPE_TYPE_Line); Segments.Add_Field("FNODE", SG_DATATYPE_Int); Segments.Add_Field("TNODE", SG_DATATYPE_Int); //----------------------------------------------------- for(int iArc=0; iArcGet_Count(); iArc++) { CSG_Shape *pArc = pArcs->Get_Shape(iArc); if( id == pArc->asInt(ARC_LPOL) ) { CSG_Shape *pSegment = Segments.Add_Shape(); pSegment->Set_Value(0, pArc->asInt(ARC_FNODE)); pSegment->Set_Value(1, pArc->asInt(ARC_TNODE)); for(int iVertex=0; iVertexGet_Point_Count(0); iVertex++) { pSegment->Add_Point(pArc->Get_Point(iVertex, 0, false), 0); } pArc->Set_Value(ARC_LPOL, -1); } else if( id == pArc->asInt(ARC_RPOL) ) { CSG_Shape *pSegment = Segments.Add_Shape(); pSegment->Set_Value(1, pArc->asInt(ARC_FNODE)); pSegment->Set_Value(0, pArc->asInt(ARC_TNODE)); for(int iVertex=0; iVertexGet_Point_Count(0); iVertex++) { pSegment->Add_Point(pArc->Get_Point(iVertex, 0, true), 0); } pArc->Set_Value(ARC_RPOL, -1); } } if( Segments.Get_Count() <= 0 ) { return; } //----------------------------------------------------- CSG_Shape *pPolygon = pPolygons->Add_Shape(); pPolygon->Set_Value(0, id); while( Segments.Get_Count() > 0 ) { CSG_Shape *pSegment = Segments.Get_Shape(0); int iPart = pPolygon->Get_Part_Count(); do { for(int iVertex=0; iVertexGet_Point_Count(0); iVertex++) { pPolygon->Add_Point(pSegment->Get_Point(iVertex), iPart); } int fNode = pSegment->asInt(0); int tNode = pSegment->asInt(1); Segments.Del_Shape(pSegment); pSegment = NULL; if( fNode != tNode ) { for(int iSegment=0; iSegmentasInt(1) ) { pSegment = Segments.Get_Shape(iSegment); } } } } while( pSegment ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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 = E00_Read_Line()) != 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); //--------------------------------------------- E00_Read_Line(); // 4 values to skip if( prec ) { E00_Read_Line(); // 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 = E00_Read_Line()) != 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); //------------------------------------------------- E00_Read_Line(); // 4 values to skip if( prec ) { E00_Read_Line(); // 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 = E00_Read_Line()) != 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 = E00_Read_Line()) != 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; iAdd_Field("XMIN", SG_DATATYPE_Double); pShapes->Add_Field("YMIN", SG_DATATYPE_Double); pShapes->Add_Field("XMAX", SG_DATATYPE_Double); pShapes->Add_Field("YMAX", SG_DATATYPE_Double); CSG_Table_Record *pRecord = pTable->Get_Record(0); CSG_Shape *pShape = pShapes->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)); m_pShapes->Add_Item(pShapes); } delete(pTable); } //--------------------------------------------- else if( !s.CmpNoCase(SG_T("tic")) ) // tick marks { if( m_bTic ) { CSG_Shapes *pShapes = SG_Create_Shapes(SHAPE_TYPE_Point, SG_T("Tick Points")); pShapes->Add_Field("ID", SG_DATATYPE_Int); pShapes->Add_Field("X" , SG_DATATYPE_Double); pShapes->Add_Field("Y" , SG_DATATYPE_Double); for(i=0; iGet_Record_Count(); i++) { CSG_Table_Record *pRecord = pTable->Get_Record(i); CSG_Shape *pShape = pShapes->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)); } m_pShapes->Add_Item(pShapes); } delete(pTable); } //--------------------------------------------- else if( m_bTables ) { m_pTables->Add_Item(pTable); } //--------------------------------------------- else if( pTable != m_pPAT && pTable != m_pAAT ) { delete(pTable); } } } //----------------------------------------------------- // 0 if none, 1 if AAT, 2 if PAT, 3 if both return( m_pPAT ? (m_pAAT ? 3 : 2) : (m_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; iFieldAdd_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; iRecordAdd_Record(); for(iField=0; iFieldGet_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; iRecordGet_Field_Count() <= 0 || !m_pPAT || m_pPAT->Get_Field_Count() <= 2 ) { return( false ); } Process_Set_Text(_TL("Assign attributes to shapes...")); int iField, off_Field = pShapes->Get_Field_Count(); for(iField=0; iFieldGet_Field_Count(); iField++) { pShapes->Add_Field(m_pPAT->Get_Field_Name(iField), m_pPAT->Get_Field_Type(iField)); } for(int i=0; iGet_Count() && Set_Progress(i, m_pPAT->Get_Count()); i++) { CSG_Shape *pShape = pShapes->Get_Shape(i); CSG_Table_Record *pRecord = m_pPAT->Get_Record(pShape->asInt(0) - 1); if( pRecord ) { for(iField=0; iFieldGet_Field_Count(); iField++) { if( SG_Data_Type_is_Numeric(m_pPAT->Get_Field_Type(iField)) ) pShape->Set_Value(off_Field + iField, pRecord->asDouble(iField)); else pShape->Set_Value(off_Field + iField, pRecord->asString(iField)); } } } return( true ); /* pShapes->Set_Index(0, TABLE_INDEX_Ascending); m_pPAT ->Set_Index(3, TABLE_INDEX_Ascending); for(int iShape=0, off_Record=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape_byIndex(iShape); int id = pShape->asInt(0); for(int iRecord=off_Record; iRecordGet_Record_Count(); iRecord++) { CSG_Table_Record *pRecord = m_pPAT->Get_Record_byIndex(iRecord); if( id == pRecord->asInt(3) ) { for(iField=0; iFieldGet_Field_Count(); iField++) { if( SG_Data_Type_is_Numeric(m_pPAT->Get_Field_Type(iField)) ) pShape->Set_Value(off_Field + iField, pRecord->asDouble(iField)); else pShape->Set_Value(off_Field + iField, pRecord->asString(iField)); } off_Record++; break; } } } return( true );/**/ } /////////////////////////////////////////////////////////// // // // Skips // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CESRI_E00_Import::skip(char *end) { const char *line; int l = strlen(end); while( (line = E00_Read_Line()) != NULL && strncmp(line, end, l) ); } //--------------------------------------------------------- void CESRI_E00_Import::skip_dat(void) { const char *line; int i = 0; while( (line = E00_Read_Line()) != 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 = E00_Read_Line()) != NULL ) { sscanf(line, "%lf %lf %lf", &xmin, &ymin, &xmax); if( (line = E00_Read_Line()) != 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-- ) { E00_Read_Line(); } } } } //--------------------------------------------------------- void CESRI_E00_Import::skip_arc(int prec) { const char *line; int i, covnum, nPoints; while( (line = E00_Read_Line()) != 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 //--------------------------------------------------------- #ifdef io_esri_e00_EXPORTS #define io_esri_e00_EXPORT _SAGA_DLL_EXPORT #else #define io_esri_e00_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_esri_e00_H saga-2.2.3/src/modules/io/io_esri_e00/ESRI_E00_Import.h0000664000175000017500000001204512565125414023412 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ESRI_E00_Import.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // ESRI_E00.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // ESRI_E00.h // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ESRI_E00_H #define HEADER_INCLUDED__ESRI_E00_H //--------------------------------------------------------- #include "MLB_Interface.h" #include "./e00compr/e00compr.h" //--------------------------------------------------------- class CESRI_E00_Import : public CSG_Module { public: CESRI_E00_Import(void); protected: virtual bool On_Execute(void); private: bool m_bBnd, m_bTic, m_bTables; int m_iFile; E00ReadPtr m_hReadPtr; CSG_String m_e00_Name; CSG_Table *m_pPAT, *m_pAAT; CSG_Parameter_Table_List *m_pTables; CSG_Parameter_Shapes_List *m_pShapes; CSG_Parameter_Grid_List *m_pGrids; bool Load (const CSG_String &FileName); bool Load (void); const char * E00_Read_Line (void); bool E00_Goto_Line (int iLine); CSG_Grid * getraster (int prec, double scale); CSG_Shapes * getarcs (int prec, double scale, TSG_Shape_Type &shape_type); CSG_Shapes * getlabels (int prec, double scale); CSG_Shapes * getsites (int prec, double scale); double getproj (void); int info_Get_Tables (void); CSG_Table * info_Get_Table (struct info_Table info); void info_Skip_Table (struct info_Table info); void info_Get_Record (char *buffer, int buffer_length); bool Assign_Attributes (CSG_Shapes *pShapes); CSG_Shapes * Arcs2Polygons (CSG_Shapes *pArcs); void Arcs2Polygon (CSG_Shapes *pArcs, CSG_Shapes *pPolygons, int id); void skip (char *end); void skip_dat (void); void skip_msk (void); void skip_arc (int prec); void skip_lab (int prec); void skip_pal (int prec); void skip_txt (int prec); }; #endif // #ifndef HEADER_INCLUDED__ESRI_E00_H saga-2.2.3/src/modules/io/io_shapes_las/0000775000175000017500000000000012634325744021260 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_shapes_las/las_export.cpp0000664000175000017500000003546412565125414024153 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_export.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_export.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "las_export.h" #include #include #include #include #include #include //--------------------------------------------------------- #define MAX_NUM_RETURN 5 //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLAS_Export::CLAS_Export(void) { CSG_Parameter *pNodeAttr; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export LAS Files")); Set_Author (SG_T("Volker Wichmann (c) 2010, LASERDATA GmbH")); CSG_String Description(_TW( "This module exports a SAGA Point Cloud as ASPRS LAS file (version 1.2) " "using the \"libLAS\" library. It allows to write Point Data Record Formats 1 to 4. " "Please have a look at the ASPRS LAS 1.2 Format Specification for " "more information on the attributes supported with each format.\n" "Get more information about the \"libLAS\" library at " "http://liblas.org\n" "Please note, that the liblas writer does an \"isValid()\" check on each point. " "This might cause problems with MLS data because of the included scan angle check. " "MLS data ususally includes larger scan angles than ALS data and thus points may fail the " "test. Please always have a look at the summary printed in the message window.\n\n" "\nliblas version: " )); Description += CSG_String(LIBLAS_RELEASE_NAME); Set_Description (Description); //----------------------------------------------------- // 2. Parameters... pNodeAttr = Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Point Cloud"), _TL("The point cloud to export."), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNodeAttr , "T" , _TL("gps-time"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "i" , _TL("intensity"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "a" , _TL("scan angle"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "r" , _TL("number of the return"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "n" , _TL("number of returns of given pulse"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "c" , _TL("classification"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "u" , _TL("user data"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "R" , _TL("red channel color"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "G" , _TL("green channel color"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "B" , _TL("blue channel color"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "e" , _TL("edge of flight line flag"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "d" , _TL("direction of scan flag"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "p" , _TL("point source ID"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "RGB" , _TL("SAGA RGB color"), _TL(""), true ); Parameters.Add_Value( NULL , "OFF_X" , _TL("Offset X"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( NULL , "OFF_Y" , _TL("Offset Y"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( NULL , "OFF_Z" , _TL("Offset Z"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( NULL , "SCALE_X" , _TL("Scale X"), _TL(""), PARAMETER_TYPE_Double, 0.001 ); Parameters.Add_Value( NULL , "SCALE_Y" , _TL("Scale Y"), _TL(""), PARAMETER_TYPE_Double, 0.001 ); Parameters.Add_Value( NULL , "SCALE_Z" , _TL("Scale Z"), _TL(""), PARAMETER_TYPE_Double, 0.001 ); Parameters.Add_Choice( NULL, "FORMAT", _TL("Point Data Record Format"), _TL("Choose the Point Data Record Format you like to use"), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("0"), _TL("1"), _TL("2"), _TL("3") ), 3 ); Parameters.Add_FilePath( NULL , "FILE" , _TL("Output File"), _TL("The LAS output file."), _TL("LAS Files (*.las)|*.las|All Files|*.*"), NULL, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLAS_Export::On_Execute(void) { CSG_PointCloud *pPoints; CSG_String fName; int i_T, i_i, i_a, i_r, i_n, i_c, i_u, i_R, i_G, i_B, i_e, i_d, i_p, i_RGB; double off_X, off_Y, off_Z; double scale_X, scale_Y, scale_Z; int format; int cntRead = 0, cntWrite = 0; double x, y, z, xmin, ymin, zmin, xmax, ymax, zmax; liblas::uint32_t binPulse[MAX_NUM_RETURN]; liblas::uint16_t r; std::ofstream ofs; //----------------------------------------------------- pPoints = Parameters("POINTS")->asPointCloud(); i_T = Parameters("T")->asInt(); i_i = Parameters("i")->asInt(); i_a = Parameters("a")->asInt(); i_r = Parameters("r")->asInt(); i_n = Parameters("n")->asInt(); i_c = Parameters("c")->asInt(); i_u = Parameters("u")->asInt(); i_R = Parameters("R")->asInt(); i_G = Parameters("G")->asInt(); i_B = Parameters("B")->asInt(); i_e = Parameters("e")->asInt(); i_d = Parameters("d")->asInt(); i_p = Parameters("p")->asInt(); i_RGB = Parameters("RGB")->asInt(); off_X = Parameters("OFF_X")->asDouble(); off_Y = Parameters("OFF_Y")->asDouble(); off_Z = Parameters("OFF_Z")->asDouble(); scale_X = Parameters("SCALE_X")->asDouble(); scale_Y = Parameters("SCALE_Y")->asDouble(); scale_Z = Parameters("SCALE_Z")->asDouble(); format = Parameters("FORMAT")->asInt(); fName = Parameters("FILE")->asString(); ofs.open(fName.b_str(), std::ios::out | std::ios::binary); if (!ofs) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unable to open LAS file!"))); return (false); } //----------------------------------------------------- liblas::LASHeader header; switch (format) { case 0: header.SetDataFormatId(liblas::LASHeader::ePointFormat0); break; case 1: header.SetDataFormatId(liblas::LASHeader::ePointFormat1); break; case 2: header.SetDataFormatId(liblas::LASHeader::ePointFormat2); break; case 3: default: header.SetDataFormatId(liblas::LASHeader::ePointFormat3); break; } header.SetOffset(off_X, off_Y, off_Z); header.SetScale(scale_X, scale_Y, scale_Z); // Get_ZMin() and Get_ZMax() do currently not work: /*header.SetMin( (pPoints->Get_Extent().Get_XMin() - off_X) / scale_X, (pPoints->Get_Extent().Get_YMin() - off_Y) / scale_Y, (pPoints->Get_ZMin() - off_Z) / scale_Z); header.SetMax( (pPoints->Get_Extent().Get_XMax() - off_X) / scale_X, (pPoints->Get_Extent().Get_YMax() - off_Y) / scale_Y, (pPoints->Get_ZMax() - off_Z) / scale_Z);*/ liblas::LASWriter writer(ofs, header); if( pPoints->Get_Count() > 0 ) { xmin = xmax = pPoints->Get_X(0); ymin = ymax = pPoints->Get_Y(0); zmin = zmax = pPoints->Get_Z(0); } for( int i=0; iGet_Count() && SG_UI_Process_Set_Progress(i, pPoints->Get_Count()); i++ ) { cntRead++; liblas::LASPoint point; x = pPoints->Get_X(i); y = pPoints->Get_Y(i); z = pPoints->Get_Z(i); x < xmin ? xmin = x : NULL; x > xmax ? xmax = x : NULL; y < ymin ? ymin = y : NULL; y > ymax ? ymax = y : NULL; z < zmin ? zmin = z : NULL; z > zmax ? zmax = z : NULL; point.SetCoordinates(x, y, z); if( i_T > -1 ) point.SetTime(pPoints->Get_Value(i, i_T)); if( i_i > -1 ) point.SetIntensity((liblas::uint16_t)pPoints->Get_Value(i, i_i)); if( i_a > -1 ) point.SetScanAngleRank((liblas::int8_t)pPoints->Get_Value(i, i_a)); if( i_r > -1 ) { r = (liblas::uint16_t)pPoints->Get_Value(i, i_r); point.SetReturnNumber(r); if( r > 0 && r <= MAX_NUM_RETURN ) binPulse[r-1] += 1; } if( i_n > -1 ) point.SetNumberOfReturns((liblas::uint16_t)pPoints->Get_Value(i, i_n)); if( i_c > -1 ) point.SetClassification((liblas::int8_t)pPoints->Get_Value(i, i_c)); if( i_u > -1 ) point.SetUserData((liblas::int8_t)pPoints->Get_Value(i, i_u)); if( i_R > -1 && i_G > -1 && i_B > -1 ) { liblas::LASColor color; color.SetRed((liblas::uint16_t)pPoints->Get_Value(i, i_R)); color.SetGreen((liblas::uint16_t)pPoints->Get_Value(i, i_G)); color.SetBlue((liblas::uint16_t)pPoints->Get_Value(i, i_B)); point.SetColor(color); } else if( i_RGB > -1 ) { liblas::LASColor color; color.SetRed((liblas::uint16_t)SG_GET_R((int)pPoints->Get_Value(i, i_RGB))); color.SetGreen((liblas::uint16_t)SG_GET_G((int)pPoints->Get_Value(i, i_RGB))); color.SetBlue((liblas::uint16_t)SG_GET_B((int)pPoints->Get_Value(i, i_RGB))); point.SetColor(color); } if( i_e > -1 ) point.SetFlightLineEdge((liblas::uint16_t)pPoints->Get_Value(i, i_e)); if( i_d > -1 ) point.SetScanDirection((liblas::uint16_t)pPoints->Get_Value(i, i_d)); if( i_p > -1 ) point.SetPointSourceID((liblas::uint16_t)pPoints->Get_Value(i, i_p)); if( writer.WritePoint(point) ) cntWrite++; } header.SetMin(xmin, ymin, zmin); header.SetMax(xmax, ymax, zmax); SG_UI_Msg_Add(_TL("Summary:\n"), true); if( i_r > -1 ) { SG_UI_Msg_Add(_TL("Number of points per return:"), true); for( int i=0; iGet_Identifier(), SG_T("POINTS"))) // set attribute field choices to - NOT SET - { if (pParameters->Get_Parameter("POINTS")->asPointCloud() != NULL) { int cntFields = pParameters->Get_Parameter("POINTS")->asPointCloud()->Get_Field_Count(); pParameters->Get_Parameter("T")->Set_Value(cntFields); pParameters->Get_Parameter("i")->Set_Value(cntFields); pParameters->Get_Parameter("a")->Set_Value(cntFields); pParameters->Get_Parameter("r")->Set_Value(cntFields); pParameters->Get_Parameter("n")->Set_Value(cntFields); pParameters->Get_Parameter("c")->Set_Value(cntFields); pParameters->Get_Parameter("u")->Set_Value(cntFields); pParameters->Get_Parameter("R")->Set_Value(cntFields); pParameters->Get_Parameter("G")->Set_Value(cntFields); pParameters->Get_Parameter("B")->Set_Value(cntFields); pParameters->Get_Parameter("e")->Set_Value(cntFields); pParameters->Get_Parameter("d")->Set_Value(cntFields); pParameters->Get_Parameter("p")->Set_Value(cntFields); pParameters->Get_Parameter("RGB")->Set_Value(cntFields); } } return (true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_shapes_las/las_import.cpp0000664000175000017500000003440212565125414024133 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_import.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_import.cpp // // // // Copyright (C) 2009 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "las_import.h" #include #include #include #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { VAR_T = 0, // gps-time VAR_i, // intensity VAR_a, // scan angle VAR_r, // number of the return VAR_c, // classification VAR_u, // user data VAR_n, // number of returns of given pulse VAR_R, // red channel color VAR_G, // green channel color VAR_B, // blue channel color VAR_e, // edge of flight line flag VAR_d, // direction of scan flag VAR_p, // point source ID VAR_C, // color VAR_Count }; //--------------------------------------------------------- #define ADD_FIELD(id, var, name, type) if( Parameters(id)->asBool() ) { iField[var] = nFields++; pPoints->Add_Field(name, type); } else { iField[var] = -1; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLAS_Import::CLAS_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import LAS Files")); Set_Author (SG_T("O. Conrad, V. Wichmann (c) 2009")); CSG_String Description(_TW( "This module imports ASPRS LAS files (versions 1.0, 1.1 and 1.2) as Point Clouds " "using the \"libLAS\" library. " "Get more information about this library at " "http://liblas.org\n" "\n" "Besides the x,y,z coordinates, the user can decide upon which attributes " "should be imported from the LAS file.\n\n" "Module development was supported by " "http://Laserdata GmbH, Austria\n" "and " "http://alpS GmbH, Austria\n" "\nliblas version: " )); Description += CSG_String(LIBLAS_RELEASE_NAME); Set_Description (Description); //----------------------------------------------------- // 2. Parameters... Parameters.Add_FilePath( NULL , "FILES" , _TL("Input Files"), _TL(""), _TL("LAS Files (*.las)|*.las|LAS Files (*.LAS)|*.LAS|All Files|*.*"), NULL, false, false, true ); Parameters.Add_PointCloud_List( NULL , "POINTS" , _TL("Point Clouds"), _TL(""), PARAMETER_OUTPUT ); pNode = Parameters.Add_Node( NULL , "NODE_VARS" , _TL("Attributes to import besides x,y,z ..."), _TL("") ); Parameters.Add_Value(pNode, "T", _TL("gps-time") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "i", _TL("intensity") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "a", _TL("scan angle") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "r", _TL("number of the return") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "c", _TL("classification") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "u", _TL("user data") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "n", _TL("number of returns of given pulse"), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "R", _TL("red channel color") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "G", _TL("green channel color") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "B", _TL("blue channel color") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "e", _TL("edge of flight line flag") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "d", _TL("direction of scan flag") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "p", _TL("point source ID") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "C", _TL("rgb color") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value( NULL , "VALID" , _TL("Check Point Validity"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL , "RGB_RANGE", _TL("R,G,B value range"), _TL("Range of R,G,B values in LAS file."), CSG_String::Format(SG_T("%s|%s|"), _TL("16 bit"), _TL("8 bit") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLAS_Import::On_Execute(void) { CSG_Parameter_PointCloud_List *pPointsList; bool bValidity; CSG_Strings Files; int RGBrange; int cntInvalid = 0; bValidity = Parameters("VALID")->asBool(); RGBrange = Parameters("RGB_RANGE")->asInt(); //----------------------------------------------------- if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) ) { return( false ); } //----------------------------------------------------- pPointsList = Parameters("POINTS")->asPointCloudList(); pPointsList ->Del_Items(); for(int i=0; iSet_Name(SG_File_Get_Name(Files[i], false)); nFields = 3; ADD_FIELD("T", VAR_T, _TL("gps-time") , SG_DATATYPE_Double); // SG_DATATYPE_Long ADD_FIELD("i", VAR_i, _TL("intensity") , SG_DATATYPE_Float); // SG_DATATYPE_Word ADD_FIELD("a", VAR_a, _TL("scan angle") , SG_DATATYPE_Float); // SG_DATATYPE_Byte ADD_FIELD("r", VAR_r, _TL("number of the return") , SG_DATATYPE_Int); ADD_FIELD("c", VAR_c, _TL("classification") , SG_DATATYPE_Int); // SG_DATATYPE_Byte ADD_FIELD("u", VAR_u, _TL("user data") , SG_DATATYPE_Double); // SG_DATATYPE_Byte ADD_FIELD("n", VAR_n, _TL("number of returns of given pulse") , SG_DATATYPE_Int); ADD_FIELD("R", VAR_R, _TL("red channel color") , SG_DATATYPE_Int); // SG_DATATYPE_Word ADD_FIELD("G", VAR_G, _TL("green channel color") , SG_DATATYPE_Int); ADD_FIELD("B", VAR_B, _TL("blue channel color") , SG_DATATYPE_Int); ADD_FIELD("e", VAR_e, _TL("edge of flight line flag") , SG_DATATYPE_Char); ADD_FIELD("d", VAR_d, _TL("direction of scan flag") , SG_DATATYPE_Char); ADD_FIELD("p", VAR_p, _TL("point source ID") , SG_DATATYPE_Int); // SG_DATATYPE_Word ADD_FIELD("C", VAR_C, _TL("rgb color") , SG_DATATYPE_Int); //----------------------------------------------------- int iPoint = 0; try { while( reader.ReadNextPoint() ) { if (iPoint % 100000) SG_UI_Process_Set_Progress(iPoint, header.GetPointRecordsCount()); liblas::LASPoint const& point = reader.GetPoint(); if( bValidity ) { if( !point.IsValid() ) { cntInvalid++; continue; } } pPoints->Add_Point(point.GetX(), point.GetY(), point.GetZ()); if( iField[VAR_T] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_T], point.GetTime()); if( iField[VAR_i] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_i], point.GetIntensity()); if( iField[VAR_a] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_a], point.GetScanAngleRank()); if( iField[VAR_r] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_r], point.GetReturnNumber()); if( iField[VAR_c] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_c], point.GetClassification()); if( iField[VAR_u] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_u], point.GetUserData()); if( iField[VAR_n] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_n], point.GetNumberOfReturns()); if( iField[VAR_R] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_R], point.GetColor().GetRed()); if( iField[VAR_G] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_G], point.GetColor().GetGreen()); if( iField[VAR_B] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_B], point.GetColor().GetBlue()); if( iField[VAR_e] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_e], point.GetFlightLineEdge()); if( iField[VAR_d] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_d], point.GetScanDirection()); if( iField[VAR_p] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_p], point.GetPointSourceID()); if( iField[VAR_C] > 0 ) { double r, g, b; r = point.GetColor().GetRed(); g = point.GetColor().GetGreen(); b = point.GetColor().GetBlue(); if (RGBrange == 0) // 16 bit { r = r / 65535 * 255; g = g / 65535 * 255; b = b / 65535 * 255; } pPoints->Set_Value(iPoint, iField[VAR_C], SG_GET_RGB(r, g, b)); } iPoint++; } } catch(std::exception &e) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("LAS reader exception: %s"), e.what())); ifs.close(); return( false ); } catch(...) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unknown LAS reader exception!"))); ifs.close(); return( false ); } ifs.close(); pPointsList->Add_Item(pPoints); DataObject_Add(pPoints); //----------------------------------------------------- CSG_Parameters sParms; DataObject_Get_Parameters(pPoints, sParms); if (sParms("METRIC_ATTRIB") && sParms("COLORS_TYPE") && sParms("METRIC_COLORS") && sParms("METRIC_ZRANGE") && sParms("DISPLAY_VALUE_AGGREGATE")) { sParms("DISPLAY_VALUE_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("METRIC_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); SG_UI_Msg_Add(_TL("okay"), false); } //----------------------------------------------------- if( bValidity && cntInvalid > 0 ) SG_UI_Msg_Add(CSG_String::Format(_TL("WARNING: %d invalid points skipped!"), cntInvalid), true); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_shapes_las/Makefile.in0000664000175000017500000005573112622651167023336 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/io_shapes_las DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) @HAVE_LLAS_TRUE@libio_shapes_las_la_DEPENDENCIES = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am__libio_shapes_las_la_SOURCES_DIST = las_export.cpp las_import.cpp \ las_info.cpp MLB_Interface.cpp las_export.h las_import.h \ las_info.h MLB_Interface.h @HAVE_LLAS_TRUE@am_libio_shapes_las_la_OBJECTS = las_export.lo \ @HAVE_LLAS_TRUE@ las_import.lo las_info.lo MLB_Interface.lo libio_shapes_las_la_OBJECTS = $(am_libio_shapes_las_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = @HAVE_LLAS_TRUE@am_libio_shapes_las_la_rpath = -rpath $(pkglibdir) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_shapes_las_la_SOURCES) DIST_SOURCES = $(am__libio_shapes_las_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @SAGA_UNICODE_TRUE@UC_DEFS = -D_SAGA_UNICODE @HAVE_LLAS_TRUE@DEP_LIBS = -llas @HAVE_LLAS_TRUE@DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD @HAVE_LLAS_TRUE@CXX_INCS = -I$(top_srcdir)/src/saga_core @HAVE_LLAS_TRUE@AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS) $(GOMPFLAGS) @HAVE_LLAS_TRUE@AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) @HAVE_LLAS_TRUE@pkglib_LTLIBRARIES = libio_shapes_las.la @HAVE_LLAS_TRUE@libio_shapes_las_la_SOURCES = \ @HAVE_LLAS_TRUE@las_export.cpp\ @HAVE_LLAS_TRUE@las_import.cpp\ @HAVE_LLAS_TRUE@las_info.cpp\ @HAVE_LLAS_TRUE@MLB_Interface.cpp\ @HAVE_LLAS_TRUE@las_export.h\ @HAVE_LLAS_TRUE@las_import.h\ @HAVE_LLAS_TRUE@las_info.h\ @HAVE_LLAS_TRUE@MLB_Interface.h @HAVE_LLAS_TRUE@libio_shapes_las_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) --foreign src/modules/io/io_shapes_las/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_shapes_las/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_shapes_las.la: $(libio_shapes_las_la_OBJECTS) $(libio_shapes_las_la_DEPENDENCIES) $(EXTRA_libio_shapes_las_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) $(am_libio_shapes_las_la_rpath) $(libio_shapes_las_la_OBJECTS) $(libio_shapes_las_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/las_export.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/las_import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/las_info.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/io/io_shapes_las/las_info.cpp0000664000175000017500000005447612565125414023571 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_info.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_info.cpp // // // // Copyright (C) 2010 by // // Volker Wichmann // // // // Implementation builds upon the lasinfo tool of // // Martin Isenburg (isenburg@cs.unc.edu) // // Copyright (C) 2007 // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "las_info.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLAS_Info::CLAS_Info(void) { Set_Name (_TL("LAS Info")); Set_Author (SG_T("Volker Wichmann (c) 2010, LASERDATA GmbH")); CSG_String Description(_TW( "Prints information on ASPRS LAS files (versions 1.0, 1.1 and 1.2) " "using the \"libLAS\" library. " "Get more information about this library at " "http://liblas.org\n" "Implementation of this module builds upon the lasinfo tool of " "Martin Isenburg.\n" "\n" "\nliblas version: " )); Description += CSG_String(LIBLAS_RELEASE_NAME); Set_Description (Description); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILE" , _TL("LAS File"), _TL(""), _TL("LAS Files (*.las)|*.las|All Files|*.*") ); Parameters.Add_Value( NULL , "HEADER" , _TL("Only Header Info"), _TL("Print only information available in LAS header."), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLAS_Info::On_Execute(void) { CSG_String fName; bool bHeader; std::ifstream ifs; LASPointSummary summary; //----------------------------------------------------- fName = Parameters("FILE")->asString(); bHeader = Parameters("HEADER")->asBool(); //----------------------------------------------------- ifs.open(fName.b_str(), std::ios::in | std::ios::binary); if (!ifs) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unable to open LAS file!"))); return (false); } //----------------------------------------------------- // Check if LAS version is supported liblas::LASReader *pReader; try { pReader = new liblas::LASReader(ifs); } catch(std::exception &e) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("LAS header exception: %s"), e.what())); ifs.close(); return (false); } catch(...) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unknown LAS header exception!"))); ifs.close(); return (false); } delete (pReader); ifs.clear(); //----------------------------------------------------- liblas::LASReader reader(ifs); liblas::LASHeader const& header = reader.GetHeader(); //----------------------------------------------------- Print_Header(fName, header); if( !bHeader ) { LASPointSummary *pSummary; pSummary = (LASPointSummary*) malloc(sizeof(LASPointSummary)); if( !Summarize_Points(&reader, pSummary, header.GetPointRecordsCount()) ) return (false); if( !Print_Point_Summary(header, pSummary) ) return (false); free (pSummary); } //----------------------------------------------------- ifs.close(); return( true ); } //--------------------------------------------------------- bool CLAS_Info::Print_Header(CSG_String fName, liblas::LASHeader header) { SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); SG_UI_Msg_Add(_TL(" Header Summary"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" File Name:\t\t\t%s"), fName.c_str()), true); if (SG_STR_CMP(header.GetFileSignature().c_str(), SG_T("LASF"))) { SG_UI_Msg_Add_Error(_TL("File signature is not 'LASF'!")); return (false); } SG_UI_Msg_Add(CSG_String::Format(_TL(" Version:\t\t\t%d.%d"), header.GetVersionMajor(), header.GetVersionMinor()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Source ID:\t\t\t%d"), header.GetFileSourceId()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Reserved:\t\t\t%d"), header.GetReserved()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Project ID/GUID:\t\t'%s'"), CSG_String(header.GetProjectId().to_string().c_str()).w_str()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" System Identifier:\t\t'%s'"), CSG_String(header.GetSystemId().c_str()).w_str()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Generating Software:\t\t'%s'"), CSG_String(header.GetSoftwareId().c_str()).w_str()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" File Creation Day/Year:\t\t%d/%d"), header.GetCreationDOY(), header.GetCreationYear()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Header Size:\t\t\t%d"), header.GetHeaderSize()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Offset to Point Data:\t\t%d"), header.GetDataOffset()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Number Var. Length Records:\t%d"), header.GetRecordsCount()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Point Data Format:\t\t%d"), header.GetDataFormatId()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Point Data Record Length:\t%d"), header.GetDataRecordLength()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Number of Point Records:\t%d"), header.GetPointRecordsCount()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Number of Points by Return:\t%d %d %d %d %d"), header.GetPointRecordsByReturnCount().at(0), header.GetPointRecordsByReturnCount().at(1), header.GetPointRecordsByReturnCount().at(2), header.GetPointRecordsByReturnCount().at(3), header.GetPointRecordsByReturnCount().at(4)), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Scale Factor X Y Z:\t\t%.6g %.6g %.6g"), header.GetScaleX(), header.GetScaleY(), header.GetScaleZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Offset X Y Z:\t\t\t%.6f %.6f %.6f"), header.GetOffsetX(), header.GetOffsetY(), header.GetOffsetZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Min X Y Z:\t\t\t%.6f %.6f %.6f"), header.GetMinX(), header.GetMinY(), header.GetMinZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Max X Y Z:\t\t\t%.6f %.6f %.6f"), header.GetMaxX(), header.GetMaxY(), header.GetMaxZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Spatial Reference:\t\t%s"), CSG_String(header.GetSRS().GetProj4().c_str()).w_str()), true); return (true); } //--------------------------------------------------------- bool CLAS_Info::Print_Point_Summary(liblas::LASHeader header, LASPointSummary *pSummary) { long rgpsum = 0; long pbretsum = 0; int i = 0; if( pSummary->number_of_point_records == 0 ) { SG_UI_Msg_Add_Error(_TL("Point summary contains no points!")); return (false); } SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); SG_UI_Msg_Add(_TL(" Point Inspection Summary"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Header Point Count:\t\t%d"), header.GetPointRecordsCount()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Actual Point Count:\t\t%d"), pSummary->number_of_point_records), true); SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL(" Minimum and Maximum Attributes (min, max)"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Min X Y Z:\t\t\t%.6f %.6f %.6f"), pSummary->pmin.GetX(), pSummary->pmin.GetY(), pSummary->pmin.GetZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Max X Y Z:\t\t\t%.6f %.6f %.6f"), pSummary->pmax.GetX(), pSummary->pmax.GetY(), pSummary->pmax.GetZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Bounding Box:\t\t\t%.2f, %.2f, %.2f, %.2f"), pSummary->pmin.GetX(), pSummary->pmin.GetY(), pSummary->pmax.GetX(), pSummary->pmax.GetY()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Time:\t\t\t\t%.6f, %.6f"), pSummary->pmin.GetTime(), pSummary->pmax.GetTime()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Return Number:\t\t%d, %d"), pSummary->pmin.GetReturnNumber(), pSummary->pmax.GetReturnNumber()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Return Count:\t\t\t%d, %d"), pSummary->pmin.GetNumberOfReturns(), pSummary->pmax.GetNumberOfReturns()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Flightline Edge:\t\t\t%d, %d"), pSummary->pmin.GetFlightLineEdge(), pSummary->pmax.GetFlightLineEdge()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Intensity:\t\t\t%d, %d"), pSummary->pmin.GetIntensity(), pSummary->pmax.GetIntensity()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Scan Direction Flag:\t\t%d, %d"), pSummary->pmin.GetScanDirection(), pSummary->pmax.GetScanDirection()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Scan Angle Rank:\t\t%d, %d"), pSummary->pmin.GetScanAngleRank(), pSummary->pmax.GetScanAngleRank()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Classification:\t\t\t%d, %d"), pSummary->pmin.GetClassification(), pSummary->pmax.GetClassification()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Point Source Id:\t\t%d, %d"), pSummary->pmin.GetPointSourceID(), pSummary->pmax.GetPointSourceID()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Minimum Color:\t\t\t%d %d %d"), pSummary->pmin.GetColor().GetRed(), pSummary->pmin.GetColor().GetGreen(), pSummary->pmin.GetColor().GetBlue()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Maximum Color:\t\t%d %d %d"), pSummary->pmax.GetColor().GetRed(), pSummary->pmax.GetColor().GetGreen(), pSummary->pmax.GetColor().GetBlue()), true); SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL(" Number of Points by Return"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); for( i=0; i<5; i++ ) { pbretsum = pbretsum + pSummary->number_of_points_by_return[i]; SG_UI_Msg_Add(CSG_String::Format(SG_T("\t(%d) %d"), i, pSummary->number_of_points_by_return[i]), true); } SG_UI_Msg_Add(CSG_String::Format(_TL(" Total Points:\t%ld"), pbretsum), true); SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL(" Number of Returns by Pulse"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); for( i=0; i<8; i++ ) { rgpsum = rgpsum + pSummary->number_of_returns_of_given_pulse[i]; SG_UI_Msg_Add(CSG_String::Format(SG_T("\t(%d) %d"), i, pSummary->number_of_returns_of_given_pulse[i]), true); } SG_UI_Msg_Add(CSG_String::Format(_TL(" Total Pulses:\t%ld"), rgpsum), true); for( i=0; i<5; i++ ) { if( header.GetPointRecordsByReturnCount().at(i) != pSummary->number_of_points_by_return[i] ) { SG_UI_Msg_Add(CSG_String::Format(_TL(" Actual number of points by return is different from header (actual, header):")), true); for( int j=0; i<5; i++ ) { SG_UI_Msg_Add(CSG_String::Format(SG_T("\t(%d, %d"), pSummary->number_of_points_by_return[j], header.GetPointRecordsByReturnCount().at(j)), true); } } } SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL(" Point Classifications"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); for( i=0; i<32; i++ ) { if( pSummary->classification[i] ) { SG_UI_Msg_Add(CSG_String::Format(SG_T("\t%d\t\t%s (%d)"), pSummary->classification[i], gLASPointClassification_Key_Name[i], i), true); } } if( pSummary->classification_synthetic || pSummary->classification_keypoint || pSummary->classification_withheld ) { SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL(" Point Classification Histogram"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); if( pSummary->classification_synthetic ) SG_UI_Msg_Add(CSG_String::Format(_TL(" +-> flagged as synthetic:\t%d"), pSummary->classification_synthetic), true); if( pSummary->classification_keypoint ) SG_UI_Msg_Add(CSG_String::Format(_TL(" +-> flagged as keypoints:\t%d"), pSummary->classification_keypoint), true); if( pSummary->classification_withheld ) SG_UI_Msg_Add(CSG_String::Format(_TL(" +-> flagged as withheld:\t%d"), pSummary->classification_withheld), true); } return (true); } //--------------------------------------------------------- bool CLAS_Info::Summarize_Points(liblas::LASReader *pReader, LASPointSummary *pSummary, int headerPts) { liblas::LASColor color; liblas::LASColor min_color; liblas::LASColor max_color; liblas::uint8_t cls = 0; liblas::uint16_t red = 0; liblas::uint16_t green = 0; liblas::uint16_t blue = 0; liblas::uint16_t ptsrc = 0; int i = 0; bool bValid = false; pSummary->number_of_point_records = 0; for( i=0; i<8; i++ ) pSummary->number_of_points_by_return[i] = 0; for( i=0; i<8; i++ ) pSummary->number_of_returns_of_given_pulse[i] = 0; for( i=0; i<32; i++ ) pSummary->classification[i] = 0; pSummary->classification_synthetic = 0; pSummary->classification_keypoint = 0; pSummary->classification_withheld = 0; //----------------------------------------------------- if( !pReader->ReadNextPoint() ) { SG_UI_Msg_Add_Error(_TL("Unable to read points from LAS file!")); return (false); } else bValid = true; liblas::LASPoint const& p = pReader->GetPoint(); pSummary->pmin = p; pSummary->pmax = p; i = 1; //----------------------------------------------------- while( bValid ) { SG_UI_Process_Set_Progress(i, headerPts); pSummary->x = p.GetX(); if( pSummary->x < pSummary->pmin.GetX() ) pSummary->pmin.SetX(pSummary->x); if( pSummary->x > pSummary->pmax.GetX() ) pSummary->pmax.SetX(pSummary->x); pSummary->y = p.GetY(); if( pSummary->y < pSummary->pmin.GetY() ) pSummary->pmin.SetY(pSummary->y); if( pSummary->y > pSummary->pmax.GetY() ) pSummary->pmax.SetY(pSummary->y); pSummary->z = p.GetZ(); if( pSummary->z < pSummary->pmin.GetZ() ) pSummary->pmin.SetZ(pSummary->z); if( pSummary->z > pSummary->pmax.GetZ() ) pSummary->pmax.SetZ(pSummary->z); pSummary->intensity = p.GetIntensity(); if( pSummary->intensity < pSummary->pmin.GetIntensity() ) pSummary->pmin.SetIntensity(pSummary->intensity); if( pSummary->intensity > pSummary->pmax.GetIntensity() ) pSummary->pmax.SetIntensity(pSummary->intensity); pSummary->t = p.GetTime(); if( pSummary->t < pSummary->pmin.GetTime() ) pSummary->pmin.SetTime(pSummary->t); if( pSummary->t > pSummary->pmax.GetTime() ) pSummary->pmax.SetTime(pSummary->t); pSummary->retnum = p.GetReturnNumber(); if( pSummary->retnum < pSummary->pmin.GetReturnNumber() ) pSummary->pmin.SetReturnNumber(pSummary->retnum); if( pSummary->retnum > pSummary->pmax.GetReturnNumber() ) pSummary->pmax.SetReturnNumber(pSummary->retnum); pSummary->numret = p.GetNumberOfReturns(); if( pSummary->numret < pSummary->pmin.GetNumberOfReturns() )pSummary->pmin.SetNumberOfReturns(pSummary->numret); if( pSummary->numret > pSummary->pmax.GetNumberOfReturns() )pSummary->pmax.SetNumberOfReturns(pSummary->numret); pSummary->scandir = p.GetScanDirection(); if( pSummary->scandir < pSummary->pmin.GetScanDirection() ) pSummary->pmin.SetScanDirection(pSummary->scandir); if( pSummary->scandir > pSummary->pmax.GetScanDirection() ) pSummary->pmax.SetScanDirection(pSummary->scandir); pSummary->fedge = p.GetFlightLineEdge(); if( pSummary->fedge < pSummary->pmin.GetFlightLineEdge() ) pSummary->pmin.SetFlightLineEdge(pSummary->fedge); if( pSummary->fedge > pSummary->pmax.GetFlightLineEdge() ) pSummary->pmax.SetFlightLineEdge(pSummary->fedge); pSummary->scan_angle = p.GetScanAngleRank(); if( pSummary->scan_angle < pSummary->pmin.GetScanAngleRank() ) pSummary->pmin.SetScanAngleRank(pSummary->scan_angle); if( pSummary->scan_angle > pSummary->pmax.GetScanAngleRank() ) pSummary->pmax.SetScanAngleRank(pSummary->scan_angle); pSummary->user_data = p.GetUserData(); if( pSummary->user_data < pSummary->pmin.GetUserData() ) pSummary->pmin.SetUserData(pSummary->user_data); if( pSummary->user_data > pSummary->pmax.GetUserData() ) pSummary->pmax.SetUserData(pSummary->user_data); pSummary->number_of_point_records = i; if( p.GetReturnNumber() ) pSummary->number_of_points_by_return[p.GetReturnNumber() - 1]++; else pSummary->number_of_points_by_return[p.GetReturnNumber()]++; pSummary->number_of_returns_of_given_pulse[p.GetNumberOfReturns()]++; cls = p.GetClassification(); if( cls < pSummary->pmin.GetClassification() ) pSummary->pmin.SetClassification(cls); if( cls > pSummary->pmax.GetClassification() ) pSummary->pmax.SetClassification(cls); ptsrc = p.GetPointSourceID(); if( ptsrc < pSummary->pmin.GetPointSourceID() ) pSummary->pmin.SetPointSourceID(ptsrc); if( ptsrc > pSummary->pmax.GetPointSourceID() ) pSummary->pmax.SetPointSourceID(ptsrc); color = p.GetColor(); min_color = pSummary->pmin.GetColor(); max_color = pSummary->pmax.GetColor(); min_color.GetRed() < color.GetRed() ? red = min_color.GetRed() : red = color.GetRed(); min_color.GetGreen() < color.GetGreen() ? green = min_color.GetGreen() : green = color.GetGreen(); min_color.GetBlue() < color.GetBlue() ? blue = min_color.GetBlue() : blue = color.GetBlue(); min_color.SetRed(red); min_color.SetGreen(green); min_color.SetBlue(blue); pSummary->pmin.SetColor(min_color); max_color.GetRed() > color.GetRed() ? red = max_color.GetRed() : red = color.GetRed(); max_color.GetGreen() > color.GetGreen() ? green = max_color.GetGreen() : green = color.GetGreen(); max_color.GetBlue() > color.GetBlue() ? blue = max_color.GetBlue() : blue = color.GetBlue(); max_color.SetRed(red); max_color.SetGreen(green); max_color.SetBlue(blue); pSummary->pmax.SetColor(max_color); pSummary->classification[cls & 31]++; if( cls & 32 ) pSummary->classification_synthetic++; if( cls & 64 ) pSummary->classification_keypoint++; if( cls & 128 ) pSummary->classification_withheld++; if( !pReader->ReadNextPoint() ) bValid = false; else { bValid = true; liblas::LASPoint const& p = pReader->GetPoint(); i++; } } return (true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_shapes_las/las_import.h0000664000175000017500000001036212565125414023577 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_import.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_import.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__las_import_H #define HEADER_INCLUDED__las_import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLAS_Import : public CSG_Module { public: CLAS_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__las_import_H saga-2.2.3/src/modules/io/io_shapes_las/MLB_Interface.cpp0000664000175000017500000001116312565125414024353 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("LAS") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Wichmann (c) 2009-10") ); case MLB_INFO_Description: return( _TL("Tools for the import and export of ASPRS LAS files.") ); 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 "las_export.h" #include "las_import.h" #include "las_info.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CLAS_Export ); case 1: return( new CLAS_Import ); case 2: return( new CLAS_Info ); default: return( NULL ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/io/io_shapes_las/Makefile.am0000664000175000017500000000135112565125414023307 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif if SAGA_UNICODE UC_DEFS = -D_SAGA_UNICODE endif if HAVE_LLAS DEP_LIBS = -llas 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) pkglib_LTLIBRARIES = libio_shapes_las.la libio_shapes_las_la_SOURCES =\ las_export.cpp\ las_import.cpp\ las_info.cpp\ MLB_Interface.cpp\ las_export.h\ las_import.h\ las_info.h\ MLB_Interface.h libio_shapes_las_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) endif saga-2.2.3/src/modules/io/io_shapes_las/MLB_Interface.h0000664000175000017500000000754112565125414024025 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // MLB_Interface.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_shapes_las_H #define HEADER_INCLUDED__io_shapes_las_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_shapes_las_EXPORTS #define io_shapes_las_EXPORT _SAGA_DLL_EXPORT #else #define io_shapes_las_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_shapes_las_H saga-2.2.3/src/modules/io/io_shapes_las/las_info.h0000664000175000017500000001541112565125414023220 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_info.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_info.h // // // // Copyright (C) 2010 by // // Volker Wichmann // // // // Implementation builds upon the lasinfo tool of // // Martin Isenburg (isenburg@cs.unc.edu) // // Copyright (C) 2007 // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__las_info_H #define HEADER_INCLUDED__las_info_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include #include #include #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// const SG_Char gLASPointClassification_Key_Name[32][32] = { SG_T("Created, never classified"), SG_T("Unclassified"), SG_T("Ground"), SG_T("Low Vegetation"), SG_T("Medium Vegetation"), SG_T("High Vegetation"), SG_T("Building"), SG_T("Low Point (noise)"), SG_T("Model Key-point (mass point)"), SG_T("Water"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Overlap Points"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition") }; typedef struct { double t; double x, y, z; liblas::uint16_t intensity; liblas::uint8_t cls; liblas::int8_t scan_angle; liblas::uint8_t user_data; liblas::uint16_t retnum; liblas::uint16_t numret; liblas::uint16_t scandir; liblas::uint16_t fedge; liblas::uint16_t red; liblas::uint16_t green; liblas::uint16_t blue; long rgpsum; int number_of_point_records; int number_of_points_by_return[8]; int number_of_returns_of_given_pulse[8]; int classification[32]; int classification_synthetic; int classification_keypoint; int classification_withheld; liblas::LASPoint pmax; liblas::LASPoint pmin; } LASPointSummary; //--------------------------------------------------------- class CLAS_Info : public CSG_Module { public: CLAS_Info(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); bool Print_Header (CSG_String fName, liblas::LASHeader header); bool Print_Point_Summary (liblas::LASHeader header, LASPointSummary *pSummary); bool Summarize_Points (liblas::LASReader *pReader, LASPointSummary *pSummary, int headerPts); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__las_info_H saga-2.2.3/src/modules/io/io_shapes_las/las_export.h0000664000175000017500000001061512565125414023607 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_export.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_export.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__las_export_H #define HEADER_INCLUDED__las_export_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLAS_Export : public CSG_Module { public: CLAS_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Export") ); } protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__las_export_H saga-2.2.3/src/modules/io/io_grid/0000775000175000017500000000000012634325743020062 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_grid/bmp_export.h0000664000175000017500000001104612565125414022410 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: bmp_export.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for an Automated Geo-Scientific Analysis // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // bmp_export.h // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for an Automated // // Geo-Scientific Analysis'. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__bmp_export_H #define HEADER_INCLUDED__bmp_export_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CBMP_Export : public CSG_Module_Grid { public: CBMP_Export(void); virtual ~CBMP_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Export") ); } protected: virtual bool On_Execute (void); private: void Write_WORD (FILE *Stream, WORD Value); void Write_DWORD (FILE *Stream, DWORD Value); void Write_LONG (FILE *Stream, long Value); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__bmp_export_H saga-2.2.3/src/modules/io/io_grid/surfer.h0000664000175000017500000001013512565125414021535 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: surfer.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Surfer.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Surfer.h // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Surfer_H #define HEADER_INCLUDED__Surfer_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CSurfer_Import : public CSG_Module { public: CSurfer_Import(void); virtual ~CSurfer_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute(void); private: }; //--------------------------------------------------------- class CSurfer_Export : public CSG_Module_Grid { public: CSurfer_Export(void); virtual ~CSurfer_Export(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Export") ); } protected: virtual bool On_Execute(void); private: }; #endif // #ifndef HEADER_INCLUDED__Surfer_H saga-2.2.3/src/modules/io/io_grid/grid_table.h0000664000175000017500000001106112565125414022322 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_table.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Grid_Table.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Table_H #define HEADER_INCLUDED__Grid_Table_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Table_Import : public CSG_Module { public: CGrid_Table_Import(void); virtual ~CGrid_Table_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Table_H saga-2.2.3/src/modules/io/io_grid/surfer.cpp0000664000175000017500000003220612565125414022073 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: surfer.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Surfer.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "surfer.h" //--------------------------------------------------------- #define NODATAVALUE 1.70141e38f /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSurfer_Import::CSurfer_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name(_TL("Import Surfer Grid")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (_TW( "Import grid from Golden Software's Surfer grid format.\n") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("Surfer Grid (*.grd)|*.grd|All Files|*.*") ); pNode = Parameters.Add_Choice( NULL , "NODATA" , _TL("No Data Value"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Surfer's No Data Value"), _TL("User Defined") ), 0 ); Parameters.Add_Value( pNode , "NODATA_VAL" , _TL("User Defined No Data Value"), _TL(""), PARAMETER_TYPE_Double , -99999.0 ); } //--------------------------------------------------------- CSurfer_Import::~CSurfer_Import(void) {} //--------------------------------------------------------- bool CSurfer_Import::On_Execute(void) { int x, y, NX, NY; short sValue; long lValue; float *fLine; double *dLine, dValue, DX, DY, xMin, yMin; FILE *Stream; CSG_String fName; CSG_Grid *pGrid; //----------------------------------------------------- pGrid = NULL; fName = Parameters("FILE")->asString(); //----------------------------------------------------- if( fName.Length() > 0 && (Stream = fopen(fName.b_str(), "rb")) != NULL ) { fread(&lValue, 1, sizeof(long), Stream); //------------------------------------------------- // Surfer 7: Binary... if( !strncmp((char *)&lValue, "DSRB", 4) ) { fread(&lValue, 1, sizeof(long) , Stream); // SectionSize... fread(&lValue, 1, sizeof(long) , Stream); // Version fread(&lValue, 1, sizeof(long) , Stream); if( lValue == 0x44495247 ) // Grid-Header... { fread(&lValue , 1, sizeof(long) , Stream); // SectionSize... fread(&lValue , 1, sizeof(long) , Stream); // NX... NY = (int)lValue; fread(&lValue , 1, sizeof(long) , Stream); // NY... NX = (int)lValue; fread(&xMin , 1, sizeof(double) , Stream); // xMin... fread(&yMin , 1, sizeof(double) , Stream); // yMin... fread(&DX , 1, sizeof(double) , Stream); // DX... fread(&DY , 1, sizeof(double) , Stream); // DY... fread(&dValue , 1, sizeof(double) , Stream); // zMin... fread(&dValue , 1, sizeof(double) , Stream); // zMax... fread(&dValue , 1, sizeof(double) , Stream); // Rotation (unused)... fread(&dValue , 1, sizeof(double) , Stream); // Blank Value... fread(&lValue , 1, sizeof(long) , Stream); // ???... if( lValue == 0x41544144 ) // Load Binary Double... { fread(&lValue, 1, sizeof(long) , Stream); // SectionSize... //------------------------------------- if( !feof(Stream) && (pGrid = SG_Create_Grid(SG_DATATYPE_Double, NX, NY, DX, xMin, yMin)) != NULL ) { dLine = (double *)SG_Malloc(pGrid->Get_NX() * sizeof(double)); for(y=0; yGet_NY() && !feof(Stream) && Set_Progress(y, pGrid->Get_NY()); y++) { fread(dLine, pGrid->Get_NX(), sizeof(double), Stream); for(x=0; xGet_NX(); x++) { pGrid->Set_Value(x, y, dLine[x]); } } SG_Free(dLine); } } } } //------------------------------------------------- // Surfer 6: Binary... else if( !strncmp((char *)&lValue, "DSBB", 4) ) { fread(&sValue , 1, sizeof(short) , Stream); NX = sValue; fread(&sValue , 1, sizeof(short) , Stream); NY = sValue; fread(&xMin , 1, sizeof(double) , Stream); fread(&dValue , 1, sizeof(double) , Stream); // XMax DX = (dValue - xMin) / (NX - 1.0); fread(&yMin , 1, sizeof(double) , Stream); fread(&dValue , 1, sizeof(double) , Stream); // YMax... DY = (dValue - yMin) / (NY - 1.0); fread(&dValue , 1, sizeof(double) , Stream); // ZMin... fread(&dValue , 1, sizeof(double) , Stream); // ZMax... //--------------------------------------------- if( !feof(Stream) && (pGrid = SG_Create_Grid(SG_DATATYPE_Float, NX, NY, DX, xMin, yMin)) != NULL ) { fLine = (float *)SG_Malloc(pGrid->Get_NX() * sizeof(float)); for(y=0; yGet_NY() && !feof(Stream) && Set_Progress(y, pGrid->Get_NY()); y++) { fread(fLine, pGrid->Get_NX(), sizeof(float), Stream); for(x=0; xGet_NX(); x++) { pGrid->Set_Value(x, y, fLine[x]); } } SG_Free(fLine); } } //------------------------------------------------- // Surfer 6: ASCII... else if( !strncmp((char *)&lValue, "DSAA", 4) ) { fscanf(Stream, "%d %d" , &NX , &NY); fscanf(Stream, "%lf %lf", &xMin , &dValue); DX = (dValue - xMin) / (NX - 1.0); fscanf(Stream, "%lf %lf", &yMin , &dValue); DY = (dValue - yMin) / (NY - 1.0); fscanf(Stream, "%lf %lf", &dValue, &dValue); //--------------------------------------------- if( !feof(Stream) && (pGrid = SG_Create_Grid(SG_DATATYPE_Float, NX, NY, DX, xMin, yMin)) != NULL ) { for(y=0; yGet_NY() && !feof(Stream) && Set_Progress(y, pGrid->Get_NY()); y++) { for(x=0; xGet_NX(); x++) { fscanf(Stream, "%lf", &dValue); pGrid->Set_Value(x, y, dValue); } } } } fclose(Stream); } //----------------------------------------------------- if( pGrid ) { pGrid->Set_Name(Parameters("FILE")->asString()); pGrid->Set_NoData_Value(Parameters("NODATA")->asInt() == 0 ? NODATAVALUE : Parameters("NODATA_VAL")->asDouble()); Parameters("GRID")->Set_Value(pGrid); } return( pGrid != NULL ); } /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSurfer_Export::CSurfer_Export(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("Export Surfer Grid")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (_TW( "Export grid to Golden Software's Surfer grid format.\n") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL( "Surfer Grid (*.grd)|*.grd|All Files|*.*"), NULL, true ); Parameters.Add_Choice( NULL , "FORMAT" , _TL("Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("binary"), _TL("ASCII") ), 0 ); Parameters.Add_Value( NULL , "NODATA" , _TL("Use Surfer's No-Data Value"), _TL(""), PARAMETER_TYPE_Bool , false ); } //--------------------------------------------------------- CSurfer_Export::~CSurfer_Export(void) {} //--------------------------------------------------------- bool CSurfer_Export::On_Execute(void) { const char ID_BINARY[] = "DSBB"; bool bNoData; short sValue; int x, y; float *fLine; double dValue; FILE *Stream; CSG_String fName; CSG_Grid *pGrid; //----------------------------------------------------- pGrid = Parameters("GRID") ->asGrid(); fName = Parameters("FILE") ->asString(); bNoData = Parameters("NODATA") ->asBool(); switch( Parameters("FORMAT")->asInt() ) { //----------------------------------------------------- case 0: // Surfer 6 - Binary... if( (Stream = fopen(fName.b_str(), "wb")) != NULL ) { fwrite(ID_BINARY, 4, sizeof(char ), Stream); sValue = (short)pGrid->Get_NX(); fwrite(&sValue , 1, sizeof(short ), Stream); sValue = (short)pGrid->Get_NY(); fwrite(&sValue , 1, sizeof(short ), Stream); dValue = pGrid->Get_XMin(); fwrite(&dValue , 1, sizeof(double), Stream); dValue = pGrid->Get_XMax(); fwrite(&dValue , 1, sizeof(double), Stream); dValue = pGrid->Get_YMin(); fwrite(&dValue , 1, sizeof(double), Stream); dValue = pGrid->Get_YMax(); fwrite(&dValue , 1, sizeof(double), Stream); dValue = pGrid->Get_ZMin(); fwrite(&dValue , 1, sizeof(double), Stream); dValue = pGrid->Get_ZMax(); fwrite(&dValue , 1, sizeof(double), Stream); //--------------------------------------------- fLine = (float *)SG_Malloc(pGrid->Get_NX() * sizeof(float)); for(y=0; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++) { for(x=0; xGet_NX(); x++) { fLine[x] = bNoData && pGrid->is_NoData(x, y) ? NODATAVALUE : pGrid->asFloat(x, y); } fwrite(fLine, pGrid->Get_NX(), sizeof(float), Stream); } SG_Free(fLine); fclose(Stream); return( true ); } break; //----------------------------------------------------- case 1: // Surfer - ASCII... if( (Stream = fopen(fName.b_str(), "w")) != NULL ) { fprintf(Stream, "DSAA\n" ); fprintf(Stream, "%d %d\n", pGrid->Get_NX() , pGrid->Get_NY() ); fprintf(Stream, "%f %f\n", pGrid->Get_XMin(), pGrid->Get_XMax() ); fprintf(Stream, "%f %f\n", pGrid->Get_YMin(), pGrid->Get_YMax() ); fprintf(Stream, "%f %f\n", pGrid->Get_ZMin(), pGrid->Get_ZMax() ); //--------------------------------------------- for(y=0; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++) { for(x=0; xGet_NX(); x++) { if( bNoData && pGrid->is_NoData(x, y) ) { fprintf(Stream, "1.70141e38 "); } else { fprintf(Stream, "%f ", pGrid->asFloat(x, y)); } } fprintf(Stream, "\n"); } fclose(Stream); return( true ); } break; } //----------------------------------------------------- return( false ); } saga-2.2.3/src/modules/io/io_grid/raw.cpp0000664000175000017500000002662412565125414021365 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: raw.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Raw.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "raw.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CRaw_Import::CRaw_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("Import Binary Raw Data")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Imports grid from binary raw data.\n") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE_DATA" , _TL("Raw Data File"), _TL("") ); //----------------------------------------------------- Parameters.Add_Value( NULL , "NX" , _TL("Cell Count (X)"), _TL(""), PARAMETER_TYPE_Int , 1 ); Parameters.Add_Value( NULL , "NY" , _TL("Cell Count (Y)"), _TL(""), PARAMETER_TYPE_Int , 1 ); Parameters.Add_Value( NULL , "DXY" , _TL("Cell Size"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "XMIN" , _TL("Left Border (X)"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( NULL , "YMIN" , _TL("Lower Border (Y)"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_String( NULL , "UNIT" , _TL("Unit Name"), _TL(""), _TL("") ); Parameters.Add_Value( NULL , "ZFACTOR" , _TL("Z Multiplier"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "NODATA" , _TL("No Data Value"), _TL(""), PARAMETER_TYPE_Double , -99999.0 ); Parameters.Add_Value( NULL , "DATA_OFFSET" , _TL("Data Offset (Bytes)"), _TL(""), PARAMETER_TYPE_Int , 0.0 ); Parameters.Add_Value( NULL , "LINE_OFFSET" , _TL("Line Offset (Bytes)"), _TL(""), PARAMETER_TYPE_Int , 0.0 ); Parameters.Add_Value( NULL , "LINE_ENDSET" , _TL("Line Endset (Bytes)"), _TL(""), PARAMETER_TYPE_Int , 0.0 ); Parameters.Add_Choice( NULL , "DATA_TYPE" , _TL("Data Type"), _TL(""), _TW( "1 Byte Integer (unsigned)|" "1 Byte Integer (signed)|" "2 Byte Integer (unsigned)|" "2 Byte Integer (signed)|" "4 Byte Integer (unsigned)|" "4 Byte Integer (signed)|" "4 Byte Floating Point|" "8 Byte Floating Point|" ) ); Parameters.Add_Choice( NULL , "BYTEORDER_BIG" , _TL("Byte Order"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Little Endian (Intel)"), _TL("Big Endian (Motorola)") ), 0 ); Parameters.Add_Choice( NULL , "TOPDOWN" , _TL("Line Order"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Bottom to Top"), _TL("Top to Bottom") ), 0 ); } //--------------------------------------------------------- CRaw_Import::~CRaw_Import(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CRaw_Import::On_Execute(void) { bool bDown, bBig; int nx, ny, data_head, line_head, line_tail; double dxy, xmin, ymin, zFactor, zNoData; FILE *Stream; TSG_Data_Type data_type; CSG_String FileName, Unit; CSG_Grid *pGrid; //----------------------------------------------------- pGrid = NULL; FileName = Parameters("FILE_DATA") ->asString(); nx = Parameters("NX") ->asInt(); ny = Parameters("NY") ->asInt(); dxy = Parameters("DXY") ->asDouble(); xmin = Parameters("XMIN") ->asDouble(); ymin = Parameters("YMIN") ->asDouble(); data_head = Parameters("DATA_OFFSET") ->asInt(); line_head = Parameters("LINE_OFFSET") ->asInt(); line_tail = Parameters("LINE_ENDSET") ->asInt(); bDown = Parameters("TOPDOWN") ->asInt() == 1; bBig = Parameters("BYTEORDER_BIG") ->asInt() == 1; Unit = Parameters("UNIT") ->asString(); zFactor = Parameters("ZFACTOR") ->asDouble(); zNoData = Parameters("NODATA") ->asDouble(); switch( Parameters("DATA_TYPE")->asInt() ) { default: data_type = SG_DATATYPE_Undefined; break; // not handled case 0: data_type = SG_DATATYPE_Byte; break; // 1 Byte Integer (unsigned) case 1: data_type = SG_DATATYPE_Char; break; // 1 Byte Integer (signed) case 2: data_type = SG_DATATYPE_Word; break; // 2 Byte Integer (unsigned) case 3: data_type = SG_DATATYPE_Short; break; // 2 Byte Integer (signed) case 4: data_type = SG_DATATYPE_DWord; break; // 4 Byte Integer (unsigned) case 5: data_type = SG_DATATYPE_Int; break; // 4 Byte Integer (signed) case 6: data_type = SG_DATATYPE_Float; break; // 4 Byte Floating Point case 7: data_type = SG_DATATYPE_Double; break; // 8 Byte Floating Point } //----------------------------------------------------- if( data_type != SG_DATATYPE_Undefined && (Stream = fopen(FileName.b_str(), "rb")) != NULL ) { if( (pGrid = Load_Data(Stream, data_type, nx, ny, dxy, xmin, ymin, data_head, line_head, line_tail, bDown, bBig)) != NULL ) { pGrid->Set_Unit (Unit); pGrid->Set_Scaling (zFactor); pGrid->Set_NoData_Value (zNoData); pGrid->Set_Name (SG_File_Get_Name(FileName, false)); Parameters("GRID")->Set_Value(pGrid); } fclose(Stream); } //----------------------------------------------------- return( pGrid != NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Grid * CRaw_Import::Load_Data(FILE *Stream, TSG_Data_Type data_type, int nx, int ny, double dxy, double xmin, double ymin, int data_head, int line_head, int line_tail, bool bDown, bool bBig) { char *pLine, *pValue; int x, y, nBytes_Value, nBytes_Line; CSG_Grid *pGrid = NULL; //----------------------------------------------------- if( Stream && data_type != SG_DATATYPE_Undefined ) { for(x=0; xGet_NY() && !feof(Stream) && Set_Progress(y, pGrid->Get_NY()); y++) { for(x=0; xGet_NX(); x++, pValue+=nBytes_Value) { if( bBig ) { SG_Swap_Bytes(pValue, nBytes_Value); } switch( data_type ) { case SG_DATATYPE_Byte: pGrid->Set_Value(x, y, *(unsigned char *)pValue); break; // 1 Byte Integer (unsigned) case SG_DATATYPE_Char: pGrid->Set_Value(x, y, *(signed char *)pValue); break; // 1 Byte Integer (signed) case SG_DATATYPE_Word: pGrid->Set_Value(x, y, *(unsigned short *)pValue); break; // 2 Byte Integer (unsigned) case SG_DATATYPE_Short: pGrid->Set_Value(x, y, *(signed short *)pValue); break; // 2 Byte Integer (signed) case SG_DATATYPE_DWord: pGrid->Set_Value(x, y, *(unsigned int *)pValue); break; // 4 Byte Integer (unsigned) case SG_DATATYPE_Int: pGrid->Set_Value(x, y, *(signed int *)pValue); break; // 4 Byte Integer (signed) case SG_DATATYPE_Float: pGrid->Set_Value(x, y, *(float *)pValue); break; // 4 Byte Floating Point case SG_DATATYPE_Double: pGrid->Set_Value(x, y, *(double *)pValue); break; // 8 Byte Floating Point } } for(x=0; xFlip(); } } } //----------------------------------------------------- return( pGrid ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid/wrf.cpp0000664000175000017500000010471512565125414021370 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wrf.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // wrf.cpp // // // // Copyright (C) 2011 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "wrf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// #define VAL_CATEGORICAL 0 #define VAL_CONTINUOUS 1 #define VAL_ENDIAN_BIG 0 #define VAL_ENDIAN_LITTLE 1 #define VAL_BOTTOM_TOP 0 #define VAL_TOP_BOTTOM 1 //--------------------------------------------------------- CWRF_Index::CWRF_Index(void) { Reset(); } //--------------------------------------------------------- bool CWRF_Index::Reset(void) { m_PROJECTION = SG_T(""); // A character string specifying the projection of the data, which may be // either lambert, polar, mercator, regular_ll, albers_nad83, or polar_wgs84. // No default value. m_TYPE = 0; // A character string, either categorical or continuous, that determines // whether the data in the data files should be interpreted as a continuous field or as discrete // indices. For categorical data represented by a fractional field for each possible category, // type should be set to continuous. // No default value. m_SIGNED = false; // Either yes or no, indicating whether the values in the data files (which are // always represented as integers) are signed in two's complement form or not. // Default value is no. m_UNITS = SG_T(""); // A character string, enclosed in quotation marks ("), specifying the units of the // interpolated field; the string will be written to the geogrid output files as a variable timeindependent // attribute. // No default value. m_DESCRIPTION = SG_T(""); // A character string, enclosed in quotation marks ("), giving a short // description of the interpolated field; the string will be written to the geogrid output files // as a variable time-independent attribute. // No default value. m_DX = 0.0; // A real value giving the grid spacing in the x-direction of the data set. If // projection is one of lambert, polar, mercator, albers_nad83, or polar_wgs84, dx // gives the grid spacing in meters; if projection is regular_ll, dx gives the grid spacing // in degrees. // No default value. m_DY = 0.0; // A real value giving the grid spacing in the y-direction of the data set. If // projection is one of lambert, polar, mercator, albers_nad83, or polar_wgs84, dy // gives the grid spacing in meters; if projection is regular_ll, dy gives the grid spacing // in degrees. // No default value. m_KNOWN_X = 1.0; // A real value specifying the i-coordinate of an (i,j) location // corresponding to a (latitude, longitude) location that is known in the projection. // Default value is 1. m_KNOWN_Y = 1.0; // A real value specifying the j-coordinate of an (i,j) location // corresponding to a (latitude, longitude) location that is known in the projection. // Default value is 1. m_KNOWN_LAT = 0.0; // A real value specifying the latitude of a (latitude, longitude) // location that is known in the projection. // No default value. m_KNOWN_LON = 0.0; // A real value specifying the longitude of a (latitude, longitude) // location that is known in the projection. // No default value. m_STDLON = 0.0; // A real value specifying the longitude that is parallel with the y-axis in // conic and azimuthal projections. // No default value. m_TRUELAT1 = 0.0; // A real value specifying the first true latitude for conic projections or // the only true latitude for azimuthal projections. // No default value. m_TRUELAT2 = 0.0; // A real value specifying the second true latitude for conic projections. // No default value. m_WORDSIZE = 1; // An integer giving the number of bytes used to represent the value of // each grid point in the data files. // No default value. m_TILE_X = 0; // An integer specifying the number of grid points in the x-direction, // excluding any halo points, for a single tile of source data. // No default value. m_TILE_Y = 0; // An integer specifying the number of grid points in the y-direction, // excluding any halo points, for a single tile of source data. // No default value. m_TILE_Z = 1; // An integer specifying the number of grid points in the z-direction for a // single tile of source data; this keyword serves as an alternative to the pair of keywords // tile_z_start and tile_z_end, and when this keyword is used, the starting z-index is // assumed to be 1. // No default value. m_TILE_Z_START = 1; // An integer specifying the starting index in the z-direction of the // array in the data files. If this keyword is used, tile_z_end must also be specified. // No default value. m_TILE_Z_END = 1; // An integer specifying the ending index in the z-direction of the array // in the data files. If this keyword is used, tile_z_start must also be specified. // No default value m_CATEGORY_MIN = 0; // For categorical data (type=categorical), an integer specifying // the minimum category index that is found in the data set. If this keyword is used, // category_max must also be specified. // No default value. m_CATEGORY_MAX = 0; // For categorical data (type=categorical), an integer // specifying the maximum category index that is found in the data set. If this keyword is // used, category_min must also be specified. // No default value. m_TILE_BDR = 0; // An integer specifying the halo width, in grid points, for each tile of data. // Default value is 0. m_MISSING_VALUE = -99999.0; // A real value that, when encountered in the data set, should be interpreted as missing data. // No default value. m_SCALE_FACTOR = 1.0; // A real value that data should be scaled by (through // multiplication) after being read in as integers from tiles of the data set. // Default value is 1. m_ROW_ORDER = VAL_BOTTOM_TOP; // A character string, either bottom_top or top_bottom, specifying // whether the rows of the data set arrays were written proceeding from the lowest-index // row to the highest (bottom_top) or from highest to lowest (top_bottom). This keyword // may be useful when utilizing some USGS data sets, which are provided in top_bottom // order. // Default value is bottom_top. m_ENDIAN = VAL_ENDIAN_BIG; // A character string, either big or little, specifying whether the values in // the static data set arrays are in big-endian or little-endian byte order. // Default value is big. m_ISWATER = 16; // An integer specifying the land use category of water. // Default value is 16. m_ISLAKE = -1; // An integer specifying the land use category of inland water bodies. // Default value is -1 (i.e., no separate inland water category). m_ISICE = 24; // An integer specifying the land use category of ice. // Default value is 24. m_ISURBAN = 1; // An integer specifying the land use category of urban areas. // Default value is 1. m_ISOILWATER = 14; // An integer specifying the soil category of water. // Default value is 14. m_MMINLU = SG_T("USGS"); // A character string, enclosed in quotation marks ("), indicating which // section of WRF's LANDUSE.TBL and VEGPARM.TBL will be used when looking up // parameters for land use categories. // Default value is "USGS". return( true ); } //--------------------------------------------------------- bool CWRF_Index::Load(const CSG_String &File) { Reset(); CSG_File Stream; if( !Stream.Open(File, SG_FILE_R, false) ) { return( false ); } CSG_String sLine, sKey, sValue; while( Stream.Read_Line(sLine) ) { sKey = sLine.BeforeFirst(SG_T('=')).Make_Upper(); sKey .Trim(); sKey .Trim(true); sValue = sLine.AfterFirst (SG_T('=')).Make_Upper(); sValue.Trim(); sValue.Trim(true); if( !sKey.Cmp(SG_T("PROJECTION")) ) { m_PROJECTION = sValue; } else if( !sKey.Cmp(SG_T("TYPE")) ) { m_TYPE = sValue.Contains(SG_T("CATEGORICAL")) ? VAL_CATEGORICAL : VAL_CONTINUOUS; } else if( !sKey.Cmp(SG_T("SIGNED")) ) { m_SIGNED = sValue.Contains(SG_T("YES")); } else if( !sKey.Cmp(SG_T("UNITS")) ) { m_UNITS = sValue; } else if( !sKey.Cmp(SG_T("DESCRIPTION")) ) { m_DESCRIPTION = sValue; } else if( !sKey.Cmp(SG_T("DX")) ) { m_DX = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("DY")) ) { m_DY = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("KNOWN_X")) ) { m_KNOWN_X = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("KNOWN_Y")) ) { m_KNOWN_Y = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("KNOWN_LAT")) ) { m_KNOWN_LAT = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("KNOWN_LON")) ) { m_KNOWN_LON = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("STDLON")) ) { m_STDLON = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("TRUELAT1")) ) { m_TRUELAT1 = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("TRUELAT2")) ) { m_TRUELAT2 = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("WORDSIZE")) ) { m_WORDSIZE = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_X")) ) { m_TILE_X = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_Y")) ) { m_TILE_Y = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_Z")) ) { m_TILE_Z = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_Z_START")) ) { m_TILE_Z_START = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_Z_END")) ) { m_TILE_Z_END = sValue.asInt(); } else if( !sKey.Cmp(SG_T("CATEGORY_MIN")) ) { m_CATEGORY_MIN = sValue.asInt(); } else if( !sKey.Cmp(SG_T("CATEGORY_MAX")) ) { m_CATEGORY_MAX = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_BDR")) ) { m_TILE_BDR = sValue.asInt(); } else if( !sKey.Cmp(SG_T("MISSING_VALUE")) ) { m_MISSING_VALUE = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("SCALE_FACTOR")) ) { m_SCALE_FACTOR = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("ROW_ORDER")) ) { m_ROW_ORDER = sValue.Contains(SG_T("BOTTOM_TOP")) ? VAL_BOTTOM_TOP : VAL_TOP_BOTTOM; } else if( !sKey.Cmp(SG_T("ENDIAN")) ) { m_ENDIAN = sValue.Contains(SG_T("BIG")) ? VAL_ENDIAN_BIG : VAL_ENDIAN_LITTLE; } else if( !sKey.Cmp(SG_T("ISWATER")) ) { m_ISWATER = sValue.asInt(); } else if( !sKey.Cmp(SG_T("ISLAKE")) ) { m_ISLAKE = sValue.asInt(); } else if( !sKey.Cmp(SG_T("ISICE")) ) { m_ISICE = sValue.asInt(); } else if( !sKey.Cmp(SG_T("ISURBAN")) ) { m_ISURBAN = sValue.asInt(); } else if( !sKey.Cmp(SG_T("ISOILWATER")) ) { m_ISOILWATER = sValue.asInt(); } else if( !sKey.Cmp(SG_T("MMINLU")) ) { m_MMINLU = sValue; } } return( true ); } //--------------------------------------------------------- bool CWRF_Index::Save(const CSG_String &File) { CSG_File Stream; if( !Stream.Open(File, SG_FILE_W, false) ) { return( false ); } //----------------------------------------------------- Stream.Printf(SG_T("%s=%s\n"), SG_T("TYPE") , m_TYPE == VAL_CATEGORICAL ? SG_T("CATEGORICAL") : SG_T("CONTINUOUS")); if( m_CATEGORY_MIN < m_CATEGORY_MAX ) { Stream.Printf(SG_T("%s=%d\n"), SG_T("CATEGORY_MIN") , m_CATEGORY_MIN); Stream.Printf(SG_T("%s=%d\n"), SG_T("CATEGORY_MAX") , m_CATEGORY_MAX); } Stream.Printf(SG_T("%s=%s\n"), SG_T("PROJECTION") , m_PROJECTION.c_str()); if( m_PROJECTION.CmpNoCase(SG_T("regular_ll")) ) { Stream.Printf(SG_T("%s=%f\n"), SG_T("STDLON") , m_STDLON); Stream.Printf(SG_T("%s=%f\n"), SG_T("TRUELAT1") , m_TRUELAT1); Stream.Printf(SG_T("%s=%f\n"), SG_T("TRUELAT2") , m_TRUELAT2); } Stream.Printf(SG_T("%s=%.8f\n"), SG_T("DX") , m_DX); Stream.Printf(SG_T("%s=%.8f\n"), SG_T("DY") , m_DY); Stream.Printf(SG_T("%s=%f\n"), SG_T("KNOWN_X") , m_KNOWN_X); Stream.Printf(SG_T("%s=%f\n"), SG_T("KNOWN_Y") , m_KNOWN_Y); Stream.Printf(SG_T("%s=%.5f\n"), SG_T("KNOWN_LAT") , m_KNOWN_LAT); Stream.Printf(SG_T("%s=%.5f\n"), SG_T("KNOWN_LON") , m_KNOWN_LON); if( m_SIGNED ) { Stream.Printf(SG_T("%s=%s\n"), SG_T("SIGNED") , SG_T("YES")); } Stream.Printf(SG_T("%s=%d\n"), SG_T("WORDSIZE") , m_WORDSIZE); Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_X") , m_TILE_X); Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_Y") , m_TILE_Y); if( m_TILE_Z == 1 ) { Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_Z") , m_TILE_Z); } else { Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_Z_START") , m_TILE_Z_START); Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_Z_END") , m_TILE_Z_END); } if( m_TILE_BDR > 0 ) { Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_BDR") , m_TILE_BDR); } Stream.Printf(SG_T("%s=%f\n"), SG_T("MISSING_VALUE") , m_MISSING_VALUE); if( m_SCALE_FACTOR != 1.0 ) { Stream.Printf(SG_T("%s=%f\n"), SG_T("SCALE_FACTOR") , m_SCALE_FACTOR); } if( m_ROW_ORDER == VAL_TOP_BOTTOM ) { Stream.Printf(SG_T("%s=%s\n"), SG_T("ROW_ORDER") , SG_T("TOP_BOTTOM")); } if( m_ENDIAN == VAL_ENDIAN_LITTLE ) { Stream.Printf(SG_T("%s=%s\n"), SG_T("ENDIAN") , SG_T("LITTLE")); } if( m_TYPE == VAL_CATEGORICAL ) { Stream.Printf(SG_T("%s=\"%s\"\n"), SG_T("UNITS") , SG_T("CATEGORY")); } else if( m_UNITS.Length() > 0 ) { Stream.Printf(SG_T("%s=\"%s\"\n"), SG_T("UNITS") , m_UNITS.c_str()); } if( m_DESCRIPTION.Length() > 0 ) { Stream.Printf(SG_T("%s=\"%s\"\n"), SG_T("DESCRIPTION") , m_DESCRIPTION.c_str()); } if( m_MMINLU.CmpNoCase(SG_T("USGS")) ) { Stream.Printf(SG_T("%s=%s\n"), SG_T("MMINLU") , m_MMINLU.c_str()); } if( m_ISWATER != 16 ) Stream.Printf(SG_T("%s=%d\n"), SG_T("ISWATER") , m_ISWATER); if( m_ISLAKE != -1 ) Stream.Printf(SG_T("%s=%d\n"), SG_T("ISLAKE") , m_ISLAKE); if( m_ISICE != 24 ) Stream.Printf(SG_T("%s=%d\n"), SG_T("_ISICE") , m_ISICE); if( m_ISURBAN != 1 ) Stream.Printf(SG_T("%s=%d\n"), SG_T("m_ISURBAN") , m_ISURBAN); if( m_ISOILWATER != 14 ) Stream.Printf(SG_T("%s=%d\n"), SG_T("m_ISOILWATER"), m_ISOILWATER); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWRF_Import::CWRF_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import WRF Geogrid Binary Format")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Imports grid(s) from Weather Research and Forcasting Model (WRF) geogrid binary format." "\n" "WRF Homepage" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL("") ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWRF_Import::On_Execute(void) { CSG_String File; //----------------------------------------------------- File = Parameters("FILE") ->asString(); Parameters("GRIDS")->asGridList()->Del_Items(); //----------------------------------------------------- if( !m_Index.Load(SG_File_Make_Path(SG_File_Get_Path(File), SG_T("index"))) ) { Error_Set(_TL("error reading index file")); return( false ); } //----------------------------------------------------- if( !Load(File) ) { Error_Set(_TL("error loading data file")); return( false ); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWRF_Import::Load(const CSG_String &File) { //----------------------------------------------------- // 00001-00600.00001-00600 // 01234567890123456789012 CSG_String Name = SG_File_Get_Name(File, true); if( Name.Length() != 23 || Name[5] != SG_T('-') || Name[11] != SG_T('.') || Name[17] != SG_T('-') ) { Error_Set(_TL("invalid geogrid file name")); return( false ); } int xOffset = Name.asInt() - 1; int yOffset = Name.AfterFirst(SG_T('.')).asInt() - 1; //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(File, SG_FILE_R) ) { Error_Set(_TL("data file could not be openend")); return( false ); } //----------------------------------------------------- TSG_Data_Type Type; switch( m_Index.m_WORDSIZE ) { default: Error_Set(_TL("invalid word size")); return( false ); case 1: Type = m_Index.m_SIGNED == false ? SG_DATATYPE_Byte : SG_DATATYPE_Char; break; case 2: Type = m_Index.m_SIGNED == false ? SG_DATATYPE_Word : SG_DATATYPE_Short; break; case 4: Type = m_Index.m_SIGNED == false ? SG_DATATYPE_DWord : SG_DATATYPE_Int; break; } //----------------------------------------------------- char *pLine, *pValue; int x, y, nBytes_Line; nBytes_Line = (m_Index.m_TILE_X + 2 * m_Index.m_TILE_BDR) * m_Index.m_WORDSIZE; pLine = (char *)SG_Malloc(nBytes_Line); //----------------------------------------------------- for(int z=m_Index.m_TILE_Z_START; z<=m_Index.m_TILE_Z_END && !Stream.is_EOF() && Process_Get_Okay(); z++) { CSG_Grid *pGrid = SG_Create_Grid( Type, m_Index.m_TILE_X + 2 * m_Index.m_TILE_BDR, m_Index.m_TILE_Y + 2 * m_Index.m_TILE_BDR, m_Index.m_DX, m_Index.m_KNOWN_LON + (xOffset - m_Index.m_TILE_BDR) * m_Index.m_DX, m_Index.m_KNOWN_LAT + (yOffset - m_Index.m_TILE_BDR) * m_Index.m_DY ); pGrid->Set_Name (CSG_String::Format(SG_T("%s_%02d"), SG_File_Get_Name(File, false).c_str(), z)); pGrid->Set_Description (m_Index.m_DESCRIPTION); pGrid->Set_Unit (m_Index.m_UNITS); pGrid->Set_NoData_Value (m_Index.m_MISSING_VALUE); pGrid->Set_Scaling (m_Index.m_SCALE_FACTOR); Parameters("GRIDS")->asGridList()->Add_Item(pGrid); //------------------------------------------------- for(y=0; yGet_NY() && !Stream.is_EOF() && Set_Progress(y, pGrid->Get_NY()); y++) { int yy = m_Index.m_ROW_ORDER == VAL_TOP_BOTTOM ? pGrid->Get_NY() - 1 - y : y; Stream.Read(pLine, sizeof(char), nBytes_Line); for(x=0, pValue=pLine; xGet_NX(); x++, pValue+=m_Index.m_WORDSIZE) { if( m_Index.m_ENDIAN == VAL_ENDIAN_BIG ) { SG_Swap_Bytes(pValue, m_Index.m_WORDSIZE); } switch( pGrid->Get_Type() ) { case SG_DATATYPE_Byte: pGrid->Set_Value(x, yy, *(unsigned char *)pValue); break; // 1 Byte Integer (unsigned) case SG_DATATYPE_Char: pGrid->Set_Value(x, yy, *(signed char *)pValue); break; // 1 Byte Integer (signed) case SG_DATATYPE_Word: pGrid->Set_Value(x, yy, *(unsigned short *)pValue); break; // 2 Byte Integer (unsigned) case SG_DATATYPE_Short: pGrid->Set_Value(x, yy, *(signed short *)pValue); break; // 2 Byte Integer (signed) case SG_DATATYPE_DWord: pGrid->Set_Value(x, yy, *(unsigned int *)pValue); break; // 4 Byte Integer (unsigned) case SG_DATATYPE_Int: pGrid->Set_Value(x, yy, *(signed int *)pValue); break; // 4 Byte Integer (signed) } } } } //----------------------------------------------------- SG_Free(pLine); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWRF_Export::CWRF_Export(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export WRF Geogrid Binary Format")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Exports grid(s) to Weather Research and Forcasting Model (WRF) geogrid binary format." "\n" "WRF Homepage" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("Directory"), _TL(""), NULL, NULL, true, true ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_TYPE", _TL("Projection"), _TL("")); Parameters.Add_Choice( pNode , "DATATYPE" , _TL("Data Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("1 byte unsigned"), _TL("1 byte signed"), _TL("2 byte unsigned"), _TL("2 byte signed"), _TL("4 byte unsigned"), _TL("4 byte signed") ), 0 ); Parameters.Add_Choice( pNode , "TYPE" , _TL("Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("categorical"), _TL("continuous") ), 0 ); Parameters.Add_Value(pNode , "MISSING" , _TL("Missing Value") , _TL(""), PARAMETER_TYPE_Double, m_Index.m_MISSING_VALUE); Parameters.Add_Value(pNode , "SCALE" , _TL("Scale Factor") , _TL(""), PARAMETER_TYPE_Double, m_Index.m_SCALE_FACTOR); Parameters.Add_String(pNode , "UNITS" , _TL("Units") , _TL(""), m_Index.m_UNITS); Parameters.Add_String(pNode , "DESCRIPTION" , _TL("Description") , _TL(""), m_Index.m_DESCRIPTION); Parameters.Add_String(pNode , "MMINLU" , _TL("Look Up Section") , _TL(""), m_Index.m_MMINLU); Parameters.Add_Value(pNode , "TILE_BDR" , _TL("Halo Width") , _TL(""), PARAMETER_TYPE_Int, 0, 0, true); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_PRJ", _TL("Projection"), _TL("")); Parameters.Add_Choice( pNode , "PROJECTION" , _TL("Projection"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), SG_T("lambert"), SG_T("polar"), SG_T("mercator"), SG_T("regular_ll"), SG_T("albers_nad83"), SG_T("polar_wgs84") ), 3 ); Parameters.Add_Value(pNode , "SDTLON" , _TL("Standard Longitude") , _TL(""), PARAMETER_TYPE_Double, 0.0); Parameters.Add_Value(pNode , "TRUELAT1" , _TL("True Latitude 1") , _TL(""), PARAMETER_TYPE_Double, 45.0); Parameters.Add_Value(pNode , "TRUELAT2" , _TL("True Latitude 2") , _TL(""), PARAMETER_TYPE_Double, 35.0); //----------------------------------------------------- // pNode = Parameters.Add_Node(NULL, "NODE_REF", _TL("Referencing"), _TL("")); // Parameters.Add_Value(pNode , "KNOWN_X" , _TL("Known X") , _TL(""), PARAMETER_TYPE_Double, 1.0); // Parameters.Add_Value(pNode , "KNOWN_Y" , _TL("Known Y") , _TL(""), PARAMETER_TYPE_Double, 1.0); // Parameters.Add_Value(pNode , "KNOWN_LON" , _TL("Longitude") , _TL(""), PARAMETER_TYPE_Double, -180.0); // Parameters.Add_Value(pNode , "KNOWN_LAT" , _TL("Latitude") , _TL(""), PARAMETER_TYPE_Double, -90.0); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_CAT", _TL("Categories"), _TL("")); Parameters.Add_Value(pNode , "ISWATER" , _TL("Water") , _TL(""), PARAMETER_TYPE_Int, m_Index.m_ISWATER); Parameters.Add_Value(pNode , "ISLAKE" , _TL("Lake") , _TL(""), PARAMETER_TYPE_Int, m_Index.m_ISLAKE); Parameters.Add_Value(pNode , "ISICE" , _TL("Ice") , _TL(""), PARAMETER_TYPE_Int, m_Index.m_ISICE); Parameters.Add_Value(pNode , "ISURBAN" , _TL("Urban") , _TL(""), PARAMETER_TYPE_Int, m_Index.m_ISURBAN); Parameters.Add_Value(pNode , "ISOILWATER" , _TL("Soil Water") , _TL(""), PARAMETER_TYPE_Int, m_Index.m_ISOILWATER); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CWRF_Export::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("MMINLU")) ) { if( !SG_STR_CMP(pParameter->asString(), SG_T("USGS")) ) { pParameters->Get_Parameter("DESCRIPTION")->Set_Value(SG_T("24-category USGS landuse")); } } //----------------------------------------------------- return( 1 ); } //--------------------------------------------------------- int CWRF_Export::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("PROJECTION")) ) { pParameters->Get_Parameter("SDTLON" )->Set_Enabled(pParameter->asInt() != 3); pParameters->Get_Parameter("TRUELAT1")->Set_Enabled(pParameter->asInt() != 3); pParameters->Get_Parameter("TRUELAT2")->Set_Enabled(pParameter->asInt() != 3); } //----------------------------------------------------- return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWRF_Export::On_Execute(void) { CSG_String Directory; CSG_Parameter_Grid_List *pGrids; //----------------------------------------------------- Directory = Parameters("FILE") ->asString(); pGrids = Parameters("GRIDS") ->asGridList(); //----------------------------------------------------- m_Index.Reset(); switch( Parameters("DATATYPE")->asInt() ) { case 0: default: m_Index.m_WORDSIZE = 1; m_Index.m_SIGNED = false; break; case 1: m_Index.m_WORDSIZE = 1; m_Index.m_SIGNED = true; break; case 2: m_Index.m_WORDSIZE = 2; m_Index.m_SIGNED = false; break; case 3: m_Index.m_WORDSIZE = 2; m_Index.m_SIGNED = true; break; case 4: m_Index.m_WORDSIZE = 4; m_Index.m_SIGNED = false; break; case 5: m_Index.m_WORDSIZE = 4; m_Index.m_SIGNED = true; break; } m_Index.m_TYPE = Parameters("TYPE") ->asInt(); m_Index.m_MISSING_VALUE = Parameters("MISSING") ->asDouble(); m_Index.m_SCALE_FACTOR = Parameters("SCALE") ->asDouble(); m_Index.m_UNITS = Parameters("UNITS") ->asString(); m_Index.m_DESCRIPTION = Parameters("DESCRIPTION") ->asString(); m_Index.m_MMINLU = Parameters("MMINLU") ->asString(); m_Index.m_TILE_BDR = Parameters("TILE_BDR") ->asInt(); m_Index.m_TILE_X = Get_NX() - 2 * m_Index.m_TILE_BDR; m_Index.m_TILE_Y = Get_NY() - 2 * m_Index.m_TILE_BDR; m_Index.m_TILE_Z = pGrids->Get_Count(); m_Index.m_TILE_Z_START = 1; m_Index.m_TILE_Z_END = pGrids->Get_Count(); m_Index.m_DX = Get_Cellsize(); m_Index.m_DY = Get_Cellsize(); m_Index.m_ENDIAN = VAL_ENDIAN_LITTLE; m_Index.m_ROW_ORDER = VAL_BOTTOM_TOP; m_Index.m_PROJECTION = Parameters("PROJECTION") ->asString(); m_Index.m_STDLON = Parameters("SDTLON") ->asDouble(); m_Index.m_TRUELAT1 = Parameters("TRUELAT1") ->asDouble(); m_Index.m_TRUELAT2 = Parameters("TRUELAT2") ->asDouble(); m_Index.m_KNOWN_LAT = - 90.0 + 0.5 * m_Index.m_DY; m_Index.m_KNOWN_LON = -180.0 + 0.5 * m_Index.m_DX; // m_Index.m_KNOWN_X = Parameters("KNOWN_X") ->asDouble(); // m_Index.m_KNOWN_Y = Parameters("KNOWN_Y") ->asDouble(); // m_Index.m_KNOWN_LAT = Parameters("KNOWN_LAT") ->asDouble(); // m_Index.m_KNOWN_LON = Parameters("KNOWN_LON") ->asDouble(); if( m_Index.m_TILE_Z == 1 ) { m_Index.m_CATEGORY_MIN = m_Index.m_TYPE == VAL_CATEGORICAL ? (int)pGrids->asGrid(0)->Get_ZMin() : 0; m_Index.m_CATEGORY_MAX = m_Index.m_TYPE == VAL_CATEGORICAL ? (int)pGrids->asGrid(0)->Get_ZMax() : 0; } else { m_Index.m_CATEGORY_MIN = m_Index.m_TILE_Z_START; m_Index.m_CATEGORY_MAX = m_Index.m_TILE_Z_END; } m_Index.m_ISWATER = Parameters("ISWATER") ->asInt(); m_Index.m_ISLAKE = Parameters("ISLAKE") ->asInt(); m_Index.m_ISICE = Parameters("ISICE") ->asInt(); m_Index.m_ISURBAN = Parameters("ISURBAN") ->asInt(); m_Index.m_ISOILWATER = Parameters("ISOILWATER") ->asInt(); //----------------------------------------------------- if( !m_Index.Save(SG_File_Make_Path(Directory, SG_T("index"))) ) { Error_Set(_TL("error saving index file")); return( false ); } //----------------------------------------------------- if( !Save(Directory, pGrids) ) { Error_Set(_TL("error saving data file")); return( false ); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWRF_Export::Save(const CSG_String &Directory, CSG_Parameter_Grid_List *pGrids) { //----------------------------------------------------- // 00001-00600.00001-00600 // 01234567890123456789012 int xOffset = m_Index.m_TILE_BDR + (int)(0.5 + (Get_XMin() - m_Index.m_KNOWN_LON) / Get_Cellsize()); int yOffset = m_Index.m_TILE_BDR + (int)(0.5 + (Get_YMin() - m_Index.m_KNOWN_LAT) / Get_Cellsize()); CSG_String Name = SG_File_Get_Name(Directory, true); Name.Printf(SG_T("%05d-%05d.%05d-%05d"), xOffset + 1, xOffset + m_Index.m_TILE_X, yOffset + 1, yOffset + m_Index.m_TILE_Y); //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(SG_File_Make_Path(Directory, Name), SG_FILE_W) ) { Error_Set(_TL("data file could not be openend")); return( false ); } //----------------------------------------------------- char *pLine, *pValue; int x, y, nBytes_Line; nBytes_Line = Get_NX() * m_Index.m_WORDSIZE; pLine = (char *)SG_Malloc(nBytes_Line); //----------------------------------------------------- for(int z=0; zGet_Count() && Process_Get_Okay(); z++) { CSG_Grid *pGrid = pGrids->asGrid(z); //------------------------------------------------- for(y=0; yGet_NY() && !Stream.is_EOF() && Set_Progress(y, pGrid->Get_NY()); y++) { int yy = m_Index.m_ROW_ORDER == VAL_TOP_BOTTOM ? pGrid->Get_NY() - 1 - y : y; for(x=0, pValue=pLine; xGet_NX(); x++, pValue+=m_Index.m_WORDSIZE) { if( m_Index.m_SIGNED ) { switch( m_Index.m_WORDSIZE ) { case 1: *((signed char *)pValue) = (signed char )pGrid->asInt(x, yy); break; case 2: *((signed short *)pValue) = (signed short )pGrid->asInt(x, yy); break; case 4: *((signed int *)pValue) = (signed int )pGrid->asInt(x, yy); break; } } else { switch( m_Index.m_WORDSIZE ) { case 1: *((unsigned char *)pValue) = (unsigned char )pGrid->asInt(x, yy); break; case 2: *((unsigned short *)pValue) = (unsigned short)pGrid->asInt(x, yy); break; case 4: *((unsigned int *)pValue) = (unsigned int )pGrid->asInt(x, yy); break; } } if( m_Index.m_ENDIAN == VAL_ENDIAN_BIG ) { SG_Swap_Bytes(pValue, m_Index.m_WORDSIZE); } } Stream.Write(pLine, sizeof(char), nBytes_Line); } } //----------------------------------------------------- SG_Free(pLine); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid/srtm30.cpp0000664000175000017500000002411512565125414021715 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: srtm30.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // SRTM30.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "srtm30.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSRTM30_Import::CSRTM30_Import(void) { CSG_Parameter *pNode_0; CSG_Parameters *pParameters; //----------------------------------------------------- Set_Name(_TL("Import SRTM30 DEM")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description (_TW( "Extracts elevation grids from SRTM30 data.\n\n" "\"SRTM30 is a near-global digital elevation model (DEM) comprising a " "combination of data from the Shuttle Radar Topography Mission, flown " "in February, 2000 and the the U.S. Geological Survey's GTOPO30 data " "set. It can be considered to be either an SRTM data set enhanced with " "GTOPO30, or as an upgrade to GTOPO30.\" (NASA)\n\n" "Further information about the GTOPO30 data set:\n" "" "http://edcdaac.usgs.gov/gtopo30/gtopo30.html\n\n" "SRTM30 data can be downloaded from:\n" "" "ftp://e0srp01u.ecs.nasa.gov/srtm/version2/SRTM30/\n\n" "A directory, that contains the uncompressed SRTM30 DEM files, can be located using " "the \"Path\" Parameter of this module.") ); //----------------------------------------------------- pNode_0 = Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); pNode_0 = Parameters.Add_FilePath( NULL , "PATH" , _TL("Path"), _TL(""), NULL, NULL, false, true ); //----------------------------------------------------- pNode_0 = Parameters.Add_Value( NULL , "XMIN" , _TL("West []"), _TL(""), PARAMETER_TYPE_Int, 60.0 ); pNode_0 = Parameters.Add_Value( NULL , "XMAX" , _TL("East []"), _TL(""), PARAMETER_TYPE_Int, 120.0 ); pNode_0 = Parameters.Add_Value( NULL , "YMIN" , _TL("South []"), _TL(""), PARAMETER_TYPE_Int, 20.0 ); pNode_0 = Parameters.Add_Value( NULL , "YMAX" , _TL("North []"), _TL(""), PARAMETER_TYPE_Int, 50.0 ); //----------------------------------------------------- pParameters = Add_Parameters("TILE", _TL(""), _TL("")); pNode_0 = pParameters->Add_Info_String( NULL , "INFO" , _TL("File does not exist:"), _TL(""), _TL("") ); pNode_0 = pParameters->Add_FilePath( NULL , "PATH" , _TL("Select file"), _TL(""), _TL("SRTM30 DEM Tiles (*.dem)|*.dem|All Files|*.*") ); } //--------------------------------------------------------- CSRTM30_Import::~CSRTM30_Import(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define X_WIDTH 4800 #define Y_WIDTH 6000 //--------------------------------------------------------- bool CSRTM30_Import::On_Execute(void) { char x_sTile[9][5] = { "W180", "W140", "W100", "W060", "W020", "E020", "E060", "E100", "E140" }, y_sTile[3][4] = { "S10", "N40", "N90" }; double dSize = 30.0 / (60.0 * 60.0); //----------------------------------------------------- int xTile, yTile; double xMin, xMax, yMin, yMax; TSG_Rect rOut, rTile; CSG_String sTile; CSG_Grid *pOut; //----------------------------------------------------- xMin = Parameters("XMIN")->asInt(); xMax = Parameters("XMAX")->asInt(); yMin = Parameters("YMIN")->asInt(); yMax = Parameters("YMAX")->asInt(); rOut.xMin = (180 + xMin) / 40.0 * X_WIDTH; rOut.xMax = rOut.xMin + (int)((xMax - xMin) / dSize); rOut.yMin = ( 60 + yMin) / 50.0 * Y_WIDTH; rOut.yMax = rOut.yMin + (int)((yMax - yMin) / dSize); //----------------------------------------------------- pOut = SG_Create_Grid(SG_DATATYPE_Short, (int)(rOut.xMax - rOut.xMin), (int)(rOut.yMax - rOut.yMin), dSize, xMin + 0.5 * dSize, yMin + 0.5 * dSize ); pOut->Set_NoData_Value(-9999); pOut->Assign_NoData(); pOut->Set_Name(SG_T("SRTM30")); pOut->Get_Projection().Create(SG_T("GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]")); //----------------------------------------------------- for(yTile=0, rTile.yMin=0, rTile.yMax=Y_WIDTH; yTile<3; yTile++, rTile.yMin+=Y_WIDTH, rTile.yMax+=Y_WIDTH) { for(xTile=0, rTile.xMin=0, rTile.xMax=X_WIDTH; xTile<9; xTile++, rTile.xMin+=X_WIDTH, rTile.xMax+=X_WIDTH) { sTile.Printf(SG_T("Tile: %s%s"), x_sTile[xTile], y_sTile[yTile]); Process_Set_Text(sTile); sTile.Printf(SG_T("%s%s%s.dem"), Parameters("PATH")->asString(), x_sTile[xTile], y_sTile[yTile]); Tile_Load(sTile, rTile, pOut, rOut); } } //----------------------------------------------------- Parameters("GRID")->Set_Value(pOut); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSRTM30_Import::Tile_Load(const SG_Char *sTile, TSG_Rect &rTile, CSG_Grid *pOut, TSG_Rect &rOut) { short Value; int x, y, xOut, yOut; FILE *Stream; CSG_Rect r(rTile); if( r.Intersects(rOut) != INTERSECTION_None && (Stream = Tile_Open(sTile)) != NULL ) { for(y=0, yOut=(int)(rTile.yMax-rOut.yMin); y=0 && Set_Progress(y, Y_WIDTH); y++, yOut--) { for(x=0, xOut=(int)(rTile.xMin-rOut.xMin); x= 0 && xOut < pOut->Get_NX() && yOut >= 0 && yOut < pOut->Get_NY() ) { SG_Swap_Bytes(&Value, sizeof(short)); pOut->Set_Value(xOut, yOut, Value); } } } fclose(Stream); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- FILE * CSRTM30_Import::Tile_Open(const SG_Char *sTile) { const SG_Char *sPath; FILE *Stream; CSG_String fName; CSG_Parameters *pParameters; fName = sTile; if( (Stream = fopen(fName.b_str(), "rb")) == NULL ) { pParameters = Get_Parameters("TILE"); pParameters->Get_Parameter("INFO")->Set_Value(sTile); if( Dlg_Parameters(pParameters, _TL("Locate STRM30 Data File")) && (sPath = pParameters->Get_Parameter("PATH")->asString()) != NULL ) { fName = sPath; Stream = fopen(fName.b_str(), "rb"); } } return( Stream ); } saga-2.2.3/src/modules/io/io_grid/import_clip_resample.h0000664000175000017500000001036512565125414024445 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: import_clip_resample.h 1380 2012-04-26 12:02:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // import_clip_resample.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__import_clip_resample_H #define HEADER_INCLUDED__import_clip_resample_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CImport_Clip_Resample : public CSG_Module { public: CImport_Clip_Resample(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: CSG_Grid_System m_System; CSG_Parameter_Grid_List *m_pGrids; bool Load_File (const CSG_String &File); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__import_clip_resample_H saga-2.2.3/src/modules/io/io_grid/esri_arcinfo.h0000664000175000017500000001231012565125414022667 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: esri_arcinfo.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // ESRI_ArcInfo.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // ESRI_ArcInfo.h // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ESRI_ArcInfo_H #define HEADER_INCLUDED__ESRI_ArcInfo_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CESRI_ArcInfo_Import : public CSG_Module { public: CESRI_ArcInfo_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: 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, TSG_Data_Type Datatype = SG_DATATYPE_Float); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CESRI_ArcInfo_Export : public CSG_Module_Grid { public: CESRI_ArcInfo_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Export") ); } protected: virtual bool On_Execute (void); private: CSG_String Write_Value (double Value, int Precision, bool bComma); bool Write_Header (CSG_File &Stream, CSG_Grid *pGrid, bool bComma); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ESRI_ArcInfo_H saga-2.2.3/src/modules/io/io_grid/wrf.h0000664000175000017500000001373612565125414021037 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wrf.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // wrf.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__wrf_Import_H #define HEADER_INCLUDED__wrf_Import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWRF_Index { public: CWRF_Index(void); bool Reset (void); bool Load (const CSG_String &File); bool Save (const CSG_String &File); bool m_SIGNED, m_ENDIAN; int m_TYPE, m_WORDSIZE, m_TILE_X, m_TILE_Y, m_TILE_Z, m_TILE_Z_START, m_TILE_Z_END, m_CATEGORY_MIN, m_CATEGORY_MAX, m_TILE_BDR, m_ROW_ORDER; int m_ISWATER, m_ISLAKE, m_ISICE, m_ISURBAN, m_ISOILWATER; double m_DX, m_DY, m_KNOWN_X, m_KNOWN_Y, m_KNOWN_LAT, m_KNOWN_LON, m_STDLON, m_TRUELAT1, m_TRUELAT2, m_MISSING_VALUE, m_SCALE_FACTOR; CSG_String m_PROJECTION, m_UNITS, m_DESCRIPTION, m_MMINLU; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWRF_Import : public CSG_Module { public: CWRF_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: CWRF_Index m_Index; bool Load (const CSG_String &File); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWRF_Export : public CSG_Module_Grid { public: CWRF_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Export") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CWRF_Index m_Index; bool Save (const CSG_String &Directory, CSG_Parameter_Grid_List *pGrids); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__wrf_Import_H saga-2.2.3/src/modules/io/io_grid/usgs_srtm.cpp0000664000175000017500000001754512565125414022624 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: usgs_srtm.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // USGS_SRTM.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "usgs_srtm.h" /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CUSGS_SRTM_Import::CUSGS_SRTM_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import USGS SRTM Grid")); 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" " " " http://dds.cr.usgs.gov/srtm/\n" " " " http://www.jpl.nasa.gov/srtm/\n" "\nFarr, T.G., M. Kobrick (2000):\n" " 'Shuttle Radar Topography Mission produces a wealth of data',\n" " Amer. Geophys. Union Eos, v. 81, p. 583-585\n" "\nRosen, P.A., S. Hensley, I.R. Joughin, F.K. Li, S.N. Madsen, E. Rodriguez, R.M. Goldstein (2000):\n" " 'Synthetic aperture radar interferometry'\n" " Proc. IEEE, v. 88, p. 333-382\n" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, false ); Parameters.Add_FilePath( NULL , "FILE" , _TL("Files"), _TL(""), _TL("USGS SRTM Grids (*.hgt)|*.hgt|All Files|*.*"), NULL, false, false, true ); Parameters.Add_Choice( NULL , "RESOLUTION" , _TL("Resolution"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("1 arc-second"), _TL("3 arc-second") ), 1 ); } //--------------------------------------------------------- CUSGS_SRTM_Import::~CUSGS_SRTM_Import(void) {} //--------------------------------------------------------- bool CUSGS_SRTM_Import::On_Execute(void) { int N; double D; CSG_Strings fNames; CSG_Grid *pGrid; CSG_Parameter_Grid_List *pGrids; pGrids = Parameters("GRIDS")->asGridList(); pGrids ->Del_Items(); //----------------------------------------------------- switch( Parameters("RESOLUTION")->asInt() ) { default: return( false ); case 0: // 1 arcsec... N = 3601; D = 1.0 / 3600.0; break; case 1: // 3 arcsec... N = 1201; D = 3.0 / 3600.0; break; } //----------------------------------------------------- if( Parameters("FILE")->asFilePath()->Get_FilePaths(fNames) && fNames.Get_Count() > 0 ) { for(int i=0; iAdd_Item(pGrid); } } return( pGrids->Get_Count() > 0 ); } return( false ); } //--------------------------------------------------------- CSG_Grid * CUSGS_SRTM_Import::Load(CSG_String File, int N, double D) { int x, y; short *sLine; double xMin, yMin; CSG_File Stream; CSG_String fName; CSG_Grid *pGrid; //----------------------------------------------------- pGrid = NULL; fName = SG_File_Get_Name(File, false); if( fName.Length() >= 7 ) { fName .Make_Upper(); Process_Set_Text(CSG_String::Format(SG_T("%s: %s"), _TL("Importing"), fName.c_str())); yMin = (fName[0] == 'N' ? 1.0 : -1.0) * fName.Right(6).asInt(); xMin = (fName[3] == 'W' ? -1.0 : 1.0) * fName.Right(3).asInt(); //------------------------------------------------- if( Stream.Open(File, SG_FILE_R, true) ) { if( (pGrid = SG_Create_Grid(SG_DATATYPE_Short, N, N, D, xMin, yMin)) != NULL ) { pGrid->Set_Name (fName); pGrid->Get_Projection().Create(SG_T("GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]")); pGrid->Set_NoData_Value (-32768); //----------------------------------------- sLine = (short *)SG_Malloc(N * sizeof(short)); for(y=0; ySet_Value(x, N - 1 - y, sLine[x]); } } SG_Free(sLine); } } } return( pGrid ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid/xyz.h0000664000175000017500000001213112565125414021057 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: xyz.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // XYZ.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__XYZ_H #define HEADER_INCLUDED__XYZ_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CXYZ_Export : public CSG_Module_Grid { public: CXYZ_Export(void); virtual ~CXYZ_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CXYZ_Import : public CSG_Module { public: CXYZ_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: SG_Char m_Separator; bool Read_Values (CSG_File &Stream, double &x, double &y, double &z); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__XYZ_H saga-2.2.3/src/modules/io/io_grid/esri_arcinfo.cpp0000664000175000017500000004416712565125414023241 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: esri_arcinfo.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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") ) ); CSG_Parameter *pNode; pNode = Parameters.Add_Node( NULL , "NODE_ASCII" , _TL("ASCII Grid Options"), _TL("") ); Parameters.Add_Choice( pNode , "GRID_TYPE" , _TL("Target Grid Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Integer (2 byte)"), _TL("Integer (4 byte)"), _TL("Floating Point (4 byte)"), _TL("Floating Point (8 byte)") ), 2 ); Parameters.Add_Choice( pNode , "NODATA" , _TL("NoData Value"), _TL("Choose whether the input file's NoData value or a user specified NoData value is written"), CSG_String::Format(SG_T("%s|%s|"), _TL("Input File's NoData Value"), _TL("User Defined NoData Value") ), 0 ); Parameters.Add_Value( pNode , "NODATA_VAL" , _TL("User Defined NoData Value"), _TL(""), PARAMETER_TYPE_Double , -99999.0 ); } //--------------------------------------------------------- bool CESRI_ArcInfo_Import::On_Execute(void) { CSG_File Stream; CSG_String fName; CSG_Grid *pGrid; TSG_Data_Type Datatype; int iNoData; double dNoData; //----------------------------------------------------- pGrid = NULL; fName = Parameters("FILE")->asString(); iNoData = Parameters("NODATA")->asInt(); dNoData = Parameters("NODATA_VAL")->asDouble(); switch( Parameters("GRID_TYPE")->asInt() ) { case 0: Datatype = SG_DATATYPE_Short; break; case 1: Datatype = SG_DATATYPE_Int; break; case 2: default: Datatype = SG_DATATYPE_Float; break; case 3: Datatype = SG_DATATYPE_Double; break; } //------------------------------------------------- // 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; iyGet_NY() && !Stream.is_EOF() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--) { Stream.Read(Line, sizeof(float), pGrid->Get_NX()); for(int x=0; xGet_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, Datatype)) != NULL ) { double dValue; for(int iy=0, y=pGrid->Get_NY()-1; iyGet_NY() && !Stream.is_EOF() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--) { for(int x=0; xGet_NX(); x++) { dValue = Read_Value(Stream); if( iNoData == 1 && dValue == pGrid->Get_NoData_Value() ) dValue = dNoData; pGrid->Set_Value(x, y, dValue); } } if( iNoData == 1 ) { pGrid->Set_NoData_Value(dNoData); } } //------------------------------------------------- else { return( false ); } //------------------------------------------------- pGrid->Set_Name(SG_File_Get_Name(fName, false)); pGrid->Get_Projection().Load(SG_File_Make_Path(NULL, fName, SG_T("prj"))); 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.Read_Char()) ); // ignore leading white space... if( !Stream.is_EOF() && SG_is_Numeric(c) ) { do { if( c == ',' ) { c = '.'; } s += (char)c; } while( !Stream.is_EOF() && SG_is_Numeric(c = Stream.Read_Char()) ); } 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.Read_Char()) != 0x0A ) { if( c != 0x0D ) { sLine += (char)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, TSG_Data_Type Datatype) { 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(Datatype, 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; iyGet_NY() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--) { for(int x=0; xGet_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); pGrid->Get_Projection().Save(SG_File_Make_Path(NULL, fName, SG_T("prj"))); 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; iyGet_NY() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--) { for(x=0; xGet_NX(); x++) { if( x > 0 ) { fputs(" ",Stream.Get_Stream()); } fputs(Write_Value(pGrid->asDouble(x, y), Precision, bComma).b_str(),Stream.Get_Stream()); } fputs("\n", Stream.Get_Stream()); } pGrid->Get_Projection().Save(SG_File_Make_Path(NULL, fName, SG_T("prj"))); return( true ); } //----------------------------------------------------- return( false ); } //--------------------------------------------------------- inline CSG_String CESRI_ArcInfo_Export::Write_Value(double Value, int Precision, bool bComma) { 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 ); } //--------------------------------------------------------- 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); } fputs(s.b_str(),Stream.Get_Stream()); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid/srtm30.h0000664000175000017500000000775112565125414021371 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: srtm30.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // SRTM30.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Import_SRTM30_H #define HEADER_INCLUDED__Import_SRTM30_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CSRTM30_Import : public CSG_Module { public: CSRTM30_Import(void); virtual ~CSRTM30_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute(void); private: bool Tile_Load(const SG_Char *sTile, TSG_Rect &rTile, CSG_Grid *pOut, TSG_Rect &rOut); FILE * Tile_Open(const SG_Char *sTile); }; #endif // #ifndef HEADER_INCLUDED__Import_SRTM30_H saga-2.2.3/src/modules/io/io_grid/mola.cpp0000664000175000017500000002230712565125414021516 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: mola.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // MOLA.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "mola.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMOLA_Import::CMOLA_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import MOLA Grid (MEGDR)")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Import Mars Orbit Laser Altimeter (MOLA) grids of the Mars Global Surveyor (MGS) Mission " "(Topographic maps, Mission Experiment Gridded Data Records - MEGDRs). " "Find more information and obtain free data from " "" "Mars Global Surveyor: MOLA (NASA)\n\n" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("MOLA Grids (*.img)|*.img|All Files|*.*") ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Grid Type"), _TL(""), _TL("2 byte integer|4 byte floating point|"), 1 ); Parameters.Add_Choice( NULL , "ORIENT" , _TL("Orientation"), _TL(""), _TL("normal|down under|"), 1 ); } //--------------------------------------------------------- CMOLA_Import::~CMOLA_Import(void) {} //--------------------------------------------------------- bool CMOLA_Import::On_Execute(void) { bool bDown; int xa, xb, y, yy, NX, NY; short *sLine; double D, xMin, yMin; CSG_File Stream; TSG_Data_Type Type; CSG_Grid *pGrid; CSG_String fName, sName; //----------------------------------------------------- pGrid = NULL; switch( Parameters("TYPE")->asInt() ) { case 0: Type = SG_DATATYPE_Short; break; case 1: default: Type = SG_DATATYPE_Float; break; } bDown = Parameters("ORIENT")->asInt() == 1; //----------------------------------------------------- // MEGpxxnyyyrv // 012345678901 // p indicates the product type (A for areoid, C for counts, R for // radius, and T for topography) // xx is the latitude of the upper left corner of the image // n indicates whether the latitude is north (N) or south (S) // yyy is the east longitude of the upper left corner of the image // r is the map resolution using the pattern // c = 4 pixel per degree // e = 16 pixel per degree // f = 32 pixel per degree // g = 64 pixel per degree // h = 128 pixel per degree // (This convention is consistent with that used for the Mars Digital // Image Model [MDIM] archives.) // v is a letter indicating the product version. fName = SG_File_Get_Name(Parameters("FILE")->asString(), false); fName.Make_Upper(); if( fName.Length() < 12 ) { return( false ); } //----------------------------------------------------- switch( fName[3] ) { default: return( false ); case 'A': sName.Printf(SG_T("MOLA: Areoid v%c") , fName[11]); break; case 'C': sName.Printf(SG_T("MOLA: Counts v%c") , fName[11]); break; case 'R': sName.Printf(SG_T("MOLA: Radius v%c") , fName[11]); break; case 'T': sName.Printf(SG_T("MOLA: Topography v%c") , fName[11]); break; } //----------------------------------------------------- switch( fName[10] ) { default: return( false ); case 'C': // 1/4th degree... D = 1.0 / 4.0; NX = 4 * 360; NY = 4 * 180; yMin = - 90.0; xMin = -180.0; break; case 'D': // 1/8th degree... D = 1.0 / 8.0; NX = 8 * 360; NY = 8 * 180; yMin = - 90.0; xMin = -180.0; break; case 'E': // 1/16th degree... D = 1.0 / 16.0; NX = 16 * 360; NY = 16 * 180; yMin = - 90.0; xMin = -180.0; break; case 'F': // 1/32th degree... D = 1.0 / 32.0; NX = 32 * 360; NY = 32 * 180; yMin = - 90.0; xMin = -180.0; break; case 'G': // 1/64th degree... D = 1.0 / 64.0; NX = 64 * 180; NY = 64 * 90; yMin = (fName[6] == 'S' ? -1.0 : 1.0) * fName.Right(8).asInt(); yMin = bDown ? yMin - NY * D : -yMin; xMin = fName.Right(5).asInt(); if( xMin >= 180.0 ) { xMin -= 360.0; } break; case 'H': // 1/128th degree... D = 1.0 / 128.0; NX = 128 * 90; NY = 128 * 44; yMin = (fName[6] == 'S' ? -1.0 : 1.0) * fName.Right(8).asInt(); yMin = bDown ? yMin - NY * D : -yMin; xMin = fName.Right(5).asInt(); if( xMin >= 180.0 ) { xMin -= 360.0; } break; } //----------------------------------------------------- if( Stream.Open(Parameters("FILE")->asString(), SG_FILE_R, true) ) { if( (pGrid = SG_Create_Grid(Type, NX, NY, D, xMin + D / 2.0, yMin + D / 2.0)) != NULL ) { pGrid->Set_Name(sName); pGrid->Set_NoData_Value(-999999); pGrid->Get_Projection().Create(SG_T("+proj=lonlat +units=m +a=3396200.000000 +b=3376200.000000"), SG_PROJ_FMT_Proj4); //--------------------------------------------- sLine = (short *)SG_Malloc(NX * sizeof(short)); for(y=0; ySet_Value(xa, yy, sLine[xa]); } } else { for(xa=0, xb=NX/2; xbSet_Value(xa, yy, sLine[xb]); pGrid->Set_Value(xb, yy, sLine[xa]); } } } //--------------------------------------------- SG_Free(sLine); Parameters("GRID")->Set_Value(pGrid); } } return( pGrid != NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid/Makefile.in0000664000175000017500000005660112622651165022134 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/io_grid DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_grid_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libio_grid_la_OBJECTS = bmp_export.lo citygml_import.lo \ erdas_lan.lo esri_arcinfo.lo grid_table.lo \ import_clip_resample.lo MLB_Interface.lo mola.lo raw.lo \ srtm30.lo surfer.lo usgs_srtm.lo wrf.lo xyz.lo libio_grid_la_OBJECTS = $(am_libio_grid_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_grid_la_SOURCES) DIST_SOURCES = $(libio_grid_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_grid.la libio_grid_la_SOURCES = \ bmp_export.cpp\ citygml_import.cpp\ erdas_lan.cpp\ esri_arcinfo.cpp\ grid_table.cpp\ import_clip_resample.cpp\ MLB_Interface.cpp\ mola.cpp\ raw.cpp\ srtm30.cpp\ surfer.cpp\ usgs_srtm.cpp\ wrf.cpp\ xyz.cpp\ bmp_export.h\ citygml_import.h\ erdas_lan.h\ esri_arcinfo.h\ grid_table.h\ import_clip_resample.h\ MLB_Interface.h\ mola.h\ raw.h\ srtm30.h\ surfer.h\ usgs_srtm.h\ wrf.h\ xyz.h libio_grid_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) --foreign src/modules/io/io_grid/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_grid/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_grid.la: $(libio_grid_la_OBJECTS) $(libio_grid_la_DEPENDENCIES) $(EXTRA_libio_grid_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_grid_la_OBJECTS) $(libio_grid_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bmp_export.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/citygml_import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/erdas_lan.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esri_arcinfo.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_table.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/import_clip_resample.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mola.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/srtm30.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/surfer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usgs_srtm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xyz.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/io/io_grid/xyz.cpp0000664000175000017500000002503712565125414021423 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: xyz.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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 ); } //--------------------------------------------------------- CXYZ_Export::~CXYZ_Export(void) {} //--------------------------------------------------------- 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; iGet_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(); yasGrid(0)->is_NoData(x, y)) ) { Stream.Printf(SG_T("%f\t%f"), p.x, p.y); for(i=0; iGet_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; nyGet_NY() && Set_Progress(ny, pGrid->Get_NY()); ny++) { for(nx=0; nxGet_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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid/usgs_srtm.h0000664000175000017500000000757512565125414022273 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: usgs_srtm.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // USGS_SRTM.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // USGS_SRTM.h // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__USGS_SRTM_H #define HEADER_INCLUDED__USGS_SRTM_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CUSGS_SRTM_Import : public CSG_Module { public: CUSGS_SRTM_Import(void); virtual ~CUSGS_SRTM_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: CSG_Grid * Load (CSG_String fName, int N, double D); }; #endif // #ifndef HEADER_INCLUDED__USGS_SRTM_H saga-2.2.3/src/modules/io/io_grid/import_clip_resample.cpp0000664000175000017500000001527512565125414025005 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: import_clip_resample.cpp 1380 2012-04-26 12:02:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // import_clip_resample.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "import_clip_resample.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CImport_Clip_Resample::CImport_Clip_Resample(void) { //----------------------------------------------------- Set_Name (_TL("Import, Clip and Resample Grids")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILES" , _TL("Image Files"), _TL(""), CSG_String::Format("%s|*.tif;*.tiff|%s|*.*", _TL("GeoTIFF Files"), _TL("All Files") ), NULL, false, false, true ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "CLIP" , _TL("Region of Interest"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "CELLSIZE" , _TL("Target Cell Size"), _TL(""), PARAMETER_TYPE_Double, 100.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CImport_Clip_Resample::On_Execute(void) { //----------------------------------------------------- CSG_Strings Files; if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) || Files.Get_Count() == 0 ) { return( false ); } //----------------------------------------------------- CSG_Shapes *pClip = Parameters("CLIP")->asShapes(); m_System.Assign(Parameters("CELLSIZE")->asDouble(), pClip->Get_Extent()); //----------------------------------------------------- m_pGrids = Parameters("GRIDS")->asGridList(); m_pGrids->Del_Items(); for(int i=0; iGet_Count() == 0 ) { Error_Set(_TL("no grids have been imported")); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CImport_Clip_Resample::Load_File(const CSG_String &File) { CSG_Data_Manager Grids; if( !Grids.Add(File) || !Grids.Get_Grid_System(0) || !Grids.Get_Grid_System(0)->Get(0) ) { Error_Set(CSG_String::Format(SG_T("%s: %s"), _TL("could not load file"), File.c_str())); return( false ); } int n = 0; for(size_t iSystem=0; iSystemCount(); iGrid++) { CSG_Grid *pImport = (CSG_Grid *)Grids.Get_Grid_System(iSystem)->Get(iGrid); if( m_System.Get_Extent().Intersects(pImport->Get_Extent()) ) { CSG_Grid *pGrid = SG_Create_Grid(m_System, SG_DATATYPE_Float); pGrid->Assign (pImport); pGrid->Set_Name(pImport->Get_Name()); m_pGrids->Add_Item(pGrid); n++; } } } return( n > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid/erdas_lan.cpp0000664000175000017500000002367112565125414022523 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: erdas_lan.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for an Automated Geo-Scientific Analysis // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // erdas_lan.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for an Automated // // Geo-Scientific Analysis'. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "erdas_lan.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CErdas_LAN_Import::CErdas_LAN_Import(void) { //----------------------------------------------------- Set_Name (_TL("Import Erdas LAN/GIS")); Set_Author (SG_T("(c) 2005 by O.Conrad")); Set_Description (_TW( "Import Erdas LAN/GIS files. \n" "The format analysis is based on the GRASS module i.in.erdas. " "Go to the " "GRASS GIS Hompage " "for more information.\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("Erdas LAN/GIS files (*.lan, *.gis)|*.lan;*.gis|All Files|*.*"), NULL, false, false ); } //--------------------------------------------------------- CErdas_LAN_Import::~CErdas_LAN_Import(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SWAP(v) if( bSwap ) SG_Swap_Bytes(&v, sizeof(v)); //--------------------------------------------------------- bool CErdas_LAN_Import::On_Execute(void) { //----------------------------------------------------- bool bResult = false, bSwap = false; BYTE *Line, *pLine; char head[6], empty[56]; short vType, nBands, maptyp, nclass, unit; int x, y, i, nLine; long nx, ny, px, py; float area, dx, dy, xPos, yPos; double Cellsize, xMin, yMin, Value; FILE *Stream; TSG_Data_Type gType; CSG_Parameter_Grid_List *Grids; CSG_String FileName; //----------------------------------------------------- Grids = Parameters("GRIDS") ->asGridList(); FileName = Parameters("FILE") ->asString(); Grids->Del_Items(); //----------------------------------------------------- if( (Stream = fopen(FileName.b_str(), "rb")) != NULL ) { fread( head , 6, sizeof(char) , Stream); // "HEAD74" fread(&vType , 1, sizeof(short) , Stream); SWAP(vType); // 0 = 8 bit, 1 = 4 bit, 2 = 16 bit fread(&nBands , 1, sizeof(short) , Stream); SWAP(nBands); // number of bands fread( empty , 6, sizeof(char) , Stream); // empty fread(&nx , 1, sizeof(long) , Stream); SWAP(nx); // number of columns fread(&ny , 1, sizeof(long) , Stream); SWAP(ny); // number of rows fread(&px , 1, sizeof(long) , Stream); SWAP(px); // x position of top-left pixel "database location" fread(&py , 1, sizeof(long) , Stream); SWAP(py); // y position of top-left pixel "database location" fread( empty , 56, sizeof(char) , Stream); // empty fread(&maptyp , 1, sizeof(short) , Stream); SWAP(maptyp); // map projection fread(&nclass , 1, sizeof(short) , Stream); SWAP(nclass); // number of classes fread( empty , 14, sizeof(char) , Stream); // empty fread(&unit , 1, sizeof(short) , Stream); SWAP(unit); // units of area per pixel - 0 = none, 1 = acre, 2 = hectare, 3 = other fread(&area , 1, sizeof(float) , Stream); SWAP(area); // area per pixel fread(&xPos , 1, sizeof(float) , Stream); SWAP(xPos); // x coordinate of top-left pixel fread(&yPos , 1, sizeof(float) , Stream); SWAP(yPos); // y coordinate of top-left pixel fread(&dx , 1, sizeof(float) , Stream); SWAP(dx); // linear size of a pixel (feet/degrees/meters) fread(&dy , 1, sizeof(float) , Stream); SWAP(dy); // linear size of a pixel (feet/degrees/meters) //------------------------------------------------- CSG_File fWorld; if( fWorld.Open(SG_File_Make_Path(NULL, FileName, SG_T("lnw")), SG_FILE_R, false) ) { double d; CSG_String sLine; if( fWorld.Read_Line(sLine) ) { if( sLine.asDouble(d) ) dx = (float)d; } if( fWorld.Read_Line(sLine) ) { } if( fWorld.Read_Line(sLine) ) { } if( fWorld.Read_Line(sLine) ) { if( sLine.asDouble(d) ) dy = (float)d; } if( fWorld.Read_Line(sLine) ) { if( sLine.asDouble(d) ) xPos = (float)d; } if( fWorld.Read_Line(sLine) ) { if( sLine.asDouble(d) ) yPos = (float)d; } } //------------------------------------------------- if( feof(Stream) ) { Message_Add(_TL("File error")); } else if( strncmp(head, "HEAD74", sizeof(head)) ) { Message_Add(_TL("ERDAS files other than version 7.4 are not supported.")); } //------------------------------------------------- else { bResult = true; Cellsize = dx; xMin = xPos; yMin = yPos - ny * Cellsize; switch( vType ) { case 0: default: // 8 bit gType = SG_DATATYPE_Byte; nLine = nx; break; case 1: // 4 bit gType = SG_DATATYPE_Byte; nLine = nx / 2 + (nx % 2 ? 1 : 0); break; case 2: // 16 bit gType = SG_DATATYPE_Word; nLine = nx * 2; break; } Line = (BYTE *)SG_Malloc(nLine * sizeof(BYTE)); for(i=0; iAdd_Item(SG_Create_Grid(gType, nx, ny, Cellsize, xMin, yMin)); Grids->asGrid(i)->Set_Name(CSG_String::Format(SG_T("%s [%d]"), SG_File_Get_Name(FileName, false).c_str(), i + 1)); } //--------------------------------------------- for(y=0; y> 4; pLine ++; } else { Value = (*pLine & 0x11); } break; case 2: if( bSwap ) { SG_Swap_Bytes(pLine, 2); } Value = *((short *)pLine); pLine += 2; break; } Grids->asGrid(i)->Set_Value(x, ny - y - 1, Value); } } } //--------------------------------------------- SG_Free(Line); for(i=0; iasGrid(i)); DataObject_Set_Colors (Grids->asGrid(i), 100, SG_COLORS_BLACK_WHITE); } } //------------------------------------------------- fclose(Stream); } //----------------------------------------------------- return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid/bmp_export.cpp0000664000175000017500000002102512565125414022741 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: bmp_export.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for an Automated Geo-Scientific Analysis // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // bmp_export.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for an Automated // // Geo-Scientific Analysis'. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "bmp_export.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CBMP_Export::CBMP_Export(void) { //----------------------------------------------------- Set_Name (_TL("Export True Color Bitmap")); Set_Author (SG_T("(c) 2005 by O.Conrad")); Set_Description (_TW( "Export red-green-blue coded image grids to MS-Windows true color bitmaps. " "This module writes the data directly to the file and is hence particularly " "suitable for very large data sets. " )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "IMAGE" , _TL("Image Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("MS Windows Bitmap (*.bmp)|*.bmp|All Files|*.*"), NULL, true, false ); } //--------------------------------------------------------- CBMP_Export::~CBMP_Export(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SIZE_HEADER_FILE 14 #define SIZE_HEADER_BITMAP 40 #define SIZE_HEADER_TOTAL (SIZE_HEADER_FILE + SIZE_HEADER_BITMAP) //--------------------------------------------------------- bool CBMP_Export::On_Execute(void) { //----------------------------------------------------- char *Line, *pLine; int x, y, Value, nBytes_Image, nBytes_Line; FILE *Stream; CSG_Grid *pGrid; CSG_String FileName; //----------------------------------------------------- pGrid = Parameters("IMAGE") ->asGrid(); FileName = Parameters("FILE") ->asString(); //----------------------------------------------------- if( (Stream = fopen(FileName.b_str(), "wb")) != NULL ) { nBytes_Line = 3 * sizeof(BYTE) * Get_NX(); if( (Value = nBytes_Line % 4) != 0 ) // must be a multiple of DWORD size... { nBytes_Line += 4 - Value; } nBytes_Image = nBytes_Line * Get_NY(); //------------------------------------------------- Write_WORD (Stream, 0x4d42); // bfType - 0x42 = "B", 0x4d = "M"... Write_DWORD (Stream, SIZE_HEADER_TOTAL + nBytes_Image); // bfSize - size of the entire file... Write_WORD (Stream, 0); // bfReserved1 Write_WORD (Stream, 0); // bfReserved2 Write_DWORD (Stream, SIZE_HEADER_TOTAL); // bfOffBits - offset to the array of color indices... //------------------------------------------------- Write_DWORD (Stream, SIZE_HEADER_BITMAP); // biSize; Write_LONG (Stream, Get_NX()); // biWidth; Write_LONG (Stream, Get_NY()); // biHeight; Write_WORD (Stream, 1); // biPlanes; Write_WORD (Stream, 24); // biBitCount; Write_DWORD (Stream, 0); // biCompression; Write_DWORD (Stream, nBytes_Image); // biSizeImage; Write_LONG (Stream, 0); // biXPelsPerMeter; Write_LONG (Stream, 0); // biYPelsPerMeter; Write_DWORD (Stream, 2^24); // biClrUsed; Write_DWORD (Stream, 0); // biClrImportant; //------------------------------------------------- Line = (char *)SG_Calloc(nBytes_Line, sizeof(char)); for(y=0; yasInt(x, y); pLine[0] = SG_GET_B(Value); pLine[1] = SG_GET_G(Value); pLine[2] = SG_GET_R(Value); } fwrite(Line, sizeof(char), nBytes_Line, Stream); } SG_Free(Line); fclose(Stream); //------------------------------------------------- FileName = SG_File_Make_Path(SG_File_Get_Path(FileName), SG_File_Get_Name(FileName, false), SG_T("prj")); pGrid->Get_Projection().Save(FileName); //------------------------------------------------- FileName = SG_File_Make_Path(SG_File_Get_Path(FileName), SG_File_Get_Name(FileName, false), SG_T("bpw")); if( (Stream = fopen(FileName.b_str(), "w")) != NULL ) { fprintf(Stream, "%f\n%f\n%f\n%f\n%f\n%f\n", pGrid->Get_Cellsize(), 0.0, 0.0, -pGrid->Get_Cellsize(), pGrid->Get_XMin(), pGrid->Get_YMax() ); fclose(Stream); } return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CBMP_Export::Write_WORD (FILE *Stream, WORD Value) { fwrite(&Value, sizeof(Value), 1, Stream); } //--------------------------------------------------------- void CBMP_Export::Write_DWORD (FILE *Stream, DWORD Value) { fwrite(&Value, sizeof(Value), 1, Stream); } //--------------------------------------------------------- void CBMP_Export::Write_LONG (FILE *Stream, long Value) { fwrite(&Value, sizeof(Value), 1, Stream); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid/grid_table.cpp0000664000175000017500000001763412565125414022671 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_table.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Grid_Table.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_table.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Table_Import::CGrid_Table_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("Import Grid from Table")); Set_Author (SG_T("(c) 2006 by O.Conrad")); Set_Description (_TW( "Imports grid from from table.\n") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE_DATA" , _TL("Table"), _TL("") ); //----------------------------------------------------- Parameters.Add_Value( NULL , "DXY" , _TL("Cell Size"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "XMIN" , _TL("Left Border (X)"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( NULL , "YMIN" , _TL("Lower Border (Y)"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_String( NULL , "UNIT" , _TL("Unit Name"), _TL(""), _TL("") ); Parameters.Add_Value( NULL , "ZFACTOR" , _TL("Z Multiplier"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "NODATA" , _TL("No Data Value"), _TL(""), PARAMETER_TYPE_Double , -99999.0 ); Parameters.Add_Choice( NULL , "DATA_TYPE" , _TL("Data Type"), _TL(""), _TW( "1 Byte Integer (unsigned)|" "1 Byte Integer (signed)|" "2 Byte Integer (unsigned)|" "2 Byte Integer (signed)|" "4 Byte Integer (unsigned)|" "4 Byte Integer (signed)|" "4 Byte Floating Point|" "8 Byte Floating Point|") ); Parameters.Add_Choice( NULL , "TOPDOWN" , _TL("Line Order"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Bottom to Top"), _TL("Top to Bottom") ), 0 ); } //--------------------------------------------------------- CGrid_Table_Import::~CGrid_Table_Import(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Table_Import::On_Execute(void) { bool bDown; int x, y, nx, ny; double dxy, xmin, ymin, zFactor, zNoData; TSG_Data_Type data_type; CSG_String FileName, Unit; CSG_Grid *pGrid; CSG_Table Table; CSG_Table_Record *pRecord; //----------------------------------------------------- FileName = Parameters("FILE_DATA") ->asString(); dxy = Parameters("DXY") ->asDouble(); xmin = Parameters("XMIN") ->asDouble(); ymin = Parameters("YMIN") ->asDouble(); bDown = Parameters("TOPDOWN") ->asInt() == 1; Unit = Parameters("UNIT") ->asString(); zFactor = Parameters("ZFACTOR") ->asDouble(); zNoData = Parameters("NODATA") ->asDouble(); switch( Parameters("DATA_TYPE")->asInt() ) { default: data_type = SG_DATATYPE_Undefined; break; // not handled case 0: data_type = SG_DATATYPE_Byte; break; // 1 Byte Integer (unsigned) case 1: data_type = SG_DATATYPE_Char; break; // 1 Byte Integer (signed) case 2: data_type = SG_DATATYPE_Word; break; // 2 Byte Integer (unsigned) case 3: data_type = SG_DATATYPE_Short; break; // 2 Byte Integer (signed) case 4: data_type = SG_DATATYPE_DWord; break; // 4 Byte Integer (unsigned) case 5: data_type = SG_DATATYPE_Int; break; // 4 Byte Integer (signed) case 6: data_type = SG_DATATYPE_Float; break; // 4 Byte Floating Point case 7: data_type = SG_DATATYPE_Double; break; // 8 Byte Floating Point } //----------------------------------------------------- if( Table.Create(FileName) && (nx = Table.Get_Field_Count()) > 0 && (ny = Table.Get_Record_Count()) > 0 ) { pGrid = SG_Create_Grid(data_type, nx, ny, dxy, xmin, ymin); for(y=0; ySet_Value(x, y, pRecord->asDouble(x)); } } pGrid->Set_Unit (Unit); pGrid->Set_Scaling (zFactor); pGrid->Set_NoData_Value (zNoData); pGrid->Set_Name (SG_File_Get_Name(FileName, false)); Parameters("GRID")->Set_Value(pGrid); return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_grid/raw.h0000664000175000017500000001133612565125414021024 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: raw.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Raw.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Raw_Import_H #define HEADER_INCLUDED__Raw_Import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CRaw_Import : public CSG_Module { public: CRaw_Import(void); virtual ~CRaw_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: CSG_Grid * Load_Data (FILE *Stream, TSG_Data_Type data_type, int nx, int ny, double dxy, double xmin, double ymin, int data_head, int line_head, int line_tail, bool bDown, bool bBig); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Raw_Import_H saga-2.2.3/src/modules/io/io_grid/mola.h0000664000175000017500000000745612565125414021173 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: mola.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // MOLA.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // MOLA.h // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__MOLA_Import_H #define HEADER_INCLUDED__MOLA_Import_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CMOLA_Import : public CSG_Module { public: CMOLA_Import(void); virtual ~CMOLA_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute(void); private: }; #endif // #ifndef HEADER_INCLUDED__MOLA_Import_H saga-2.2.3/src/modules/io/io_grid/MLB_Interface.cpp0000664000175000017500000001314112565125414023154 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Grids") ); case MLB_INFO_Category: return( _TL("Import/Export") ); 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 gridded data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Grid") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "esri_arcinfo.h" #include "surfer.h" #include "raw.h" #include "xyz.h" #include "usgs_srtm.h" #include "mola.h" #include "srtm30.h" #include "bmp_export.h" #include "erdas_lan.h" #include "grid_table.h" #include "wrf.h" #include "citygml_import.h" #include "import_clip_resample.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0 : return( new CESRI_ArcInfo_Export ); case 1 : return( new CESRI_ArcInfo_Import ); case 2 : return( new CSurfer_Export ); case 3 : return( new CSurfer_Import ); case 4 : return( new CRaw_Import ); case 5 : return( new CXYZ_Export ); case 6 : return( new CXYZ_Import ); case 7 : return( new CUSGS_SRTM_Import ); case 8 : return( new CMOLA_Import ); case 9 : return( new CSRTM30_Import ); case 10: return( new CBMP_Export ); case 11: return( new CErdas_LAN_Import ); case 12: return( new CGrid_Table_Import ); case 13: return( new CWRF_Import ); case 14: return( new CWRF_Export ); case 15: return( new CCityGML_Import ); case 16: return( new CImport_Clip_Resample ); //----------------------------------------------------- case 17: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/io/io_grid/erdas_lan.h0000664000175000017500000001062412565125414022162 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: erdas_lan.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for an Automated Geo-Scientific Analysis // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // erdas_lan.h // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for an Automated // // Geo-Scientific Analysis'. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__erdas_lan_H #define HEADER_INCLUDED__erdas_lan_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CErdas_LAN_Import : public CSG_Module { public: CErdas_LAN_Import(void); virtual ~CErdas_LAN_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__erdas_lan_H saga-2.2.3/src/modules/io/io_grid/Makefile.am0000664000175000017500000000163012565125414022112 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_grid.la libio_grid_la_SOURCES =\ bmp_export.cpp\ citygml_import.cpp\ erdas_lan.cpp\ esri_arcinfo.cpp\ grid_table.cpp\ import_clip_resample.cpp\ MLB_Interface.cpp\ mola.cpp\ raw.cpp\ srtm30.cpp\ surfer.cpp\ usgs_srtm.cpp\ wrf.cpp\ xyz.cpp\ bmp_export.h\ citygml_import.h\ erdas_lan.h\ esri_arcinfo.h\ grid_table.h\ import_clip_resample.h\ MLB_Interface.h\ mola.h\ raw.h\ srtm30.h\ surfer.h\ usgs_srtm.h\ wrf.h\ xyz.h libio_grid_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/io/io_grid/MLB_Interface.h0000664000175000017500000000766512565125414022637 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_grid_H #define HEADER_INCLUDED__io_grid_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_grid_EXPORTS #define io_grid_EXPORT _SAGA_DLL_EXPORT #else #define io_grid_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_grid_H saga-2.2.3/src/modules/io/io_grid/citygml_import.h0000664000175000017500000001252412565125414023275 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: citygml_import.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_grid // // // //-------------------------------------------------------// // // // citygml_import.h // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__citygml_import_H #define HEADER_INCLUDED__citygml_import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCityGML_Import : public CSG_Module { public: ////// public members and functions: ////////////// CCityGML_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute (void); private: ///// private members and functions: ///////////// bool Get_Buildings (const CSG_String &File, CSG_Shapes *pPolygons, bool bParts); bool Get_Buildings (const CSG_String &File, CSG_Shapes *pPolygons); bool Add_Buildings (CSG_Shapes *pBuildings, CSG_Shapes *pAdd); bool Has_BuildingParts (const CSG_MetaData &GML); bool Add_BuildingParts (const CSG_MetaData &GML, CSG_MetaData &GML_Parts); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__citygml_import_H saga-2.2.3/src/modules/io/io_grid/citygml_import.cpp0000664000175000017500000002675712565125414023645 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: citygml_import.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_grid // // // //-------------------------------------------------------// // // // citygml_import.cpp // // // // Copyright (C) 2014 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "citygml_import.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCityGML_Import::CCityGML_Import(void) { //----------------------------------------------------- Set_Name (_TL("Import Building Sketches from CityGML")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "This tool facilitates the import of building sketches using a CityGML based file format, " "that is commonly used by German land surveying offices and geoinformation distributors. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "BUILDINGS" , _TL("Buildings"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_FilePath( NULL , "FILES" , _TL("Files"), _TL(""), CSG_String::Format(SG_T("%s|*.xml|%s|*.*"), _TL("XML Files (*.xml)"), _TL("All Files") ), NULL, false, false, true ); Parameters.Add_Value( NULL , "PARTS" , _TL("Check for Building Parts"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCityGML_Import::On_Execute(void) { CSG_Strings Files; if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) ) { return( false ); } CSG_Shapes Buildings(SHAPE_TYPE_Polygon), *pBuildings = Parameters("BUILDINGS")->asShapes(); for(int i=0; iGet_Count() <= 0 ) { Get_Buildings(Files[i], pBuildings, Parameters("PARTS")->asBool()); } else if( Get_Buildings(Files[i], &Buildings, Parameters("PARTS")->asBool()) ) { Add_Buildings(pBuildings, &Buildings); CSG_String Description(pBuildings->Get_Description()); Description += "\n"; Description += Buildings.Get_Name(); pBuildings->Set_Description(Description); } } return( pBuildings->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCityGML_Import::Get_Buildings(const CSG_String &File, CSG_Shapes *pBuildings, bool bParts) { //----------------------------------------------------- if( !Get_Buildings(File, pBuildings) ) { Error_Set(_TL("CityGML file import failed")); return( false ); } if( bParts == false ) { return( true ); } //----------------------------------------------------- // 1. check for building parts Process_Set_Text(CSG_String::Format(SG_T("%s: %s"), _TL("loading building parts"), SG_File_Get_Name(File, true).c_str())); CSG_MetaData GML, GML_Parts; if( !GML.Create(File) ) { Error_Set(_TL("loading failed")); return( false ); } GML_Parts.Assign(GML, false); bParts = false; for(int i=0; iGet(0) ) { Error_Set(CSG_String::Format(SG_T("%s: %s"), _TL("CityGML import failed"), File.c_str())); return( false ); } //----------------------------------------------------- // convert line strings to polygons Process_Set_Text(_TL("polygon conversion")); CSG_Module *pModule; if( !(pModule = SG_Get_Module_Library_Manager().Get_Module(SG_T("shapes_polygons"), 3)) ) // Convert Lines to Polygons { Error_Set(_TL("could not locate line string to polygon conversion tool")); return( false ); } CSG_Parameters P; P.Assign(pModule->Get_Parameters()); pModule->Set_Manager(NULL); bool bResult = pModule->Get_Parameters()->Set_Parameter("POLYGONS", pPolygons) && pModule->Get_Parameters()->Set_Parameter("LINES" , (CSG_Shapes *)tmpMgr.Get_Shapes()->Get(0)) && pModule->Get_Parameters()->Set_Parameter("MERGE" , true) && pModule->Execute(); pModule->Get_Parameters()->Assign_Values(&P); pModule->Set_Manager(P.Get_Manager()); pPolygons->Set_Name(SG_File_Get_Name(File, false)); //----------------------------------------------------- return( bResult ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCityGML_Import::Add_Buildings(CSG_Shapes *pBuildings, CSG_Shapes *pAdd) { int i, j, *Index = (int *)SG_Malloc(pBuildings->Get_Field_Count() * sizeof(int)); for(i=0; iGet_Field_Count(); i++) { CSG_String Name(pBuildings->Get_Field_Name(i)); Index[i] = -1; for(j=0; Index[i]<0 && jGet_Field_Count(); j++) { if( !Name.CmpNoCase(pAdd->Get_Field_Name(j)) ) { Index[i] = j; } } } for(i=0; iGet_Count(); i++) { CSG_Shape *pPart = pAdd->Get_Shape(i); CSG_Shape *pPolygon = pBuildings->Add_Shape(pPart, SHAPE_COPY_GEOM); for(j=0; jGet_Field_Count(); j++) { if( Index[j] >= 0 ) { *pPolygon->Get_Value(j) = *pPart->Get_Value(Index[j]); } } } SG_Free(Index); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCityGML_Import::Has_BuildingParts(const CSG_MetaData &GML) { return( GML.Get_Name().CmpNoCase("core:cityObjectMember") == 0 && GML.Get_Children_Count() == 1 && GML[0].Get_Name().CmpNoCase("bldg:Building") == 0 && GML[0].Get_Child("bldg:consistsOfBuildingPart") != NULL ); } //--------------------------------------------------------- bool CCityGML_Import::Add_BuildingParts(const CSG_MetaData &GML, CSG_MetaData &GML_Parts) { if( GML.Get_Name().CmpNoCase("bldg:Building") ) { return( false ); } int i; CSG_MetaData head; for(i=0; iAdd_Child(GML[i][0], false); pBuilding->Set_Name("bldg:Building"); pBuilding->Add_Children(head); pBuilding->Add_Children(GML[i][0]); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gdal/0000775000175000017500000000000012634325743020044 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_gdal/gdal_export.h0000664000175000017500000001002112614213770022511 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_export.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_export.h // // // // Copyright (C) 2007 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_export_H #define HEADER_INCLUDED__gdal_export_H //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_gdal_EXPORT CGDAL_Export : public CSG_Module_Grid { public: CGDAL_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid|Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_export_H saga-2.2.3/src/modules/io/io_gdal/gdal_driver.cpp0000664000175000017500000006733012614213770023035 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_driver.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_driver.cpp // // // // Copyright (C) 2007 by O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_driver.h" #include #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_GDAL_Drivers gSG_GDAL_Drivers; const CSG_GDAL_Drivers & SG_Get_GDAL_Drivers (void) { return( gSG_GDAL_Drivers ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_GDAL_Drivers::CSG_GDAL_Drivers(void) { GDALAllRegister(); // affects Windows only, might be appropriate for applications // that treat filenames as being in the local encoding. // for more info see: http://trac.osgeo.org/gdal/wiki/ConfigOptions CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO"); m_pDrivers = GetGDALDriverManager(); } //--------------------------------------------------------- CSG_GDAL_Drivers::~CSG_GDAL_Drivers(void) { GDALDestroyDriverManager(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CSG_GDAL_Drivers::Get_Version(void) const { return( GDALVersionInfo("RELEASE_NAME") ); } //--------------------------------------------------------- int CSG_GDAL_Drivers::Get_Count(void) const { return( m_pDrivers->GetDriverCount() ); } //--------------------------------------------------------- GDALDriver * CSG_GDAL_Drivers::Get_Driver(const CSG_String &Name) const { return( (GDALDriver *)GDALGetDriverByName(Name) ); } //--------------------------------------------------------- GDALDriver * CSG_GDAL_Drivers::Get_Driver(int Index) const { return( (GDALDriver *)GDALGetDriver(Index) ); } //--------------------------------------------------------- CSG_String CSG_GDAL_Drivers::Get_Name(int Index) const { return( Get_Driver(Index)->GetMetadataItem(GDAL_DMD_LONGNAME) ); } //--------------------------------------------------------- CSG_String CSG_GDAL_Drivers::Get_Description(int Index) const { return( Get_Driver(Index)->GetDescription() ); } //--------------------------------------------------------- CSG_String CSG_GDAL_Drivers::Get_Extension(int Index) const { return( Get_Driver(Index)->GetMetadataItem(GDAL_DMD_EXTENSION) ); } //--------------------------------------------------------- bool CSG_GDAL_Drivers::Can_Read(int Index) const { return( Index >= 0 && Index < Get_Count() ); // ? CSLFetchBoolean(Get_Driver(Index)->GetMetadata(), GDAL_DCAP_CREATE, false) != 0 : false ); } //--------------------------------------------------------- bool CSG_GDAL_Drivers::Can_Write(int Index) const { return( Index >= 0 && Index < Get_Count() ? CSLFetchBoolean(Get_Driver(Index)->GetMetadata(), GDAL_DCAP_CREATE, false) != 0 : false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSG_GDAL_Drivers::Get_GDAL_Type(TSG_Data_Type Type) { switch( Type ) { case SG_DATATYPE_Bit: return( GDT_Byte ); // Eight bit unsigned integer case SG_DATATYPE_Byte: return( GDT_Byte ); // Eight bit unsigned integer case SG_DATATYPE_Char: return( GDT_Byte ); // Eight bit unsigned integer case SG_DATATYPE_Word: return( GDT_UInt16 ); // Sixteen bit unsigned integer case SG_DATATYPE_Short: return( GDT_Int16 ); // Sixteen bit signed integer case SG_DATATYPE_DWord: return( GDT_UInt32 ); // Thirty two bit unsigned integer case SG_DATATYPE_Int: return( GDT_Int32 ); // Thirty two bit signed integer case SG_DATATYPE_Float: return( GDT_Float32 ); // Thirty two bit floating point case SG_DATATYPE_Double: return( GDT_Float64 ); // Sixty four bit floating point default: return( GDT_Float64 ); } } //--------------------------------------------------------- TSG_Data_Type CSG_GDAL_Drivers::Get_SAGA_Type(int Type) { switch( Type ) { case GDT_Byte: return( SG_DATATYPE_Byte ); // Eight bit unsigned integer case GDT_UInt16: return( SG_DATATYPE_Word ); // Sixteen bit unsigned integer case GDT_Int16: return( SG_DATATYPE_Short ); // Sixteen bit signed integer case GDT_UInt32: return( SG_DATATYPE_DWord ); // Thirty two bit unsigned integer case GDT_Int32: return( SG_DATATYPE_Int ); // Thirty two bit signed integer case GDT_Float32: return( SG_DATATYPE_Float ); // Thirty two bit floating point case GDT_Float64: return( SG_DATATYPE_Double ); // Sixty four bit floating point case GDT_CInt16: return( SG_DATATYPE_Undefined ); // Complex Int16 case GDT_CInt32: return( SG_DATATYPE_Undefined ); // Complex Int32 case GDT_CFloat32: return( SG_DATATYPE_Undefined ); // Complex Float32 case GDT_CFloat64: return( SG_DATATYPE_Undefined ); // Complex Float64 default: return( SG_DATATYPE_Undefined ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_GDAL_DataSet::CSG_GDAL_DataSet(void) { m_pDataSet = NULL; m_TF_A.Create(2); m_TF_B.Create(2, 2); } //--------------------------------------------------------- CSG_GDAL_DataSet::CSG_GDAL_DataSet(const CSG_String &File_Name) { m_pDataSet = NULL; m_TF_A.Create(2); m_TF_B.Create(2, 2); Open_Read(File_Name); } //--------------------------------------------------------- CSG_GDAL_DataSet::~CSG_GDAL_DataSet(void) { Close(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_GDAL_DataSet::Open_Read(const CSG_String &File_Name) { Close(); if( (m_pDataSet = (GDALDataset *)GDALOpen(File_Name, GA_ReadOnly)) == NULL ) { return( false ); } //----------------------------------------------------- double Transform[6]; m_File_Name = File_Name; m_Access = SG_GDAL_IO_READ; m_NX = m_pDataSet->GetRasterXSize(); m_NY = m_pDataSet->GetRasterYSize(); 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.0; m_yMin = 0.0; } 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 ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Open_Write(const CSG_String &File_Name, const CSG_String &Driver, const CSG_String &Options, TSG_Data_Type Type, int NBands, const CSG_Grid_System &System, const CSG_Projection &Projection) { Close(); //-------------------------------------------------------- char **pOptions = NULL; if( !Options.is_Empty() ) { char **pTokens = CSLTokenizeString2(Options, " ", CSLT_STRIPLEADSPACES); for(int i=0; pTokens && pTokens[i]; i++) { pOptions = CSLAddString(pOptions, pTokens[i]); } } //-------------------------------------------------------- GDALDriver *pDriver; if( (pDriver = gSG_GDAL_Drivers.Get_Driver(Driver)) == NULL ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("%s: %s"), _TL("driver not found."), Driver.c_str())); return( false ); } if( !GDALValidateCreationOptions(pDriver, pOptions) ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("%s: %s"), _TL("Creation option(s) not supported by the driver"), Options.c_str())); return( false ); } if( CSLFetchBoolean(pDriver->GetMetadata(), GDAL_DCAP_CREATE, false) == false ) { SG_UI_Msg_Add_Error(_TL("Driver does not support file creation.")); return( false ); } if( (m_pDataSet = pDriver->Create(File_Name, System.Get_NX(), System.Get_NY(), NBands, (GDALDataType)gSG_GDAL_Drivers.Get_GDAL_Type(Type), pOptions)) == NULL ) { SG_UI_Msg_Add_Error(_TL("Could not create dataset.")); return( false ); } //-------------------------------------------------------- m_File_Name = File_Name; m_Access = SG_GDAL_IO_WRITE; if( Projection.is_Okay() ) { m_pDataSet->SetProjection(Projection.Get_WKT()); } double Transform[6] = { System.Get_XMin() - 0.5 * System.Get_Cellsize(), System.Get_Cellsize(), 0.0, System.Get_YMax() + 0.5 * System.Get_Cellsize(), 0.0, -System.Get_Cellsize() }; m_pDataSet->SetGeoTransform(Transform); m_NX = m_pDataSet->GetRasterXSize(); m_NY = m_pDataSet->GetRasterYSize(); m_bTransform = false; m_Cellsize = 1.0; m_xMin = 0.5; m_yMin = 0.5; return( true ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Close(void) { if( m_pDataSet ) { GDALClose(m_pDataSet); m_pDataSet = NULL; } m_File_Name.Clear(); m_Access = SG_GDAL_IO_CLOSED; if( strlen(CPLGetLastErrorMsg()) > 3 ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("%s: %s"), _TL("Dataset creation failed"), SG_STR_MBTOSG(CPLGetLastErrorMsg()))); CPLErrorReset(); return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- GDALDriver * CSG_GDAL_DataSet::Get_Driver(void) const { return( m_pDataSet ? m_pDataSet->GetDriver() : NULL ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_DriverID(void) const { return( m_pDataSet && m_pDataSet->GetDriver() && m_pDataSet->GetDriver()->GetDescription() ? m_pDataSet->GetDriver()->GetDescription() : "" ); } //--------------------------------------------------------- const char * CSG_GDAL_DataSet::Get_Projection(void) const { return( m_pDataSet && m_pDataSet->GetProjectionRef() ? m_pDataSet->GetProjectionRef() : "" ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_Name(void) const { return( m_pDataSet ? m_pDataSet->GetMetadataItem(GDAL_DMD_LONGNAME) : "" ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_Description(void) const { return( m_pDataSet ? m_pDataSet->GetDescription() : "" ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_File_Name(void) const { return( m_File_Name ); } //--------------------------------------------------------- const char * CSG_GDAL_DataSet::Get_MetaData_Item(const char *pszName, const char *pszDomain) const { return( m_pDataSet ? m_pDataSet->GetMetadataItem(pszName, pszDomain) : "" ); } //--------------------------------------------------------- const char ** CSG_GDAL_DataSet::Get_MetaData(const char *pszDomain) const { return( m_pDataSet ? (const char **)m_pDataSet->GetMetadata(pszDomain) : NULL ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_MetaData_Item(CSG_String &MetaData, const char *pszName, const char *pszDomain) const { const char *Item = Get_MetaData_Item(pszName, pszDomain); if( Item && *Item ) { MetaData = Item; return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_MetaData(CSG_MetaData &MetaData) const { if( m_pDataSet && is_Reading() ) { char **pMetaData = m_pDataSet->GetMetadata() + 0; if( pMetaData ) { while( *pMetaData ) { CSG_String s(*pMetaData); MetaData.Add_Child(s.BeforeFirst(SG_T('=')), s.AfterFirst(SG_T('='))); pMetaData++; } return( true ); } } return( false ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_MetaData(CSG_MetaData &MetaData, const char *pszDomain) const { if( m_pDataSet && is_Reading() ) { char **pMetaData = m_pDataSet->GetMetadata(pszDomain) + 0; if( pMetaData ) { while( *pMetaData ) { CSG_String s(*pMetaData); MetaData.Add_Child(s.BeforeFirst(SG_T('=')), s.AfterFirst(SG_T('='))); pMetaData++; } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSG_GDAL_DataSet::Get_Count(void) const { return( m_pDataSet ? m_pDataSet->GetRasterCount() : 0 ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_Name(int i) const { CSG_String Name; GDALRasterBand *pBand; if( is_Reading() && (pBand = m_pDataSet->GetRasterBand(i + 1)) != NULL ) { const char *s; //------------------------------------------------- if( !SG_STR_CMP(m_pDataSet->GetDriver()->GetDescription(), "GRIB") ) { if( (s = pBand->GetMetadataItem("GRIB_COMMENT")) != NULL && *s ) { Name = s; if( (s = pBand->GetMetadataItem("GRIB_ELEMENT" )) != NULL && *s ) { Name += "["; Name += s; Name += "]"; } if( (s = pBand->GetMetadataItem("GRIB_SHORT_NAME")) != NULL && *s ) { Name += "["; Name += s; Name += "]"; } if( (s = pBand->GetMetadataItem("GRIB_VALID_TIME")) != NULL && *s ) { Name += CSG_String::Format(SG_T("[%s]"), CSG_Time_Converter::Get_String(atoi(s), SG_TIME_FMT_Seconds_Unix).c_str()); } } } //------------------------------------------------- if( !SG_STR_CMP(m_pDataSet->GetDriver()->GetDescription(), "netCDF") ) { if( (s = pBand->GetMetadataItem("NETCDF_VARNAME" )) != NULL && *s ) { Name += "["; Name += s; Name += "]"; } if( (s = pBand->GetMetadataItem("NETCDF_DIMENSION_time" )) != NULL && *s ) { Name += "["; Name += s; Name += "]"; } if( (s = pBand->GetMetadataItem("NETCDF_DIMENSION_level")) != NULL && *s ) { Name += "["; Name += s; Name += "]"; } } //------------------------------------------------- if( Name.is_Empty() ) { Name = Get_Name(); if( Name.is_Empty() ) { Name = _TL("Band"); } Name += CSG_String::Format(SG_T(" %0*d"), SG_Get_Digit_Count(Get_Count() + 1), i + 1); } } return( Name ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_Description(int i) const { CSG_String Description; GDALRasterBand *pBand; if( is_Reading() && (pBand = m_pDataSet->GetRasterBand(i + 1)) != NULL ) { char **pMetaData = pBand->GetMetadata() + 0; if( pMetaData ) { while( *pMetaData ) { CSG_String s(*pMetaData); Description += s + SG_T("\n"); pMetaData++; } } } return( Description ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_MetaData(int i, CSG_MetaData &MetaData) const { GDALRasterBand *pBand; if( is_Reading() && (pBand = m_pDataSet->GetRasterBand(i + 1)) != NULL ) { char **pMetaData = pBand->GetMetadata() + 0; if( pMetaData ) { while( *pMetaData ) { CSG_String s(*pMetaData); MetaData.Add_Child(s.BeforeFirst(SG_T('=')), s.AfterFirst(SG_T('='))); pMetaData++; } return( true ); } } return( false ); } //--------------------------------------------------------- const char * CSG_GDAL_DataSet::Get_MetaData_Item(int i, const char *pszName) const { GDALRasterBand *pBand = m_pDataSet->GetRasterBand(i + 1); return( pBand ? pBand->GetMetadataItem(pszName) : "" ); } bool CSG_GDAL_DataSet::Get_MetaData_Item(int i, const char *pszName, CSG_String &MetaData) const { GDALRasterBand *pBand; if( (pBand = m_pDataSet->GetRasterBand(i + 1)) != NULL ) { const char *pMetaData = pBand->GetMetadataItem(pszName); if( pMetaData && *pMetaData ) { MetaData = pMetaData; return( true ); } } return( false ); } //--------------------------------------------------------- CSG_Grid * CSG_GDAL_DataSet::Read(int i) { //------------------------------------------------- if( !is_Reading() ) { return( NULL ); } //------------------------------------------------- GDALRasterBand *pBand = m_pDataSet->GetRasterBand(i + 1); if( !pBand ) { return( NULL ); } //------------------------------------------------- TSG_Data_Type Type = gSG_GDAL_Drivers.Get_SAGA_Type(pBand->GetRasterDataType()); CSG_Grid *pGrid = SG_Create_Grid(Type, Get_NX(), Get_NY(), Get_Cellsize(), Get_xMin(), Get_yMin()); if( !pGrid ) { return( NULL ); } //------------------------------------------------- int bSuccess; double zScale = pBand->GetScale (&bSuccess); if( !bSuccess || !zScale ) zScale = 1.0; double zOffset = pBand->GetOffset(&bSuccess); if( !bSuccess ) zOffset = 0.0; pGrid->Set_Name (Get_Name (i)); pGrid->Set_Description (Get_Description(i)); pGrid->Set_Unit (CSG_String(pBand->GetUnitType())); pGrid->Set_Scaling (zScale, zOffset); pBand->GetNoDataValue(&bSuccess); if( bSuccess ) { pGrid->Set_NoData_Value(pBand->GetNoDataValue(&bSuccess)); } pGrid->Get_Projection().Create(Get_Projection(), SG_PROJ_FMT_WKT); Get_MetaData(i, pGrid->Get_MetaData()); //------------------------------------------------- double *zLine = (double *)SG_Malloc(Get_NX() * sizeof(double)); for(int y=0; yRasterIO(GF_Read, 0, y, Get_NX(), 1, zLine, Get_NX(), 1, GDT_Float64, 0, 0) == CE_None ) { for(int x=0; xSet_NoData(x, yy); else pGrid->Set_Value(x, yy, zLine[x], false); } } } SG_Free(zLine); return( pGrid ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Write(int i, CSG_Grid *pGrid, double noDataValue) { if( !m_pDataSet || !pGrid || pGrid->Get_NX() != Get_NX() || pGrid->Get_NY() != Get_NY() || i < 0 || i >= Get_Count() ) { return( false ); } GDALRasterBand *pBand = m_pDataSet->GetRasterBand(i + 1); //----------------------------------------------------- CPLErr Error = CE_None; double *zLine = (double *)SG_Malloc(Get_NX() * sizeof(double)); for(int y=0, yy=Get_NY()-1; Error==CE_None && yis_NoData(x, yy) ? noDataValue : pGrid->asDouble(x, yy); } Error = pBand->RasterIO(GF_Write, 0, y, Get_NX(), 1, zLine, Get_NX(), 1, GDT_Float64, 0, 0); } SG_Free(zLine); //----------------------------------------------------- if( Error != CE_None ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("%s"), _TL("Writing dataset failed."))); return( false ); } //----------------------------------------------------- pBand->SetNoDataValue (noDataValue); pBand->SetStatistics (pGrid->Get_ZMin(), pGrid->Get_ZMax(), pGrid->Get_Mean(), pGrid->Get_StdDev()); return( true ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Write(int i, CSG_Grid *pGrid) { return (CSG_GDAL_DataSet::Write (i, pGrid, pGrid->Get_NoData_Value())); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Rect CSG_GDAL_DataSet::Get_Extent(bool bTransform) const { if( bTransform && Needs_Transformation() ) { CSG_Grid_System System; if( Get_Transformation(System, false) ) { return( System.Get_Extent() ); } } return( CSG_Rect(Get_xMin(), Get_yMin(), Get_xMax(), Get_yMax()) ); } //--------------------------------------------------------- CSG_Grid_System CSG_GDAL_DataSet::Get_System(void) const { CSG_Grid_System System; if( !Needs_Transformation() || !Get_Transformation(System, false) ) { System.Assign(Get_Cellsize(), Get_xMin(), Get_yMin(), Get_NX(), Get_NY()); } return( System ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_Transformation(CSG_Grid_System &System, bool bVerbose) const { CSG_Vector A; CSG_Matrix B; Get_Transformation(A, B); //----------------------------------------------------- if( Needs_Transformation() ) { CSG_Vector v(2); CSG_Rect r; v[0] = Get_xMin() + 0.5; v[1] = Get_yMin() + 0.5; v = B * v + A; r.Assign(v[0], v[1], v[0], v[1]); v[0] = Get_xMin() + 0.5; v[1] = Get_yMax() - 0.5; v = B * v + A; r.Union(CSG_Point(v[0], v[1])); v[0] = Get_xMax() - 0.5; v[1] = Get_yMax() - 0.5; v = B * v + A; r.Union(CSG_Point(v[0], v[1])); v[0] = Get_xMax() - 0.5; v[1] = Get_yMin() + 0.5; v = B * v + A; r.Union(CSG_Point(v[0], v[1])); v[0] = 1; v[1] = 0; v = B * v; double dx = v.Get_Length(); v[0] = 0; v[1] = 1; v = B * v; double dy = v.Get_Length(); if( dx != dy ) { if( bVerbose ) { SG_UI_Msg_Add_Execution(CSG_String::Format("\n%s: %s\n\t%s: %f", _TL("warning"), _TL("top-to-bottom and left-to-right cell sizes differ."), _TL("Difference"), fabs(dy - dx)), false ); } if( dx > dy ) { dx = dy; } if( bVerbose ) { SG_UI_Msg_Add_Execution(CSG_String::Format("\n\t%s: %f\n", _TL("using cellsize"), dx), false); } } return( System.Assign(dx, r) ); } //----------------------------------------------------- return( false ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_Transformation(CSG_Grid **ppGrid, TSG_Grid_Interpolation Interpolation, bool bVerbose) const { CSG_Grid_System System; if( Get_Transformation(System, bVerbose) ) { return( Get_Transformation(ppGrid, Interpolation, System, bVerbose) ); } return( false ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_Transformation(CSG_Grid **ppGrid, TSG_Grid_Interpolation Interpolation, const CSG_Grid_System &System, bool bVerbose) const { if( !System.is_Valid() ) { return( false ); } //----------------------------------------------------- CSG_Vector A; CSG_Matrix B, BInv; Get_Transformation(A, B); BInv = B.Get_Inverse(); //----------------------------------------------------- CSG_Grid *pImage = *ppGrid; CSG_Grid *pWorld = SG_Create_Grid(System, pImage->Get_Type()); if( !pWorld ) { return( false ); } *ppGrid = pWorld; pWorld->Set_Name (pImage->Get_Name ()); pWorld->Set_Description (pImage->Get_Description ()); pWorld->Set_Unit (pImage->Get_Unit ()); pWorld->Set_Scaling (pImage->Get_Scaling (), pImage->Get_Offset()); pWorld->Set_NoData_Value_Range(pImage->Get_NoData_Value(), pImage->Get_NoData_hiValue()); pWorld->Get_MetaData() = pImage->Get_MetaData (); pWorld->Get_Projection() = pImage->Get_Projection (); //----------------------------------------------------- // #pragma omp parallel for // for(int y=0; yGet_NY(); y++) // { // Process_Get_Okay(); for(int y=0; yGet_NY() && SG_UI_Process_Set_Progress(y, pWorld->Get_NY()); y++) { #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double z; CSG_Vector vWorld(2), vImage; vWorld[0] = pWorld->Get_XMin() + (x - 0.5) * pWorld->Get_Cellsize(); vWorld[1] = pWorld->Get_YMin() + (y + 0.5) * pWorld->Get_Cellsize(); vImage = BInv * (vWorld - A); if( pImage->Get_Value(vImage[0], vImage[1], z, Interpolation, false, true) ) { pWorld->Set_Value(x, y, z); } else { pWorld->Set_NoData(x, y); } } } delete(pImage); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- TSG_Data_Type SG_Get_Grid_Type (CSG_Parameter_Grid_List *pGrids) { TSG_Data_Type Type = SG_DATATYPE_Byte; if( pGrids ) { for(int i=0; iGet_Count(); i++) { if( SG_Data_Type_Get_Size(Type) <= SG_Data_Type_Get_Size(pGrids->asGrid(i)->Get_Type()) ) { Type = pGrids->asGrid(i)->Get_Type(); } } } return( Type ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gdal/gdal_export_geotiff.h0000664000175000017500000001006112614213770024220 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_export_geotiff.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_export_geotiff.h // // // // Copyright (C) 2007 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_export_geotiff_H #define HEADER_INCLUDED__gdal_export_geotiff_H //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGDAL_Export_GeoTIFF : public CSG_Module_Grid { public: CGDAL_Export_GeoTIFF(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid|Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_export_geotiff_H saga-2.2.3/src/modules/io/io_gdal/ogr_driver.h0000664000175000017500000001675312565125414022367 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_driver.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_driver.h // // // // Copyright (C) 2008 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ogr_driver_H #define HEADER_INCLUDED__ogr_driver_H //--------------------------------------------------------- #include "MLB_Interface.h" #include #if defined(GDAL_VERSION_MAJOR) && GDAL_VERSION_MAJOR == 2 #define USE_GDAL_V2 #endif //--------------------------------------------------------- typedef enum ESG_Geom_Type_Choice_Key { AUTOMATIC = 0, WKBPOINT, WKBPOINT25D, WKBMULTIPOINT, WKBMULTIPOINT25D, WKBLINESTRING, WKBLINESTRING25D, WKBMULTILINESTRING, WKBMULTILINESTRING25D, WKBPOLYGON, WKBPOLYGON25D, WKBMULTIPOLYGON, WKBMULTIPOLYGON25D, WKBGEOMETRYCOLLECTION, WKBGEOMETRYCOLLECTION25D, GEOM_TYPE_KEY_Count } TSG_Geom_Type_Choice_Key; //--------------------------------------------------------- const SG_Char gSG_Geom_Type_Choice_Key_Name[GEOM_TYPE_KEY_Count][32] = { SG_T("automatic"), SG_T("wkbPoint"), SG_T("wkbPoint25D"), SG_T("wkbMultiPoint"), SG_T("wkbMultiPoint25D"), SG_T("wkbLineString"), SG_T("wkbLineString25D"), SG_T("wkbMultiLineString"), SG_T("wkbMultiLineString25D"), SG_T("wkbPolygon"), SG_T("wkbPolygon25D"), SG_T("wkbMultiPolygon"), SG_T("wkbMultiPolygon25D"), SG_T("wkbGeometryCollection"), SG_T("wkbGeometryCollection25D") }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_gdal_EXPORT CSG_OGR_Drivers { public: CSG_OGR_Drivers(void); virtual ~CSG_OGR_Drivers(void); int Get_Count (void) const; #ifdef USE_GDAL_V2 class GDALDriver * Get_Driver (const CSG_String &Name) const; class GDALDriver * Get_Driver (int Index) const; #else class OGRSFDriver * Get_Driver (const CSG_String &Name) const; class OGRSFDriver * Get_Driver (int Index) const; #endif CSG_String Get_Name (int Index) const; CSG_String Get_Description (int Index) const; bool Can_Read (int Index) const; bool Can_Write (int Index) const; static TSG_Vertex_Type Get_Vertex_Type (int Type); static TSG_Shape_Type Get_Shape_Type (int Type); static int Get_Shape_Type (TSG_Shape_Type Type, bool bZ); static TSG_Data_Type Get_Data_Type (int Type); static int Get_Data_Type (TSG_Data_Type Type); private: #ifdef USE_GDAL_V2 class GDALDriverManager *m_pDrivers; #else class OGRSFDriverRegistrar *m_pDrivers; #endif }; //--------------------------------------------------------- io_gdal_EXPORT const CSG_OGR_Drivers & SG_Get_OGR_Drivers (void); /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_gdal_EXPORT CSG_OGR_DataSource { public: CSG_OGR_DataSource(void); CSG_OGR_DataSource(const CSG_String &File); CSG_OGR_DataSource(const CSG_String &File, const CSG_String &DriverName); virtual ~CSG_OGR_DataSource(void); bool Create (const CSG_String &File); bool Create (const CSG_String &File, const CSG_String &DriverName); bool Destroy (void); int Get_Count (void); class OGRLayer * Get_Layer (int iLayer); TSG_Shape_Type Get_Type (int iLayer); TSG_Vertex_Type Get_Coordinate_Type (int iLayer); CSG_Projection Get_Projection (int iLayer); CSG_Shapes * Read (int iLayer, int iGeomTypeChoice); bool Write (CSG_Shapes *pShapes, const CSG_String &DriverName); private: #ifdef USE_GDAL_V2 class GDALDataset *m_pDataSource; #else class OGRDataSource *m_pDataSource; #endif int _Get_GeomType_Choice(int iGeomTypeChoice); bool _Read_Geometry (CSG_Shape *pShape, class OGRGeometry *pGeometry); bool _Read_Line (CSG_Shape *pShape, class OGRLineString *pLine); bool _Read_Polygon (CSG_Shape *pShape, class OGRPolygon *pPolygon); bool _Write_Geometry (CSG_Shape *pShape, class OGRFeature *pFeature, bool bZ); bool _Write_Line (CSG_Shape *pShape, class OGRLineString *pLine, int iPart, bool bZ); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ogr_driver_H saga-2.2.3/src/modules/io/io_gdal/ogr_export_kml.h0000664000175000017500000001001712614213770023241 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_export_kml.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_export_kml.h // // // // Copyright (C) 2012 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ogr_export_kml_H #define HEADER_INCLUDED__ogr_export_kml_H //--------------------------------------------------------- #include "ogr_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class COGR_Export_KML : public CSG_Module { public: COGR_Export_KML(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Shapes|Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ogr_export_kml_H saga-2.2.3/src/modules/io/io_gdal/gdal_import_netcdf.h0000664000175000017500000001116012614213770024032 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_import_netcdf.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_import_netcdf.h // // // // Copyright (C) 2012 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_import_netcdf_H #define HEADER_INCLUDED__gdal_import_netcdf_H //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_gdal_EXPORT CGDAL_Import_NetCDF : public CSG_Module { public: CGDAL_Import_NetCDF(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid|Import") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool m_bSaveFile; CSG_String m_SavePath; CSG_Parameter_Grid_List *m_pGrids; bool Load (CSG_GDAL_DataSet &DataSet, const CSG_String &Description); const char * Get_Variable (CSG_GDAL_DataSet &DataSet, int iBand); const char * Get_Time (CSG_GDAL_DataSet &DataSet, int iBand); const char * Get_Level (CSG_GDAL_DataSet &DataSet, int iBand); CSG_String Get_Time_String (const CSG_String &Time, int Format); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_import_netcdf_H saga-2.2.3/src/modules/io/io_gdal/gdal_export.cpp0000664000175000017500000002033712614213770023057 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_export.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_export.cpp // // // // Copyright (C) 2007 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_export.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Export::CGDAL_Export(void) { Set_Name (_TL("Export Raster")); Set_Author ("O.Conrad (c) 2007"); CSG_String Description, Formats; Description = _TW( "The \"GDAL Raster Export\" module exports one or more grids to various file formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format(SG_T("\nGDAL %s:%s\n\n"), _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str()); Description += _TW( "Following raster formats are currently supported:\n" "\n" ); for(int i=0; i\n"), SG_Get_GDAL_Drivers().Get_Description(i).c_str(), SG_Get_GDAL_Drivers().Get_Name (i).c_str() ); Formats += CSG_String::Format(SG_T("{%s}%s|"), SG_Get_GDAL_Drivers().Get_Description(i).c_str(), SG_Get_GDAL_Drivers().Get_Name (i).c_str() ); } } Description += SG_T("
    IDName
    %s%s
    "); Set_Description(Description); //----------------------------------------------------- Parameters.Add_Grid_List( NULL, "GRIDS" , _TL("Grid(s)"), _TL("The SAGA grids to be exported."), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL, "FILE" , _TL("File"), _TL("The GDAL dataset to be created."), NULL, NULL, true ); Parameters.Add_Choice( NULL, "FORMAT" , _TL("Format"), _TL("The GDAL raster format (driver) to be used."), Formats ); Parameters.Add_Choice( NULL, "TYPE" , _TL("Data Type"), _TL("The GDAL datatype of the created dataset."), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("match input data"), _TL("8 bit unsigned integer"), _TL("16 bit unsigned integer"), _TL("16 bit signed integer"), _TL("32 bit unsigned integer"), _TL("32 bit signed integer"), _TL("32 bit floating point"), _TL("64 bit floating point") ), 0 ); Parameters.Add_Value( NULL, "SET_NODATA" , _TL("Set Custom NoData"), _TL(""), PARAMETER_TYPE_Bool, 0.0 ); Parameters.Add_Value( NULL, "NODATA" , _TL("NoData Value"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_String( NULL, "OPTIONS" , _TL("Creation Options"), _TL("A space separated list of key-value pairs (K=V)."), _TL("") ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Export::On_Execute(void) { TSG_Data_Type Type; CSG_String File_Name, Driver, Options; CSG_Projection Projection; CSG_Parameter_Grid_List *pGrids; CSG_GDAL_DataSet DataSet; //----------------------------------------------------- pGrids = Parameters("GRIDS") ->asGridList(); File_Name = Parameters("FILE") ->asString(); Options = Parameters("OPTIONS") ->asString(); Get_Projection(Projection); //----------------------------------------------------- switch( Parameters("TYPE")->asInt() ) { default: case 0: Type = SG_Get_Grid_Type(pGrids); break; // match input data case 1: Type = SG_DATATYPE_Byte; break; // Eight bit unsigned integer case 2: Type = SG_DATATYPE_Word; break; // Sixteen bit unsigned integer case 3: Type = SG_DATATYPE_Short; break; // Sixteen bit signed integer case 4: Type = SG_DATATYPE_DWord; break; // Thirty two bit unsigned integer case 5: Type = SG_DATATYPE_Int; break; // Thirty two bit signed integer case 6: Type = SG_DATATYPE_Float; break; // Thirty two bit floating point case 7: Type = SG_DATATYPE_Double; break; // Sixty four bit floating point } //----------------------------------------------------- if( !Parameters("FORMAT")->asChoice()->Get_Data(Driver) ) { return( false ); } //----------------------------------------------------- if( !DataSet.Open_Write(File_Name, Driver, Options, Type, pGrids->Get_Count(), *Get_System(), Projection) ) { return( false ); } //----------------------------------------------------- for(int i=0; iGet_Count(); i++) { Process_Set_Text(CSG_String::Format(SG_T("%s %d"), _TL("Band"), i + 1)); if ( Parameters("SET_NODATA")->asBool() ) { DataSet.Write(i, pGrids->asGrid(i), Parameters("NODATA")->asDouble()); } else { DataSet.Write(i, pGrids->asGrid(i)); } } if( !DataSet.Close() ) { return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gdal/ogr_driver.cpp0000664000175000017500000006547612565125414022730 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_driver.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_driver.cpp // // // // Copyright (C) 2008 by O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ogr_driver.h" #include #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_OGR_Drivers gSG_OGR_Drivers; const CSG_OGR_Drivers & SG_Get_OGR_Drivers (void) { return( gSG_OGR_Drivers ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifdef USE_GDAL_V2 CSG_OGR_Drivers::CSG_OGR_Drivers(void) { GDALAllRegister(); m_pDrivers = GetGDALDriverManager(); } #else CSG_OGR_Drivers::CSG_OGR_Drivers(void) { OGRRegisterAll(); m_pDrivers = OGRSFDriverRegistrar::GetRegistrar(); } #endif //--------------------------------------------------------- CSG_OGR_Drivers::~CSG_OGR_Drivers(void) { // OGRCleanupAll(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSG_OGR_Drivers::Get_Count(void) const { return( m_pDrivers->GetDriverCount() ); } #ifdef USE_GDAL_V2 //--------------------------------------------------------- GDALDriver * CSG_OGR_Drivers::Get_Driver(int Index) const { return( m_pDrivers->GetDriver(Index) ); } GDALDriver * CSG_OGR_Drivers::Get_Driver(const CSG_String &Name) const { return( m_pDrivers ? m_pDrivers->GetDriverByName(Name) : NULL ); } //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Name(int Index) const { return( m_pDrivers->GetDriver(Index)->GetMetadataItem(GDAL_DMD_LONGNAME) ); } //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Description(int Index) const { return( m_pDrivers->GetDriver(Index)->GetDescription() ); } #else //--------------------------------------------------------- OGRSFDriver * CSG_OGR_Drivers::Get_Driver(int Index) const { return( m_pDrivers->GetDriver(Index) ); } OGRSFDriver * CSG_OGR_Drivers::Get_Driver(const CSG_String &Name) const { return( m_pDrivers ? m_pDrivers->GetDriverByName(Name) : NULL ); } //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Name(int Index) const { return( m_pDrivers->GetDriver(Index)->GetName() ); } //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Description(int Index) const { OGRSFDriver *pDriver = m_pDrivers->GetDriver(Index); CSG_String s; s += pDriver->TestCapability(ODrCCreateDataSource) ? SG_T("\n[x] ") : SG_T("\n[ ] "); s += _TL("create data source"); s += pDriver->TestCapability(ODrCDeleteDataSource) ? SG_T("\n[x] ") : SG_T("\n[ ] "); s += _TL("delete data source"); /* s += pDriver->TestCapability(ODsCCreateLayer) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("create layer"); s += pDriver->TestCapability(ODsCDeleteLayer) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("delete layer"); s += pDriver->TestCapability(OLCDeleteFeature) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("delete feature"); s += pDriver->TestCapability(OLCRandomRead) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("random read"); s += pDriver->TestCapability(OLCRandomWrite) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("random write"); s += pDriver->TestCapability(OLCSequentialWrite) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("sequential write"); /**/ return( s ); } #endif //--------------------------------------------------------- bool CSG_OGR_Drivers::Can_Read(int Index) const { return( Get_Driver(Index) != NULL ); } //--------------------------------------------------------- bool CSG_OGR_Drivers::Can_Write(int Index) const { return( Get_Driver(Index) != NULL );//&& Get_Driver(Index)->TestCapability(ODrCCreateDataSource) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- TSG_Vertex_Type CSG_OGR_Drivers::Get_Vertex_Type(int Type) { switch( Type ) { case wkbPoint25D: // 2.5D extension as per 99-402 case wkbMultiPoint25D: // 2.5D extension as per 99-402 case wkbLineString25D: // 2.5D extension as per 99-402 case wkbMultiLineString25D: // 2.5D extension as per 99-402 case wkbPolygon25D: // 2.5D extension as per 99-402 case wkbMultiPolygon25D: // 2.5D extension as per 99-402 case wkbGeometryCollection25D: // 2.5D extension as per 99-402 return( SG_VERTEX_TYPE_XYZ ); default: return( SG_VERTEX_TYPE_XY ); } } //--------------------------------------------------------- TSG_Shape_Type CSG_OGR_Drivers::Get_Shape_Type(int Type) { switch( Type ) { case wkbPoint: // 0-dimensional geometric object, standard WKB case wkbPoint25D: // 2.5D extension as per 99-402 return( SHAPE_TYPE_Point ); case wkbMultiPoint: // GeometryCollection of Points, standard WKB case wkbMultiPoint25D: // 2.5D extension as per 99-402 return( SHAPE_TYPE_Points ); case wkbLineString: // 1-dimensional geometric object with linear interpolation between Points, standard WKB case wkbMultiLineString: // GeometryCollection of LineStrings, standard WKB case wkbLineString25D: // 2.5D extension as per 99-402 case wkbMultiLineString25D: // 2.5D extension as per 99-402 return( SHAPE_TYPE_Line ); case wkbPolygon: // planar 2-dimensional geometric object defined by 1 exterior boundary and 0 or more interior boundaries, standard WKB case wkbMultiPolygon: // GeometryCollection of Polygons, standard WKB case wkbPolygon25D: // 2.5D extension as per 99-402 case wkbMultiPolygon25D: // 2.5D extension as per 99-402 return( SHAPE_TYPE_Polygon ); default: case wkbUnknown: // unknown type, non-standard case wkbNone: // non-standard, for pure attribute records case wkbLinearRing: // non-standard, just for createGeometry() case wkbGeometryCollection: // geometric object that is a collection of 1 or more geometric objects, standard WKB case wkbGeometryCollection25D: // 2.5D extension as per 99-402 return( SHAPE_TYPE_Undefined ); } } //--------------------------------------------------------- int CSG_OGR_Drivers::Get_Shape_Type(TSG_Shape_Type Type, bool bZ) { switch( Type ) { case SHAPE_TYPE_Point: return( bZ ? wkbPoint25D : wkbPoint ); // point case SHAPE_TYPE_Points: return( bZ ? wkbMultiPoint25D : wkbMultiPoint ); // points case SHAPE_TYPE_Line: return( bZ ? wkbMultiLineString25D : wkbMultiLineString ); // line case SHAPE_TYPE_Polygon: return( bZ ? wkbMultiPolygon25D : wkbMultiPolygon ); // polygon default: return( wkbUnknown ); } } //--------------------------------------------------------- TSG_Data_Type CSG_OGR_Drivers::Get_Data_Type(int Type) { switch( Type ) { case OFTInteger: // Simple 32bit integer return( SG_DATATYPE_Int ); case OFTReal: // Double Precision floating point return( SG_DATATYPE_Double ); case OFTString: // String of ASCII chars return( SG_DATATYPE_String ); case OFTDateTime: // Date and Time return( SG_DATATYPE_Date ); default: case OFTIntegerList: // List of 32bit integers case OFTRealList: // List of doubles case OFTStringList: // Array of strings case OFTWideString: // deprecated case OFTWideStringList: // deprecated case OFTBinary: // Raw Binary data case OFTDate: // Date case OFTTime: // Time return( SG_DATATYPE_String ); } } //--------------------------------------------------------- int CSG_OGR_Drivers::Get_Data_Type(TSG_Data_Type Type) { switch( Type ) { default: case SG_DATATYPE_String: case SG_DATATYPE_Date: return( OFTString ); 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_Color: return( OFTInteger ); case SG_DATATYPE_Float: case SG_DATATYPE_Double: return( OFTReal ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_OGR_DataSource::CSG_OGR_DataSource(void) { m_pDataSource = NULL; } CSG_OGR_DataSource::CSG_OGR_DataSource(const CSG_String &File) { m_pDataSource = NULL; Create(File); } //--------------------------------------------------------- CSG_OGR_DataSource::~CSG_OGR_DataSource(void) { Destroy(); } #ifdef USE_GDAL_V2 //--------------------------------------------------------- bool CSG_OGR_DataSource::Create(const CSG_String &File) { Destroy(); m_pDataSource = (GDALDataset *)GDALOpenEx(File, GDAL_OF_VECTOR, NULL, NULL, NULL); return( m_pDataSource != NULL ); } bool CSG_OGR_DataSource::Create(const CSG_String &File, const CSG_String &DriverName) { GDALDriver *pDriver; Destroy(); if( (pDriver = gSG_OGR_Drivers.Get_Driver(DriverName)) != NULL ) { m_pDataSource = pDriver->Create(File, 0, 0, 0, GDT_Unknown, NULL); } return( m_pDataSource != NULL ); } //--------------------------------------------------------- bool CSG_OGR_DataSource::Destroy(void) { if( m_pDataSource ) { GDALClose(m_pDataSource); m_pDataSource = NULL; } return( true ); } #else //--------------------------------------------------------- bool CSG_OGR_DataSource::Create(const CSG_String &File) { Destroy(); m_pDataSource = OGRSFDriverRegistrar::Open(File); return( m_pDataSource != NULL ); } bool CSG_OGR_DataSource::Create(const CSG_String &File, const CSG_String &DriverName) { OGRSFDriver *pDriver; Destroy(); if( (pDriver = gSG_OGR_Drivers.Get_Driver(DriverName)) != NULL ) { m_pDataSource = pDriver->CreateDataSource(File, NULL); } return( m_pDataSource != NULL ); } //--------------------------------------------------------- bool CSG_OGR_DataSource::Destroy(void) { if( m_pDataSource ) { OGRDataSource::DestroyDataSource(m_pDataSource); m_pDataSource = NULL; } return( true ); } #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSG_OGR_DataSource::Get_Count(void) { if( m_pDataSource ) { return( m_pDataSource->GetLayerCount() ); } return( 0 ); } //--------------------------------------------------------- OGRLayer * CSG_OGR_DataSource::Get_Layer(int iLayer) { if( m_pDataSource && iLayer >= 0 && iLayer < m_pDataSource->GetLayerCount() ) { return( m_pDataSource->GetLayer(iLayer) ); } return( NULL ); } //--------------------------------------------------------- TSG_Shape_Type CSG_OGR_DataSource::Get_Type(int iLayer) { if( Get_Layer(iLayer) ) { return( CSG_OGR_Drivers::Get_Shape_Type(Get_Layer(iLayer)->GetLayerDefn()->GetGeomType()) ); } return( SHAPE_TYPE_Undefined ); } //--------------------------------------------------------- TSG_Vertex_Type CSG_OGR_DataSource::Get_Coordinate_Type(int iLayer) { if( Get_Layer(iLayer) ) { return( CSG_OGR_Drivers::Get_Vertex_Type(Get_Layer(iLayer)->GetLayerDefn()->GetGeomType()) ); } return( SG_VERTEX_TYPE_XY ); } //--------------------------------------------------------- CSG_Projection CSG_OGR_DataSource::Get_Projection(int iLayer) { CSG_Projection Projection; if( Get_Layer(iLayer) && Get_Layer(iLayer)->GetSpatialRef() ) { char *p = NULL; //------------------------------------------------- if( !Projection.is_Okay() && Get_Layer(iLayer)->GetSpatialRef()->exportToWkt (&p) == OGRERR_NONE && p && *p ) { Projection.Create(p, SG_PROJ_FMT_WKT); } if( p ) { OGRFree(p); p = NULL; } //------------------------------------------------- if( !Projection.is_Okay() && Get_Layer(iLayer)->GetSpatialRef()->exportToProj4(&p) == OGRERR_NONE && p && *p ) { Projection.Create(p, SG_PROJ_FMT_Proj4); } if( p ) { OGRFree(p); p = NULL; } } return( Projection ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shapes * CSG_OGR_DataSource::Read(int iLayer, int iGeomTypeChoice) { //----------------------------------------------------- OGRLayer *pLayer = Get_Layer(iLayer); if( !pLayer ) { return( NULL ); } if( iGeomTypeChoice != 0 ) { pLayer->GetLayerDefn()->SetGeomType((OGRwkbGeometryType)_Get_GeomType_Choice(iGeomTypeChoice)); } if( Get_Type(iLayer) == SHAPE_TYPE_Undefined ) { return( NULL ); } //----------------------------------------------------- OGRFeatureDefn *pDef = pLayer->GetLayerDefn(); CSG_Shapes *pShapes = SG_Create_Shapes(Get_Type(iLayer), CSG_String(pDef->GetName()), NULL, Get_Coordinate_Type(iLayer)); pShapes->Get_Projection() = Get_Projection(iLayer); //----------------------------------------------------- int iField; for(iField=0; iFieldGetFieldCount(); iField++) { OGRFieldDefn *pDefField = pDef->GetFieldDefn(iField); pShapes->Add_Field(pDefField->GetNameRef(), CSG_OGR_Drivers::Get_Data_Type(pDefField->GetType())); } //----------------------------------------------------- OGRFeature *pFeature; pLayer->ResetReading(); while( (pFeature = pLayer->GetNextFeature()) != NULL && SG_UI_Process_Get_Okay(false) ) { OGRGeometry *pGeometry = pFeature->GetGeometryRef(); if( pGeometry != NULL ) { CSG_Shape *pShape = pShapes->Add_Shape(); for(iField=0; iFieldGetFieldCount(); iField++) { OGRFieldDefn *pDefField = pDef->GetFieldDefn(iField); switch( pDefField->GetType() ) { default: pShape->Set_Value(iField, pFeature->GetFieldAsString (iField)); break; case OFTString: pShape->Set_Value(iField, pFeature->GetFieldAsString (iField)); break; case OFTInteger: pShape->Set_Value(iField, pFeature->GetFieldAsInteger(iField)); break; case OFTReal: pShape->Set_Value(iField, pFeature->GetFieldAsDouble (iField)); break; } } //--------------------------------------------- if( _Read_Geometry(pShape, pGeometry) == false ) { pShapes->Del_Shape(pShape); } } OGRFeature::DestroyFeature(pFeature); } return( pShapes ); } //--------------------------------------------------------- int CSG_OGR_DataSource::_Get_GeomType_Choice(int iGeomTypeChoice) { switch( iGeomTypeChoice ) { default: case AUTOMATIC: return( wkbUnknown ); case WKBPOINT: return( wkbPoint ); case WKBPOINT25D: return( wkbPoint25D ); case WKBMULTIPOINT: return( wkbMultiPoint ); case WKBMULTIPOINT25D: return( wkbMultiPoint25D ); case WKBLINESTRING: return( wkbLineString ); case WKBLINESTRING25D: return( wkbLineString25D ); case WKBMULTILINESTRING: return( wkbMultiLineString ); case WKBMULTILINESTRING25D: return( wkbMultiLineString25D ); case WKBPOLYGON: return( wkbPolygon ); case WKBPOLYGON25D: return( wkbPolygon25D ); case WKBMULTIPOLYGON: return( wkbMultiPolygon ); case WKBMULTIPOLYGON25D: return( wkbMultiPolygon25D ); case WKBGEOMETRYCOLLECTION: return( wkbGeometryCollection ); case WKBGEOMETRYCOLLECTION25D: return( wkbGeometryCollection25D ); } } //--------------------------------------------------------- bool CSG_OGR_DataSource::_Read_Geometry(CSG_Shape *pShape, OGRGeometry *pGeometry) { if( pShape && pGeometry ) { switch( pGeometry->getGeometryType() ) { //------------------------------------------------- case wkbPoint: // 0-dimensional geometric object, standard WKB case wkbPoint25D: // 2.5D extension as per 99-402 pShape->Add_Point(((OGRPoint *)pGeometry)->getX(), ((OGRPoint *)pGeometry)->getY()); pShape->Set_Z(((OGRPoint *)pGeometry)->getZ(), 0); return( true ); //------------------------------------------------- case wkbLineString: // 1-dimensional geometric object with linear interpolation between Points, standard WKB case wkbLineString25D: // 2.5D extension as per 99-402 return( _Read_Line(pShape, (OGRLineString *)pGeometry) ); //------------------------------------------------- case wkbPolygon: // planar 2-dimensional geometric object defined by 1 exterior boundary and 0 or more interior boundaries, standard WKB case wkbPolygon25D: // 2.5D extension as per 99-402 return( _Read_Polygon(pShape, (OGRPolygon *)pGeometry) ); //------------------------------------------------- case wkbMultiPoint: // GeometryCollection of Points, standard WKB case wkbMultiPoint25D: // 2.5D extension as per 99-402 case wkbMultiLineString: // GeometryCollection of LineStrings, standard WKB case wkbMultiLineString25D: // 2.5D extension as per 99-402 case wkbMultiPolygon: // GeometryCollection of Polygons, standard WKB case wkbMultiPolygon25D: // 2.5D extension as per 99-402 { for(int i=0; i<((OGRGeometryCollection *)pGeometry)->getNumGeometries(); i++) { if( _Read_Geometry(pShape, ((OGRGeometryCollection *)pGeometry)->getGeometryRef(i)) == false ) { return( false ); } } } return( true ); //------------------------------------------------- default: break; } } return( false ); } //--------------------------------------------------------- bool CSG_OGR_DataSource::_Read_Line(CSG_Shape *pShape, OGRLineString *pLine) { if( pShape && pLine && pLine->getNumPoints() > 0 ) { int iPart = pShape->Get_Part_Count(); for(int iPoint=0; iPointgetNumPoints(); iPoint++) { pShape->Add_Point(pLine->getX(iPoint), pLine->getY(iPoint), iPart); pShape->Set_Z(pLine->getZ(iPoint), iPoint, iPart); } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_OGR_DataSource::_Read_Polygon(CSG_Shape *pShape, OGRPolygon *pPolygon) { if( pShape && pPolygon ) { _Read_Line(pShape, pPolygon->getExteriorRing()); for(int i=0; igetNumInteriorRings(); i++) { pPolygon->getInteriorRing(i); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_OGR_DataSource::Write(CSG_Shapes *pShapes, const CSG_String &DriverName) { if( !m_pDataSource || !pShapes || !pShapes->is_Valid() ) { return( false ); } //----------------------------------------------------- OGRSpatialReference *pSRS = NULL; if( pShapes->Get_Projection().is_Okay() ) { pSRS = new OGRSpatialReference(pShapes->Get_Projection().Get_WKT()); // pSRS = new OGRSpatialReference(); // pSRS ->importFromProj4(pShapes->Get_Projection().Get_Proj4()); } OGRLayer *pLayer = m_pDataSource->CreateLayer(CSG_String(pShapes->Get_Name()), pSRS, (OGRwkbGeometryType)gSG_OGR_Drivers.Get_Shape_Type(pShapes->Get_Type(), pShapes->Get_Vertex_Type() != SG_VERTEX_TYPE_XY) ); if( !pLayer ) { return( false ); } //------------------------------------------------- if( SG_STR_CMP(DriverName, "DXF") ) { // the dxf driver does not support arbitrary field creation and returns OGRERR_FAILURE; // it seems like there is no method in OGR to check whether a driver supports field creation or not; // another issue with the dxf driver: 3D polygon data is not supported (would require e.g. "3DFACE" // entity implementation in GDAL/OGR), so we would need to treat them as polylines (not implemented, // currently it is necessary to convert to a line shapefile a priori) for(int iField=0; iFieldGet_Field_Count(); iField++) { OGRFieldDefn DefField(CSG_String(pShapes->Get_Field_Name(iField)), (OGRFieldType)gSG_OGR_Drivers.Get_Data_Type(pShapes->Get_Field_Type(iField))); if( pLayer->CreateField(&DefField) != OGRERR_NONE ) { return( false ); } } } //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && SG_UI_Process_Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); OGRFeature *pFeature = OGRFeature::CreateFeature(pLayer->GetLayerDefn()); if( _Write_Geometry(pShape, pFeature, pShapes->Get_Vertex_Type() != SG_VERTEX_TYPE_XY) ) { // no need for a special treatment of DXF here, as pFeature->SetField() just silently ignores iFields out of range for(int iField=0; iFieldGet_Field_Count(); iField++) { switch( pShapes->Get_Field_Type(iField) ) { default: case SG_DATATYPE_Char: case SG_DATATYPE_String: case SG_DATATYPE_Date: pFeature->SetField(iField, CSG_String(pShape->asString(iField))); break; case SG_DATATYPE_Short: case SG_DATATYPE_Int: case SG_DATATYPE_Long: case SG_DATATYPE_Color: pFeature->SetField(iField, pShape->asInt(iField)); break; case SG_DATATYPE_Float: case SG_DATATYPE_Double: pFeature->SetField(iField, pShape->asDouble(iField)); break; } } pLayer->CreateFeature(pFeature); } OGRFeature::DestroyFeature(pFeature); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CSG_OGR_DataSource::_Write_Geometry(CSG_Shape *pShape, OGRFeature *pFeature, bool bZ) { if( !pShape || !pFeature ) { return( false ); } switch( pShape->Get_Type() ) { //----------------------------------------------------- case SHAPE_TYPE_Point: { TSG_Point p = pShape->Get_Point(0); OGRPoint Point(p.x, p.y, pShape->Get_Z(0)); return( pFeature->SetGeometry(&Point) == OGRERR_NONE ); } //----------------------------------------------------- case SHAPE_TYPE_Points: { OGRMultiPoint Points; for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); OGRPoint Point(p.x, p.y, pShape->Get_Z(0)); Points.addGeometry(&Point); } } return( pFeature->SetGeometry(&Points) == OGRERR_NONE ); } //----------------------------------------------------- case SHAPE_TYPE_Line: if( pShape->Get_Part_Count() == 1 ) { OGRLineString Line; _Write_Line(pShape, &Line, 0, bZ); return( pFeature->SetGeometry(&Line) == OGRERR_NONE ); } else { OGRMultiLineString Lines; for(int iPart=0; iPartGet_Part_Count(); iPart++) { OGRLineString Line; if( _Write_Line(pShape, &Line, iPart, bZ) ) { Lines.addGeometry(&Line); } } return( pFeature->SetGeometry(&Lines) == OGRERR_NONE ); } //----------------------------------------------------- case SHAPE_TYPE_Polygon: { OGRPolygon Polygon; for(int iPart=0; iPartGet_Part_Count(); iPart++) { OGRLinearRing Ring; if( _Write_Line(pShape, &Ring, iPart, bZ) ) { Polygon.addRing(&Ring); } } return( pFeature->SetGeometry(&Polygon) == OGRERR_NONE ); } //------------------------------------------------- default: return( false ); } } //--------------------------------------------------------- bool CSG_OGR_DataSource::_Write_Line(CSG_Shape *pShape, OGRLineString *pLine, int iPart, bool bZ) { if( pLine && pShape && iPart >= 0 && iPart < pShape->Get_Part_Count() ) { pLine->empty(); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); pLine->addPoint(p.x, p.y, pShape->Get_Z(iPoint, iPart)); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gdal/ogr_import.h0000664000175000017500000001040312614213770022366 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_import.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_import.h // // // // Copyright (C) 2008 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ogr_import_H #define HEADER_INCLUDED__ogr_import_H //--------------------------------------------------------- #include "ogr_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class COGR_Import : public CSG_Module { public: COGR_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Shapes|Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- io_gdal_EXPORT bool SG_OGR_Import (const CSG_String &File_Name); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ogr_import_H saga-2.2.3/src/modules/io/io_gdal/ogr_import.cpp0000664000175000017500000001620212614213770022724 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_import.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_import.cpp // // // // Copyright (C) 2008 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ogr_import.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- COGR_Import::COGR_Import(void) { Set_Name (_TL("Import Shapes")); Set_Author ("O.Conrad (c) 2008"); CSG_String Description; Description = _TW( "The \"OGR Vector Data Import\" module imports vector data from various file/database formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" "\n" "Following vector data formats are currently supported:\n" "\n" ); for(int i=0; i\n"), SG_Get_OGR_Drivers().Get_Name(i).c_str(), SG_Get_OGR_Drivers().Get_Description(i).c_str() ); } } Description += SG_T("
    NameDescription
    %s%s
    "); Set_Description(Description); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL, "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_FilePath( NULL, "FILES" , _TL("Files"), _TL(""), NULL, NULL, false, false, true ); CSG_String sChoices; for(int i=0; iasFilePath()->Get_FilePaths(Files) ) { return( false ); } //----------------------------------------------------- Parameters("SHAPES")->asShapesList()->Del_Items(); for(int iFile=0; iFileasInt()); if( pShapes ) { Parameters("SHAPES")->asShapesList()->Add_Item(pShapes); } } } } return( Parameters("SHAPES")->asShapesList()->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool SG_OGR_Import (const CSG_String &File_Name) { COGR_Import Import; if( !Import.Get_Parameters()->Set_Parameter(SG_T("FILES"), File_Name, PARAMETER_TYPE_FilePath) ) { return( false ); } if( !Import.Execute() ) { return( false ); } CSG_Parameter_Shapes_List *pShapes = Import.Get_Parameters()->Get_Parameter(SG_T("SHAPES"))->asShapesList(); for(int i=0; iGet_Count(); i++) { SG_UI_DataObject_Add(pShapes->asShapes(i), SG_UI_DATAOBJECT_UPDATE_ONLY); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gdal/Makefile.in0000664000175000017500000005644212622651165022121 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/io_gdal DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_gdal_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libio_gdal_la_OBJECTS = gdal_catalogue.lo gdal_driver.lo \ gdal_export.lo gdal_export_geotiff.lo gdal_import.lo \ gdal_import_netcdf.lo MLB_Interface.lo ogr_driver.lo \ ogr_export.lo ogr_export_kml.lo ogr_import.lo libio_gdal_la_OBJECTS = $(am_libio_gdal_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_gdal_la_SOURCES) DIST_SOURCES = $(libio_gdal_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1465 2012-08-23 09:20:00Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @SAGA_UNICODE_TRUE@UC_DEFS = -D_SAGA_UNICODE 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) pkglib_LTLIBRARIES = libio_gdal.la libio_gdal_la_SOURCES = \ gdal_catalogue.cpp\ gdal_driver.cpp\ gdal_export.cpp\ gdal_export_geotiff.cpp\ gdal_import.cpp\ gdal_import_netcdf.cpp\ MLB_Interface.cpp\ ogr_driver.cpp\ ogr_export.cpp\ ogr_export_kml.cpp\ ogr_import.cpp\ gdal_catalogue.h\ gdal_driver.h\ gdal_export.h\ gdal_export_geotiff.h\ gdal_import.h\ gdal_import_netcdf.h\ MLB_Interface.h\ ogr_driver.h\ ogr_export.h\ ogr_export_kml.h\ ogr_import.h libio_gdal_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) --foreign src/modules/io/io_gdal/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_gdal/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_gdal.la: $(libio_gdal_la_OBJECTS) $(libio_gdal_la_DEPENDENCIES) $(EXTRA_libio_gdal_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_gdal_la_OBJECTS) $(libio_gdal_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_catalogue.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_driver.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_export.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_export_geotiff.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_import_netcdf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ogr_driver.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ogr_export.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ogr_export_kml.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ogr_import.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/io/io_gdal/ogr_export.h0000664000175000017500000000776712614213770022420 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_export.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_export.h // // // // Copyright (C) 2008 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ogr_export_H #define HEADER_INCLUDED__ogr_export_H //--------------------------------------------------------- #include "ogr_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class COGR_Export : public CSG_Module { public: COGR_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Shapes|Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ogr_export_H saga-2.2.3/src/modules/io/io_gdal/ogr_export_kml.cpp0000664000175000017500000001442012630300451023565 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_export_kml.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_export_kml.cpp // // // // Copyright (C) 2012 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ogr_export_kml.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- COGR_Export_KML::COGR_Export_KML(void) { Set_Name (_TL("Export Shapes to KML")); Set_Author ("O.Conrad (c) 2012"); Set_Description (_TW( "This module exports a vector layer to a Google Earth KML Format using " "Frank Warmerdam's \"Geospatial Data Abstraction Library\" (GDAL/OGR). " "Output file will automatically re-projected to geographic coordinates " "if necessary and possible. " "For more information on GDAL/OGR have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL, "FILE" , _TL("File"), _TL(""), CSG_String::Format( SG_T("%s|*.kml;*.kml|%s|*.*"), _TL("KML files (*.kml)"), _TL("All Files") ), NULL, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool COGR_Export_KML::On_Execute(void) { CSG_String File_Name, Driver_Name = "KML"; CSG_Shapes *pShapes, Shapes; pShapes = Parameters("SHAPES")->asShapes(); File_Name = Parameters("FILE" )->asString(); //----------------------------------------------------- if( pShapes->Get_Projection().Get_Type() == SG_PROJ_TYPE_CS_Undefined ) { Message_Add(_TL("layer uses undefined coordinate system, assuming geographic coordinates")); } else if( pShapes->Get_Projection().Get_Type() != SG_PROJ_TYPE_CS_Geographic ) { Message_Add(CSG_String::Format(SG_T("\n%s (%s: %s)\n"), _TL("re-projection to geographic coordinates"), _TL("original"), pShapes->Get_Projection().Get_Name().c_str()), false); bool bResult; SG_RUN_MODULE(bResult, "pj_proj4", 2, SG_MODULE_PARAMETER_SET("SOURCE" , pShapes) && SG_MODULE_PARAMETER_SET("TARGET" , &Shapes) && SG_MODULE_PARAMETER_SET("CRS_PROJ4", SG_T("+proj=longlat +ellps=WGS84 +datum=WGS84")) ); if( bResult ) { pShapes = &Shapes; Message_Add(CSG_String::Format(SG_T("\n%s: %s\n"), _TL("re-projection"), _TL("success")), false); } else { Message_Add(CSG_String::Format(SG_T("\n%s: %s\n"), _TL("re-projection"), _TL("failed")), false); } } //----------------------------------------------------- CSG_OGR_DataSource DataSource; if( DataSource.Create(File_Name, Driver_Name) == false ) { Message_Add(_TL("could not create KML file")); } else if( DataSource.Write(pShapes, Driver_Name) ) { return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gdal/gdal_catalogue.h0000664000175000017500000001237012634252546023153 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_catalogue.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_gdal // // // //-------------------------------------------------------// // // // gdal_catalogue.h // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_catalogue_H #define HEADER_INCLUDED__gdal_catalogue_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGDAL_Catalogue : public CSG_Module { public: CGDAL_Catalogue(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGDAL_Catalogues : public CSG_Module { public: CGDAL_Catalogues(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_String m_Directory; CSG_Strings m_Extensions; CSG_Parameter_Shapes_List *m_pCatalogues; CSG_Shapes * Get_Catalogue (const CSG_Projection &Projection, CSG_Shapes *pCatalogue, const CSG_String &Name); CSG_Shapes * Get_Catalogue (const CSG_Projection &Projection); int Add_Directory (const CSG_String &Directory); int Add_File (const CSG_String &File); bool Add_To_Geographic (CSG_Shapes *pCatalogue); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_catalogue_H saga-2.2.3/src/modules/io/io_gdal/gdal_export_geotiff.cpp0000664000175000017500000001347112614213770024563 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_export_geotiff.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_export_geotiff.cpp // // // // Copyright (C) 2007 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_export_geotiff.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Export_GeoTIFF::CGDAL_Export_GeoTIFF(void) { Set_Name (_TL("Export GeoTIFF")); Set_Author ("O.Conrad (c) 2007"); Set_Description (_TW( "The \"GDAL GeoTIFF Export\" module exports one or more grids to a Geocoded Tagged Image File Format using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL, "GRIDS" , _TL("Grid(s)"), _TL("The SAGA grids to be exported."), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL, "FILE" , _TL("File"), _TL("The GeoTIFF File to be created."), CSG_String::Format( SG_T("%s|*.tif;*.tiff|%s|*.*"), _TL("TIFF files (*.tif)"), _TL("All Files") ), NULL, true ); Parameters.Add_String( NULL, "OPTIONS" , _TL("Creation Options"), _TL("A space separated list of key-value pairs (K=V)."), _TL("") ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Export_GeoTIFF::On_Execute(void) { CSG_String File_Name, Options; CSG_Projection Projection; CSG_Parameter_Grid_List *pGrids; CSG_GDAL_DataSet DataSet; //----------------------------------------------------- pGrids = Parameters("GRIDS") ->asGridList(); File_Name = Parameters("FILE") ->asString(); Options = Parameters("OPTIONS") ->asString(); Get_Projection(Projection); //----------------------------------------------------- if( !DataSet.Open_Write(File_Name, SG_T("GTiff"), Options, SG_Get_Grid_Type(pGrids), pGrids->Get_Count(), *Get_System(), Projection) ) { return( false ); } //----------------------------------------------------- for(int i=0; iGet_Count(); i++) { Process_Set_Text(CSG_String::Format(SG_T("%s %d"), _TL("Band"), i + 1)); DataSet.Write(i, pGrids->asGrid(i)); } if( !DataSet.Close() ) { return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gdal/gdal_import_netcdf.cpp0000664000175000017500000003540612614213770024376 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_import_netcdf.cpp 1379 2012-04-26 11:58:47Z manfred-e $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_import_netcdf.cpp // // // // Copyright (C) 2012 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_import_netcdf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Import_NetCDF::CGDAL_Import_NetCDF(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import NetCDF")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "This module imports grids NetCDF Format using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format( SG_T("%s|*.nc|%s|*.*"), _TL("NetCDF Files (*.nc)"), _TL("All Files") ), NULL, false ); pNode = Parameters.Add_Value( NULL , "SAVE_FILE" , _TL("Save to File"), _TL("save output to file instead of memory"), PARAMETER_TYPE_Bool, false ); Parameters.Add_FilePath( pNode , "SAVE_PATH" , _TL("Save to Path"), _TL(""), NULL, NULL, true, true ); //----------------------------------------------------- pNode = Parameters.Add_Value( NULL , "TRANSFORM" , _TL("Transformation"), _TL("apply coordinate transformation if appropriate"), PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( pNode , "INTERPOL" , _TL("Interpolation"), _TL("interpolation method to use if grid needs to be aligned to coordinate system"), 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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGDAL_Import_NetCDF::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SAVE_FILE")) ) { pParameters->Get_Parameter("SAVE_PATH")->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("VARS_ALL" )) && pParameters->Get_Parameter("VARS") ) { pParameters->Get_Parameter("VARS" )->Set_Enabled(!pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("TIME_ALL" )) && pParameters->Get_Parameter("TIME") ) { pParameters->Get_Parameter("TIME" )->Set_Enabled(!pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("LEVEL_ALL")) && pParameters->Get_Parameter("LEVEL") ) { pParameters->Get_Parameter("LEVEL")->Set_Enabled(!pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("TRANSFORM")) ) { pParameters->Get_Parameter("INTERPOL")->Set_Enabled(pParameter->asBool()); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const char * CGDAL_Import_NetCDF::Get_Variable(CSG_GDAL_DataSet &DataSet, int iBand) { const char *s = DataSet.Get_MetaData_Item(iBand, "NETCDF_VARNAME"); return( s ); } //--------------------------------------------------------- const char * CGDAL_Import_NetCDF::Get_Time(CSG_GDAL_DataSet &DataSet, int iBand) { const char *s = DataSet.Get_MetaData_Item(iBand, "NETCDF_DIMENSION_time"); if( !s ) s = DataSet.Get_MetaData_Item(iBand, "NETCDF_DIM_time"); return( s ); } //--------------------------------------------------------- const char * CGDAL_Import_NetCDF::Get_Level(CSG_GDAL_DataSet &DataSet, int iBand) { const char *s = DataSet.Get_MetaData_Item(iBand, "NETCDF_DIMENSION_level"); if( !s ) s = DataSet.Get_MetaData_Item(iBand, "NETCDF_DIM_level"); if( !s ) s = DataSet.Get_MetaData_Item(iBand, "NETCDF_DIM_lev"); return( s ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CGDAL_Import_NetCDF::Get_Time_String(const CSG_String &Time, int Format) { switch( Format ) { case 0: return( CSG_Time_Converter::Get_String(Time.asInt(), SG_TIME_FMT_Hours_AD) ); default: return( Time ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import_NetCDF::On_Execute(void) { //----------------------------------------------------- m_pGrids = Parameters("GRIDS")->asGridList(); m_pGrids ->Del_Items(); if( (m_bSaveFile = Parameters("SAVE_FILE")->asBool()) == true ) { m_SavePath = Parameters("SAVE_PATH")->asString(); if( !SG_Dir_Exists(m_SavePath) ) { m_SavePath = SG_File_Get_Path(Parameters("FILE")->asString()); } } //----------------------------------------------------- CSG_GDAL_DataSet DataSet; if( !DataSet.Open_Read(Parameters("FILE")->asString()) ) { Error_Set(CSG_String::Format(SG_T("%s [%s]"), _TL("could not open file"), Parameters("FILE")->asString())); return( false ); } if( DataSet.Get_DriverID().Cmp("netCDF") ) { Error_Set(CSG_String::Format(SG_T("%s [%s]"), _TL("invalid NetCDF file"), Parameters("FILE")->asString())); return( false ); } //----------------------------------------------------- CSG_MetaData MetaData; if( DataSet.Get_Count() <= 0 && DataSet.Get_MetaData(MetaData, "SUBDATASETS") ) { int i, n; for(i=0, n=0; i==n; i++) { CSG_MetaData *pEntry = MetaData.Get_Child(CSG_String::Format(SG_T("SUBDATASET_%d_NAME"), i + 1)); if( pEntry && DataSet.Open_Read(pEntry->Get_Content()) ) { CSG_String Desc = _TL("unknown"); if( (pEntry = MetaData.Get_Child(CSG_String::Format(SG_T("SUBDATASET_%d_DESC"), i + 1))) != NULL ) { Desc = pEntry->Get_Content(); } if( Load(DataSet, Desc) ) { n++; } } } return( n > 0 ); } return( Load(DataSet, SG_File_Get_Name(Parameters("FILE")->asString(), false)) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import_NetCDF::Load(CSG_GDAL_DataSet &DataSet, const CSG_String &Description) { const char *s; int i; //----------------------------------------------------- CSG_MetaData MetaData, *pChild; DataSet.Get_MetaData(MetaData); //----------------------------------------------------- int tFmt = -1; if( (pChild = MetaData.Get_Child("time#units")) != NULL ) { if( pChild->Get_Content().Find("hours since 1-1-1 00:00:0.0") >= 0 ) { tFmt = 0; } } //----------------------------------------------------- CSG_Parameters P, *pVars = NULL, *pTime = NULL, *pLevel = NULL; //----------------------------------------------------- if( SG_UI_Get_Window_Main() ) { CSG_Parameter *pNode; P.Create(this, _TL("Import NetCDF"), _TL("")); P.Set_Callback_On_Parameter_Changed(Get_Parameter_Changed()); P.Add_Info_String(NULL , "METADATA", _TL("Metadata"), _TL(""), MetaData.asText(), true); pNode = P.Add_Value (NULL , "VARS_ALL" , _TL("All Variables"), _TL(""), PARAMETER_TYPE_Bool, true); pVars = P.Add_Parameters(pNode, "VARS" , _TL("Selection") , _TL(""))->asParameters(); pNode = P.Add_Value (NULL , "TIME_ALL" , _TL("All Times") , _TL(""), PARAMETER_TYPE_Bool, true); pTime = P.Add_Parameters(pNode, "TIME" , _TL("Selection") , _TL(""))->asParameters(); pNode = P.Add_Value (NULL , "LEVEL_ALL" , _TL("All Levels") , _TL(""), PARAMETER_TYPE_Bool, true); pLevel = P.Add_Parameters(pNode, "LEVEL" , _TL("Selection") , _TL(""))->asParameters(); for(i=0; iGet_Parameter(s) ) pVars ->Add_Value(NULL, s, s, _TL(""), PARAMETER_TYPE_Bool, false); if( (s = Get_Time (DataSet, i)) != NULL && !pTime ->Get_Parameter(s) ) pTime ->Add_Value(NULL, s, Get_Time_String(s, tFmt), _TL(""), PARAMETER_TYPE_Bool, false); if( (s = Get_Level (DataSet, i)) != NULL && !pLevel->Get_Parameter(s) ) pLevel ->Add_Value(NULL, s, s, _TL(""), PARAMETER_TYPE_Bool, false); } P("VARS_ALL" )->Set_Enabled(pVars ->Get_Count() > 1); P("TIME_ALL" )->Set_Enabled(pTime ->Get_Count() > 1); P("LEVEL_ALL")->Set_Enabled(pLevel->Get_Count() > 1); //------------------------------------------------- if( !Dlg_Parameters(&P, CSG_String::Format(SG_T("%s: %s"), _TL("Import NetCDF"), Description.c_str())) ) { return( false ); } //------------------------------------------------- if( !P("VARS_ALL" )->is_Enabled() || P("VARS_ALL" )->asBool() ) pVars = NULL; if( !P("TIME_ALL" )->is_Enabled() || P("TIME_ALL" )->asBool() ) pTime = NULL; if( !P("LEVEL_ALL")->is_Enabled() || P("LEVEL_ALL")->asBool() ) pLevel = NULL; } //----------------------------------------------------- TSG_Grid_Interpolation Interpolation; switch( Parameters("INTERPOL")->asInt() ) { default: 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; } bool bTransform = Parameters("TRANSFORM")->asBool() && DataSet.Needs_Transformation(); //----------------------------------------------------- for(i=0; iasBool())) && (!pTime || (!!(pLoad = (*pTime )(Get_Time (DataSet, i))) && pLoad->asBool())) && (!pLevel || (!!(pLoad = (*pLevel)(Get_Level (DataSet, i))) && pLoad->asBool())) ) { SG_UI_Progress_Lock(true); if( (pGrid = DataSet.Read(i)) != NULL ) { if( bTransform ) { Process_Set_Text(CSG_String::Format(SG_T("%s [%d/%d]"), _TL("band transformation"), i + 1, DataSet.Get_Count())); DataSet.Get_Transformation(&pGrid, Interpolation, true); } CSG_String Name(_TL("unknown")); if( (s = Get_Variable(DataSet, i)) != NULL && *s ) Name = s; if( (s = Get_Time (DataSet, i)) != NULL && *s ) Name += " [" + Get_Time_String(s, tFmt) + "]"; if( (s = Get_Level (DataSet, i)) != NULL && *s ) Name += " [" + CSG_String(s) + "]"; pGrid->Set_Name(Name); if( m_bSaveFile ) { Name.Replace(".", "_"); Name.Replace(":", "-"); pGrid->Save(SG_File_Make_Path(m_SavePath, Name)); delete(pGrid); } else { m_pGrids->Add_Item(pGrid); } } SG_UI_Progress_Lock(false); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gdal/MLB_Interface.cpp0000664000175000017500000001252712627614242023146 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO_GDAL // // // //-------------------------------------------------------// // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: author@email.de // // // // contact: Author // // Sesame Street 7 // // 12345 Metropolis // // Nirwana // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "gdal_driver.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("GDAL/OGR") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( _TL("SAGA User Group Associaton (c) 2008" )); case MLB_INFO_Description: return( CSG_String::Format(SG_T("%s\n%s %s\n%s: %s"), _TL("Interface to Frank Warmerdam's Geospatial Data Abstraction Library (GDAL)."), _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str(), _TL("Homepage"), SG_T("www.gdal.org\n") )); case MLB_INFO_Version: return( SG_T("2.0") ); case MLB_INFO_Menu_Path: return( _TL("File") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "gdal_import.h" #include "gdal_export.h" #include "gdal_export_geotiff.h" #include "gdal_import_netcdf.h" #include "gdal_catalogue.h" #include "ogr_import.h" #include "ogr_export.h" #include "ogr_export_kml.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CGDAL_Import ); case 1: return( new CGDAL_Export ); case 2: return( new CGDAL_Export_GeoTIFF ); case 7: return( new CGDAL_Catalogue ); case 8: return( new CGDAL_Catalogues ); case 3: return( new COGR_Import ); case 4: return( new COGR_Export ); case 5: return( new COGR_Export_KML ); case 6: return( SG_Get_GDAL_Drivers().Get_Driver("netCDF") ? new CGDAL_Import_NetCDF : NULL ); //----------------------------------------------------- case 9: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/io/io_gdal/Makefile.am0000664000175000017500000000174212614213770022076 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1465 2012-08-23 09:20:00Z oconrad $ # if DEBUG DBGFLAGS = -g -DDEBUG endif if SAGA_UNICODE UC_DEFS = -D_SAGA_UNICODE endif 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) pkglib_LTLIBRARIES = libio_gdal.la libio_gdal_la_SOURCES =\ gdal_catalogue.cpp\ gdal_driver.cpp\ gdal_export.cpp\ gdal_export_geotiff.cpp\ gdal_import.cpp\ gdal_import_netcdf.cpp\ MLB_Interface.cpp\ ogr_driver.cpp\ ogr_export.cpp\ ogr_export_kml.cpp\ ogr_import.cpp\ gdal_catalogue.h\ gdal_driver.h\ gdal_export.h\ gdal_export_geotiff.h\ gdal_import.h\ gdal_import_netcdf.h\ MLB_Interface.h\ ogr_driver.h\ ogr_export.h\ ogr_export_kml.h\ ogr_import.h libio_gdal_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.2.3/src/modules/io/io_gdal/ogr_export.cpp0000664000175000017500000001345112614213770022736 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_export.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_export.cpp // // // // Copyright (C) 2008 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ogr_export.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- COGR_Export::COGR_Export(void) { Set_Name (_TL("Export Shapes")); Set_Author ("O.Conrad (c) 2008"); CSG_String Description, Formats; Description = _TW( "The \"OGR Vector Data Export\" module exports vector data to various file formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" "\n" "Following vector formats are currently supported:\n" "\n" ); for(int i=0; i\n"), SG_Get_OGR_Drivers().Get_Name(i).c_str(), SG_Get_OGR_Drivers().Get_Description(i).c_str() ); Formats += CSG_String::Format(SG_T("%s|"), SG_Get_OGR_Drivers().Get_Name(i).c_str()); } } Description += SG_T("
    NameDescription
    %s%s
    "); Set_Description(Description); //----------------------------------------------------- Parameters.Add_Shapes( NULL, "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL, "FILE" , _TL("File"), _TL(""), NULL, NULL, true ); Parameters.Add_Choice( NULL, "FORMAT" , _TL("Format"), _TL(""), Formats ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool COGR_Export::On_Execute(void) { CSG_String File_Name; CSG_Shapes *pShapes; CSG_OGR_DataSource DataSource; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); File_Name = Parameters("FILE") ->asString(); //----------------------------------------------------- if( DataSource.Create(File_Name, Parameters("FORMAT")->asString()) == false ) { Message_Add(_TL("Could not create data source.")); } else if( DataSource.Write(pShapes, Parameters("FORMAT")->asString()) ) { return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gdal/MLB_Interface.h0000664000175000017500000000740112565125414022605 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2007 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_gdal_H #define HEADER_INCLUDED__io_gdal_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_gdal_EXPORTS #define io_gdal_EXPORT _SAGA_DLL_EXPORT #else #define io_gdal_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_gdal_H saga-2.2.3/src/modules/io/io_gdal/gdal_import.h0000664000175000017500000001105512614213770022512 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_import.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_import.h // // // // Copyright (C) 2007 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_import_H #define HEADER_INCLUDED__gdal_import_H //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_gdal_EXPORT CGDAL_Import : public CSG_Module { public: CGDAL_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid|Import") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: CSG_Parameter_Grid_List *m_pGrids; bool Load_Sub (CSG_GDAL_DataSet &DataSet); bool Load (CSG_GDAL_DataSet &DataSet, const CSG_String &Name); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- io_gdal_EXPORT bool SG_GDAL_Import (const CSG_String &File_Name); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_import_H saga-2.2.3/src/modules/io/io_gdal/gdal_import.cpp0000664000175000017500000003406412614213770023052 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_import.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_import.cpp // // // // Copyright (C) 2007 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_import.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Import::CGDAL_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import Raster")); Set_Author ("O.Conrad (c) 2007 (A.Ringeler)"); CSG_String Description; Description = _TW( "The \"GDAL Raster Import\" module imports grid data from various file formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format("\nGDAL %s:%s\n\n", _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str()); Description += _TW( "Following raster formats are currently supported:\n" "\n" ); for(int i=0; i\n", SG_Get_GDAL_Drivers().Get_Description(i).c_str(), SG_Get_GDAL_Drivers().Get_Name (i).c_str() ); } Description += "
    IDName
    %s%s
    "; Set_Description(Description); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT, false ); Parameters.Add_FilePath( NULL , "FILES" , _TL("Files"), _TL(""), NULL, NULL, false, false, true ); //----------------------------------------------------- Parameters.Add_Value( NULL , "SELECT" , _TL("Select from Multiple Bands"), _TL(""), PARAMETER_TYPE_Bool, true )->Set_UseInCMD(false); //----------------------------------------------------- pNode = Parameters.Add_Value( NULL , "TRANSFORM" , _TL("Transformation"), _TL("align grid to coordinate system"), PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( pNode , "INTERPOL" , _TL("Interpolation"), _TL("interpolation method to use if grid needs to be aligned to coordinate system"), CSG_String::Format("%s|%s|%s|%s|%s|", _TL("Nearest Neighbor"), _TL("Bilinear Interpolation"), _TL("Inverse Distance Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 4 ); //----------------------------------------------------- Add_Parameters("SELECTION", _TL("Select from Multiple Bands"), _TL("")); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGDAL_Import::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TRANSFORM") ) { pParameters->Get_Parameter("INTERPOL")->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameters->Get_Identifier(), "SELECTION") && !SG_STR_CMP(pParameter ->Get_Identifier(), "ALL") && pParameters->Get_Parameter("BANDS") ) { pParameters->Get_Parameter("BANDS")->Set_Enabled(!pParameter->asBool()); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import::On_Execute(void) { CSG_Strings Files; CSG_GDAL_DataSet DataSet; //----------------------------------------------------- if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) ) { return( false ); } //----------------------------------------------------- m_pGrids = Parameters("GRIDS")->asGridList(); m_pGrids ->Del_Items(); for(int i=0; iGet_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import::Load_Sub(CSG_GDAL_DataSet &DataSet) { CSG_MetaData MetaData; if( !DataSet.Get_MetaData(MetaData, "SUBDATASETS") ) { return( false ); } //----------------------------------------------------- int i, n; CSG_Parameters P; for(i=0, n=0; i==n; i++) { CSG_MetaData *pName = MetaData.Get_Child(CSG_String::Format("SUBDATASET_%d_NAME", i + 1)); CSG_MetaData *pDesc = MetaData.Get_Child(CSG_String::Format("SUBDATASET_%d_DESC", i + 1)); if( pName ) { n++; Message_Add(CSG_String::Format("\n%s", pName->Get_Content().c_str()), false); P.Add_Value(NULL, pName->Get_Content(), pDesc ? pDesc->Get_Content().c_str() : _TL("unnamed"), SG_T(""), PARAMETER_TYPE_Bool, SG_UI_Get_Window_Main() == NULL); } } if( SG_UI_Get_Window_Main() && !Dlg_Parameters(&P, _TL("Select from Subdatasets...")) ) // with gui { return( false ); } //----------------------------------------------------- for(i=0, n=0; iasBool() && DataSet.Open_Read(P(i)->Get_Identifier()) && Load(DataSet, P(i)->Get_Name()) ) { n++; } } //--------------------------------------------- return( n > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import::Load(CSG_GDAL_DataSet &DataSet, const CSG_String &Name) { if( !DataSet.is_Reading() ) { return( false ); } //----------------------------------------------------- if( DataSet.Get_Count() <= 0 ) { return( Load_Sub(DataSet) ); } //----------------------------------------------------- CSG_Vector A; CSG_Matrix B; DataSet.Get_Transformation(A, B); Message_Add("\n", false); Message_Add(CSG_String::Format("\n%s: %s", _TL("Driver" ), DataSet.Get_DriverID().c_str() ), false); Message_Add(CSG_String::Format("\n%s: %d", _TL("Bands" ), DataSet.Get_Count() ), false); Message_Add(CSG_String::Format("\n%s: %d", _TL("Rows" ), DataSet.Get_NX() ), false); Message_Add(CSG_String::Format("\n%s: %d", _TL("Columns"), DataSet.Get_NY() ), false); Message_Add("\n", false); Message_Add(CSG_String::Format("\n%s:", _TL("Transformation") ), false); Message_Add(CSG_String::Format("\n x' = %.6f + x * %.6f + y * %.6f", A[0], B[0][0], B[0][1]), false); Message_Add(CSG_String::Format("\n y' = %.6f + x * %.6f + y * %.6f", A[1], B[1][0], B[1][1]), false); Message_Add("\n", false); //----------------------------------------------------- int i, n; CSG_Table Bands; Bands.Add_Field("NAME", SG_DATATYPE_String); for(i=0; iSet_Value(0, DataSet.Get_Name(i)); } Bands.Set_Index(0, TABLE_INDEX_Ascending); //----------------------------------------------------- if( Parameters("SELECT") && Parameters("SELECT")->asBool() && DataSet.Get_Count() > 1 ) { CSG_Parameters *pSelection = Get_Parameters("SELECTION"); pSelection->Add_Value(NULL, "ALL", _TL("Load all bands"), _TL(""), PARAMETER_TYPE_Bool, false); CSG_Parameter *pNode = pSelection->Add_Node(NULL, "BANDS", _TL("Bands"), _TL("")); for(i=0; iAdd_Value(pNode, SG_Get_String(i, 0), pBand->asString(0), _TL(""), PARAMETER_TYPE_Bool, false); } if( Dlg_Parameters("SELECTION") ) { for(i=0; iGet_Parameter(0)->asBool() || pSelection->Get_Parameter(i + 2)->asBool() ) { Bands.Select(Bands.Get_Record_byIndex(i)->Get_Index(), true); } } } pSelection->Del_Parameters(); if( Bands.Get_Selection_Count() <= 0 ) { return( false ); } } //----------------------------------------------------- TSG_Grid_Interpolation Interpolation; switch( Parameters("INTERPOL")->asInt() ) { default: 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; } bool bTransform = Parameters("TRANSFORM")->asBool() && DataSet.Needs_Transformation(); //----------------------------------------------------- for(i=0, n=0; iis_Selected() ) { Process_Set_Text(CSG_String::Format("%s [%d/%d]", _TL("loading band"), i + 1, DataSet.Get_Count())); CSG_Grid *pGrid = DataSet.Read(pBand->Get_Index()); if( pGrid != NULL ) { n++; if( bTransform ) { Process_Set_Text(CSG_String::Format("%s [%d/%d]", _TL("band transformation"), i + 1, DataSet.Get_Count())); DataSet.Get_Transformation(&pGrid, Interpolation, true); } pGrid->Set_Name(DataSet.Get_Count() > 1 ? CSG_String::Format("%s [%s]", Name.c_str(), pGrid->Get_Name()).c_str() : Name.c_str() ); pGrid->Set_File_Name(DataSet.Get_File_Name()); m_pGrids->Add_Item(pGrid); DataObject_Add (pGrid); DataObject_Set_Colors (pGrid, CSG_Colors(11, SG_COLORS_BLACK_WHITE, false)); if( DataSet.Get_Count() == 1 ) { pGrid->Set_File_Name(DataSet.Get_File_Name()); pGrid->Get_MetaData().Add_Child("GDAL_DRIVER", DataSet.Get_DriverID()); } } } } //----------------------------------------------------- return( n > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool SG_GDAL_Import (const CSG_String &File_Name) { CGDAL_Import Import; if( !Import.Get_Parameters()->Set_Parameter("FILES", File_Name, PARAMETER_TYPE_FilePath) ) { return( false ); } if( !Import.Execute() ) { return( false ); } CSG_Parameter_Grid_List *pGrids = Import.Get_Parameters()->Get_Parameter("GRIDS")->asGridList(); for(int i=0; iGet_Count(); i++) { SG_UI_DataObject_Add(pGrids->asGrid(i), SG_UI_DATAOBJECT_UPDATE_ONLY); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_gdal/gdal_driver.h0000664000175000017500000002220112614213770022466 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_driver.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_driver.h // // // // Copyright (C) 2007 O. 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_driver_H #define HEADER_INCLUDED__gdal_driver_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_gdal_EXPORT CSG_GDAL_Drivers { public: CSG_GDAL_Drivers(void); virtual ~CSG_GDAL_Drivers(void); CSG_String Get_Version (void) const; int Get_Count (void) const; class GDALDriver * Get_Driver (const CSG_String &Name) const; class GDALDriver * Get_Driver (int Index) const; CSG_String Get_Name (int Index) const; CSG_String Get_Description (int Index) const; CSG_String Get_Extension (int Index) const; bool Can_Read (int Index) const; bool Can_Write (int Index) const; static int Get_GDAL_Type (TSG_Data_Type Type); static TSG_Data_Type Get_SAGA_Type (int Type); private: class GDALDriverManager *m_pDrivers; }; //--------------------------------------------------------- io_gdal_EXPORT const CSG_GDAL_Drivers & SG_Get_GDAL_Drivers (void); /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SG_GDAL_IO_CLOSED 0x00 #define SG_GDAL_IO_READ 0x01 #define SG_GDAL_IO_WRITE 0x02 #define SG_GDAL_IO_READWRITE (SG_GDAL_IO_READ|IO_WRITE) //--------------------------------------------------------- class io_gdal_EXPORT CSG_GDAL_DataSet { public: CSG_GDAL_DataSet(void); CSG_GDAL_DataSet(const CSG_String &File_Name); virtual ~CSG_GDAL_DataSet(void); bool Open_Read (const CSG_String &File_Name); bool Open_Write (const CSG_String &File_Name, const CSG_String &Driver, const CSG_String &Options, TSG_Data_Type Type, int NBands, const CSG_Grid_System &System, const CSG_Projection &Projection); bool Close (void); bool is_Okay (void) const { return( m_pDataSet != NULL ); } bool is_Reading (void) const { return( m_pDataSet != NULL && m_Access & SG_GDAL_IO_READ ); } bool is_Writing (void) const { return( m_pDataSet != NULL && m_Access & SG_GDAL_IO_WRITE ); } int Get_NX (void) const { return( m_NX ); } int Get_NY (void) const { return( m_NY ); } double Get_Cellsize (void) const { return( m_Cellsize ); } double Get_xMin (void) const { return( m_xMin ); } double Get_yMin (void) const { return( m_yMin ); } double Get_xMax (void) const { return( m_xMin + m_NX * m_Cellsize ); } double Get_yMax (void) const { return( m_yMin + m_NY * m_Cellsize ); } CSG_Rect Get_Extent (bool bTransform = true) const; CSG_Grid_System Get_System (void) const; bool Needs_Transformation(void) const { return( m_bTransform ); } void Get_Transformation (CSG_Vector &A, CSG_Matrix &B) const { A = m_TF_A; B = m_TF_B; } bool Get_Transformation (CSG_Grid_System &System, bool bVerbose) const; bool Get_Transformation (CSG_Grid **ppGrid, TSG_Grid_Interpolation Interpolation, bool bVerbose) const; bool Get_Transformation (CSG_Grid **ppGrid, TSG_Grid_Interpolation Interpolation, const CSG_Grid_System &System, bool bVerbose) const; class GDALDriver * Get_Driver (void) const; CSG_String Get_DriverID (void) const; CSG_String Get_Name (void) const; CSG_String Get_Description (void) const; CSG_String Get_File_Name (void) const; const char * Get_Projection (void) const; const char * Get_MetaData_Item (const char *pszName, const char *pszDomain = "") const; const char ** Get_MetaData (const char *pszDomain = "") const; bool Get_MetaData_Item (CSG_String &MetaData, const char *pszName, const char *pszDomain = "") const; bool Get_MetaData (CSG_MetaData &MetaData) const; bool Get_MetaData (CSG_MetaData &MetaData, const char *pszDomain) const; int Get_Count (void) const; CSG_String Get_Name (int i) const; CSG_String Get_Description (int i) const; bool Get_MetaData (int i, CSG_MetaData &MetaData) const; const char * Get_MetaData_Item (int i, const char *pszName) const; bool Get_MetaData_Item (int i, const char *pszName, CSG_String &MetaData) const; CSG_Grid * Read (int i); bool Write (int i, CSG_Grid *pGrid, double NoDataValue); bool Write (int i, CSG_Grid *pGrid); private: bool m_bTransform; int m_Access, m_NX, m_NY; double m_xMin, m_yMin, m_Cellsize; CSG_String m_File_Name; CSG_Vector m_TF_A; CSG_Matrix m_TF_B, m_TF_BInv; class GDALDataset *m_pDataSet; public: bool to_World (double x, double y, double &xWorld, double &yWorld) { if( m_pDataSet ) { 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 ); } return( false ); } bool from_World (double xWorld, double yWorld, double &x, double &y) { if( m_pDataSet ) { xWorld -= m_TF_A[0]; yWorld -= m_TF_A[1]; 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( true ); } return( false ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- io_gdal_EXPORT TSG_Data_Type SG_Get_Grid_Type (CSG_Parameter_Grid_List *pGrids); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_driver_H saga-2.2.3/src/modules/io/io_gdal/gdal_catalogue.cpp0000664000175000017500000004510412634252546023507 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_catalogue.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_gdal // // // //-------------------------------------------------------// // // // gdal_catalogue.cpp // // // // Copyright (C) 2015 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_catalogue.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Catalogue::CGDAL_Catalogue(void) { //----------------------------------------------------- Set_Name (_TL("Create Raster Catalogue from Files")); Set_Author ("O.Conrad (c) 2015"); CSG_String Description; Description = _TW( "Create a raster catalogue from selected files. Output is a polygon layer " "that shows the extent for each valid raster file. Each extent is attributed with " "the original file path and raster system properties.\n" "\n" "The \"GDAL Raster Import\" module imports grid data from various file formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format("\nGDAL %s:%s\n\n", _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str()); Description += _TW( "Following raster formats are currently supported:\n" "\n" ); for(int i=0; i\n", SG_Get_GDAL_Drivers().Get_Description(i).c_str(), SG_Get_GDAL_Drivers().Get_Name (i).c_str() ); } Description += "
    IDName
    %s%s
    "; Set_Description(Description); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "CATALOGUE" , _TL("Raster Catalogue"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_FilePath( NULL , "FILES" , _TL("Files"), _TL(""), NULL, NULL, false, false, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGDAL_Catalogue::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Catalogue::On_Execute(void) { //----------------------------------------------------- CSG_Strings Files; if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) ) { return( false ); } //----------------------------------------------------- CSG_Shapes *pCatalogue = Parameters("CATALOGUE")->asShapes(); pCatalogue->Create(SHAPE_TYPE_Polygon, _TL("Raster Catalogue")); pCatalogue->Add_Field("ID" , SG_DATATYPE_Int ); pCatalogue->Add_Field("NAME" , SG_DATATYPE_String); pCatalogue->Add_Field("FILE" , SG_DATATYPE_String); pCatalogue->Add_Field("CRS" , SG_DATATYPE_String); pCatalogue->Add_Field("BANDS" , SG_DATATYPE_Int ); pCatalogue->Add_Field("CELLSIZE", SG_DATATYPE_Double); pCatalogue->Add_Field("ROWS" , SG_DATATYPE_Int ); pCatalogue->Add_Field("COLUMNS" , SG_DATATYPE_Int ); //----------------------------------------------------- for(int i=0; iAdd_Shape(); pEntry->Set_Value(0, pCatalogue->Get_Count ()); pEntry->Set_Value(1, Name ); pEntry->Set_Value(2, DataSet.Get_File_Name ()); pEntry->Set_Value(3, DataSet.Get_Projection()); pEntry->Set_Value(4, DataSet.Get_Count ()); pEntry->Set_Value(5, System.Get_Cellsize ()); pEntry->Set_Value(6, System.Get_NX ()); pEntry->Set_Value(7, System.Get_NY ()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMin()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMax()); pEntry->Add_Point(System.Get_XMax(), System.Get_YMax()); pEntry->Add_Point(System.Get_XMax(), System.Get_YMin()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMin()); if( !pCatalogue->Get_Projection().is_Okay() ) { pCatalogue->Get_Projection().Create(DataSet.Get_Projection(), SG_PROJ_FMT_WKT); } } } //----------------------------------------------------- return( pCatalogue->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Catalogues::CGDAL_Catalogues(void) { //----------------------------------------------------- Set_Name (_TL("Create Raster Catalogues from Directory")); Set_Author ("O.Conrad (c) 2015"); CSG_String Description; Description = _TW( "Creates raster catalogues from all raster files found in the selected directory. " "Catalogues are splitted according to the coordinate reference system used by the " "different raster files. Output are polygon layers that show the extent for each " "raster file in it. Each extent is attributed with the original file path and " "raster system properties.\n" "\n" "The \"GDAL Raster Import\" module imports grid data from various file formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format("\nGDAL %s:%s\n\n", _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str()); Description += _TW( "Following raster formats are currently supported:\n" "\n" ); for(int i=0; i\n", SG_Get_GDAL_Drivers().Get_Description(i).c_str(), SG_Get_GDAL_Drivers().Get_Name (i).c_str() ); } Description += "
    IDName
    %s%s
    "; Set_Description(Description); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL , "CATALOGUES" , _TL("Raster Catalogues"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "CATALOGUE_GCS" , _TL("Raster Catalogue"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "CATALOGUE_UKN" , _TL("Raster Catalogue (unknown CRS)"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_FilePath( NULL , "DIRECTORY" , _TL("Directory"), _TL(""), NULL, NULL, false, true ); Parameters.Add_String( NULL , "EXTENSIONS" , _TL("Extensions"), _TL(""), "sgrd; tif" ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format("%s|%s|", _TL("one catalogue for each coordinate system"), _TL("one catalogue using geographic coordinates") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGDAL_Catalogues::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "OUTPUT") ) { pParameters->Set_Enabled("CATALOGUES" , pParameter->asInt() == 0); pParameters->Set_Enabled("CATALOGUE_GCS", pParameter->asInt() == 1); pParameters->Set_Enabled("CATALOGUE_UKN", pParameter->asInt() == 1); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Catalogues::On_Execute(void) { //----------------------------------------------------- m_Directory = Parameters("DIRECTORY")->asString(); if( !SG_Dir_Exists(m_Directory) ) { return( false ); } //----------------------------------------------------- m_pCatalogues = Parameters("CATALOGUES")->asShapesList(); m_pCatalogues ->Del_Items(); //----------------------------------------------------- CSG_String_Tokenizer Extensions(Parameters("EXTENSIONS")->asString(), ";"); while( Extensions.Has_More_Tokens() ) { CSG_String Extension = Extensions.Get_Next_Token(); Extension.Trim(true); Extension.Trim(false); if( Extension.CmpNoCase("sgrd") == 0 ) // gdal ignores saga's grid header file, use grid data file instead! { Extension = "sdat"; } if( !Extension.is_Empty() ) { m_Extensions += Extension; } } if( m_Extensions.Get_Count() == 0 ) { m_Extensions += ""; } //----------------------------------------------------- int n = Add_Directory(m_Directory); m_Extensions.Clear(); if( n <= 0 ) { Message_Add(CSG_String::Format("\n%s\n", _TL("No raster files have been found in directory."))); return( false ); } Message_Add(CSG_String::Format("\n%s: %d\n", _TL("Number of raster files found in directory"), n), false); //----------------------------------------------------- if( Parameters("OUTPUT")->asInt() == 1 ) // one catalogue using geographic coordinates { Get_Catalogue(CSG_Projection("+proj=longlat +datum=WGS84", SG_PROJ_FMT_Proj4), Parameters("CATALOGUE_GCS")->asShapes(), _TL("Raster Catalogue") ); Get_Catalogue(CSG_Projection(), Parameters("CATALOGUE_UKN")->asShapes(), _TL("Raster Catalogue (unknown CRS)") ); for(int i=m_pCatalogues->Get_Count()-1; i>=0 && Process_Get_Okay(true); i--) { CSG_Shapes *pCatalogue = m_pCatalogues->asShapes(i); Add_To_Geographic(pCatalogue); delete(pCatalogue); m_pCatalogues->Del_Item(i); } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shapes * CGDAL_Catalogues::Get_Catalogue(const CSG_Projection &Projection, CSG_Shapes *pCatalogue, const CSG_String &Name) { if( pCatalogue ) { pCatalogue->Create(SHAPE_TYPE_Polygon, Name); pCatalogue->Add_Field("ID" , SG_DATATYPE_Int ); pCatalogue->Add_Field("NAME" , SG_DATATYPE_String); pCatalogue->Add_Field("FILE_ABS", SG_DATATYPE_String); pCatalogue->Add_Field("FILE_REL", SG_DATATYPE_String); pCatalogue->Add_Field("CRS" , SG_DATATYPE_String); pCatalogue->Add_Field("PROJ4" , SG_DATATYPE_String); pCatalogue->Add_Field("BANDS" , SG_DATATYPE_Int ); pCatalogue->Add_Field("CELLSIZE", SG_DATATYPE_Double); pCatalogue->Add_Field("ROWS" , SG_DATATYPE_Int ); pCatalogue->Add_Field("COLUMNS" , SG_DATATYPE_Int ); pCatalogue->Get_Projection().Create(Projection); } return( pCatalogue ); } //--------------------------------------------------------- CSG_Shapes * CGDAL_Catalogues::Get_Catalogue(const CSG_Projection &Projection) { for(int i=0; iGet_Count(); i++) { if( Projection.is_Equal(m_pCatalogues->asShapes(i)->Get_Projection()) ) { return( m_pCatalogues->asShapes(i) ); } } //----------------------------------------------------- CSG_Shapes *pCatalogue = Get_Catalogue(Projection, SG_Create_Shapes(), CSG_String::Format("%s No.%d", _TL("Raster Catalogue"), 1 + m_pCatalogues->Get_Count())); m_pCatalogues->Add_Item(pCatalogue); return( pCatalogue ); } //--------------------------------------------------------- int CGDAL_Catalogues::Add_Directory(const CSG_String &Directory) { int n = 0; CSG_Strings List; //----------------------------------------------------- for(int iExtension=0; iExtensionAdd_Shape(); CSG_String Filename_Absolute = DataSet.Get_File_Name(); if( SG_File_Cmp_Extension(Filename_Absolute, SG_T("sdat")) ) { SG_File_Set_Extension(Filename_Absolute, "sgrd"); } CSG_String Filename_Relative = SG_File_Get_Path_Relative(m_Directory, Filename_Absolute); pEntry->Set_Value(0, pCatalogue->Get_Count ()); pEntry->Set_Value(1, Name ); pEntry->Set_Value(2, Filename_Absolute ); pEntry->Set_Value(3, Filename_Relative ); pEntry->Set_Value(4, DataSet.Get_Projection()); pEntry->Set_Value(5, Projection.Get_Proj4 ()); pEntry->Set_Value(6, DataSet.Get_Count ()); pEntry->Set_Value(7, System.Get_Cellsize ()); pEntry->Set_Value(8, System.Get_NX ()); pEntry->Set_Value(9, System.Get_NY ()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMin()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMax()); pEntry->Add_Point(System.Get_XMax(), System.Get_YMax()); pEntry->Add_Point(System.Get_XMax(), System.Get_YMin()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMin()); return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Catalogues::Add_To_Geographic(CSG_Shapes *pCatalogue) { CSG_Shapes Catalogue, *pTarget = Parameters("CATALOGUE_UKN")->asShapes(); if( pCatalogue->Get_Projection().is_Okay() ) { bool bResult; SG_RUN_MODULE(bResult, "pj_proj4", 2, SG_MODULE_PARAMETER_SET("SOURCE" , pCatalogue) && SG_MODULE_PARAMETER_SET("TARGET" , &Catalogue) && SG_MODULE_PARAMETER_SET("CRS_PROJ4", Parameters("CATALOGUE_GCS")->asShapes()->Get_Projection().Get_Proj4()) ); if( bResult ) { pCatalogue = &Catalogue; pTarget = Parameters("CATALOGUE_GCS")->asShapes(); } } //----------------------------------------------------- if( pTarget ) { for(int i=0; iGet_Count(); i++) { pTarget->Add_Shape(pCatalogue->Get_Shape(i)); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_table/0000775000175000017500000000000012634325744020225 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_table/io_table_txt.h0000664000175000017500000001370512622617361023055 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: io_table_txt.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_io // // // //-------------------------------------------------------// // // // io_table_txt.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_table_txt_H #define HEADER_INCLUDED__io_table_txt_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Text_Export : public CSG_Module { public: CTable_Text_Export(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Text_Import : public CSG_Module { public: CTable_Text_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Import") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Text_Import_Numbers : public CSG_Module { public: CTable_Text_Import_Numbers(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Import") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Text_Import_Fixed_Cols : public CSG_Module { public: CTable_Text_Import_Fixed_Cols(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Import") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_table_txt_H saga-2.2.3/src/modules/io/io_table/Makefile.in0000664000175000017500000005413712622651167022302 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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/io_table DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) 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'`; 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__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) 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) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_table_la_SOURCES) DIST_SOURCES = $(libio_table_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ 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@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOMPFLAGS = @GOMPFLAGS@ 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@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ 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_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ 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@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ 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 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_table.la libio_table_la_SOURCES = \ io_table_txt.cpp\ MLB_Interface.cpp\ io_table_txt.h\ MLB_Interface.h libio_table_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) --foreign src/modules/io/io_table/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_table/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) @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 " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ 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)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_table.la: $(libio_table_la_OBJECTS) $(libio_table_la_DEPENDENCIES) $(EXTRA_libio_table_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_table_la_OBJECTS) $(libio_table_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io_table_txt.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files 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: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi 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 TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am 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 tags-am 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: saga-2.2.3/src/modules/io/io_table/io_table_txt.cpp0000664000175000017500000005371112622617361023411 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: io_table_txt.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_io // // // //-------------------------------------------------------// // // // io_table_txt.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "io_table_txt.h" /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Text_Export::CTable_Text_Export(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Export Text Table")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Value( NULL , "HEADLINE" , _TL("Save Headline"), _TL(""), PARAMETER_TYPE_Bool , true ); Parameters.Add_Value( NULL , "STRQUOTA" , _TL("Strings in Quota"), _TL(""), PARAMETER_TYPE_Bool , true ); pNode = Parameters.Add_Choice( NULL , "SEPARATOR" , _TL("Separator"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("tabulator"), SG_T(";"), SG_T(","), _TL("space"), _TL("other") ), 0 ); Parameters.Add_String( pNode , "SEP_OTHER" , _TL("other"), _TL(""), SG_T("*") ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"), _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("CSV Files (*.csv)") , SG_T("*.csv"), _TL("All Files") , SG_T("*.*") ), NULL, true ); } //--------------------------------------------------------- bool CTable_Text_Export::On_Execute(void) { CSG_String StrFormat, Separator; CSG_File Stream; CSG_Table *pTable; //----------------------------------------------------- pTable = Parameters("TABLE" )->asTable(); StrFormat = Parameters("STRQUOTA")->asBool() ? SG_T("\"%s\"") : SG_T("%s"); switch( Parameters("SEPARATOR")->asInt() ) { case 0: Separator = "\t"; break; case 1: Separator = ";"; break; case 2: Separator = ","; break; case 3: Separator = " "; break; default: Separator = Parameters("SEP_OTHER")->asString(); break; } //----------------------------------------------------- if( !Stream.Open(Parameters("FILENAME")->asString(), SG_FILE_W, false) ) { Message_Add(_TL("file could not be opened.")); } //----------------------------------------------------- else { if( Parameters("HEADLINE")->asBool() ) { for(int iField=0; iFieldGet_Field_Count(); iField++) { Stream.Printf(StrFormat.c_str(), pTable->Get_Field_Name(iField)); Stream.Printf(iField < pTable->Get_Field_Count() - 1 ? Separator.c_str() : SG_T("\n")); } } //------------------------------------------------- for(int iRecord=0; iRecordGet_Record_Count() && Set_Progress(iRecord, pTable->Get_Record_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); for(int iField=0; iFieldGet_Field_Count(); iField++) { switch( pTable->Get_Field_Type(iField) ) { default: case SG_DATATYPE_Char: case SG_DATATYPE_String: case SG_DATATYPE_Date: Stream.Printf(StrFormat.c_str(), pRecord->asString(iField)); break; case SG_DATATYPE_Short: case SG_DATATYPE_Int: case SG_DATATYPE_Color: Stream.Printf(SG_T("%d") , pRecord->asInt(iField)); break; case SG_DATATYPE_Long: Stream.Printf(SG_T("%ld") , (long)pRecord->asDouble(iField)); break; case SG_DATATYPE_ULong: Stream.Printf(SG_T("%lu") , (unsigned long)pRecord->asDouble(iField)); break; case SG_DATATYPE_Float: case SG_DATATYPE_Double: Stream.Printf(SG_T("%f") , pRecord->asDouble(iField)); break; } Stream.Printf(iField < pTable->Get_Field_Count() - 1 ? Separator.c_str() : SG_T("\n")); } } //------------------------------------------------- Stream.Close(); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Text_Import::CTable_Text_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import Text Table")); Set_Author ("O. Conrad (c) 2008"); 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 ); pNode = Parameters.Add_Choice( NULL , "SEPARATOR" , _TL("Separator"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|", _TL("tabulator"), SG_T(";"), SG_T(","), _TL("space"), _TL("other") ), 0 ); Parameters.Add_String( pNode , "SEP_OTHER" , _TL("Separator (other)"), _TL(""), SG_T("*") ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("File"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|%s", _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("CSV Files (*.csv)") , SG_T("*.csv"), _TL("All Files") , SG_T("*.*") ), NULL, false ); } //--------------------------------------------------------- int CTable_Text_Import::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "SEPARATOR") ) { pParameters->Set_Enabled("SEP_OTHER", pParameter->asInt() >= 4); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } //--------------------------------------------------------- bool CTable_Text_Import::On_Execute(void) { //----------------------------------------------------- CSG_Table *pTable = Parameters("TABLE")->asTable(); SG_Char Separator; switch( Parameters("SEPARATOR")->asInt() ) { case 0: Separator = '\t'; break; case 1: Separator = ';'; break; case 2: Separator = ','; break; case 3: Separator = ' '; break; default: Separator = *Parameters("SEP_OTHER")->asString(); break; } //----------------------------------------------------- if( !pTable->Create(Parameters("FILENAME")->asString(), Parameters("HEADLINE")->asBool() ? TABLE_FILETYPE_Text : TABLE_FILETYPE_Text_NoHeadLine, Separator) ) { Error_Set(_TL("table could not be opened.")); return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Text_Import_Numbers::CTable_Text_Import_Numbers(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import Text Table with Numbers only")); Set_Author ("O. Conrad (c) 2008"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "SKIP" , _TL("Skip Lines"), _TL(""), PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( NULL , "HEADLINE" , _TL("Headline"), _TL(""), PARAMETER_TYPE_Bool, false ); pNode = Parameters.Add_Choice( NULL , "SEPARATOR" , _TL("Separator"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|", _TL("tabulator"), SG_T(";"), SG_T(","), _TL("space"), _TL("other") ), 0 ); Parameters.Add_String( pNode , "SEP_OTHER" , _TL("other"), _TL(""), SG_T("*") ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("File"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|%s", _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("CSV Files (*.csv)") , SG_T("*.csv"), _TL("All Files") , SG_T("*.*") ), NULL, false ); } //--------------------------------------------------------- int CTable_Text_Import_Numbers::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "SEPARATOR") ) { pParameters->Set_Enabled("SEP_OTHER", pParameter->asInt() >= 4); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } //--------------------------------------------------------- bool CTable_Text_Import_Numbers::On_Execute(void) { CSG_String sHead, sLine, Separator; CSG_File Stream; //----------------------------------------------------- if( !Stream.Open(Parameters("FILENAME")->asString(), SG_FILE_R, false) ) { Error_Set(_TL("file could not be opened")); return( false ); } if( Parameters("SKIP")->asInt() > 0 ) { int i = Parameters("SKIP")->asInt(); while( i > 0 && Stream.Read_Line(sLine) ) { i--; } } if( !Stream.Read_Line(sHead) || sHead.Length() == 0 ) { Error_Set(_TL("empty or corrupted file")); return( false ); } if( !Parameters("HEADLINE")->asBool() ) { sLine = sHead; } else if( !Stream.Read_Line(sLine) || sLine.Length() == 0 ) { Error_Set(_TL("empty or corrupted file")); return( false ); } //----------------------------------------------------- switch( Parameters("SEPARATOR")->asInt() ) { case 0: Separator = "\t"; break; case 1: Separator = ";"; break; case 2: Separator = ","; break; case 3: Separator = " "; break; default: Separator = Parameters("SEP_OTHER")->asString(); break; } //----------------------------------------------------- CSG_Table *pTable = Parameters("TABLE")->asTable(); pTable->Destroy(); pTable->Set_Name(SG_File_Get_Name(Parameters("FILENAME")->asString(), false)); sHead.Trim(true); sHead.Replace(Separator, "\t"); while( sHead.Length() > 0 ) { sHead.Trim(); if( Parameters("HEADLINE")->asBool() ) { pTable->Add_Field(sHead.BeforeFirst('\t'), SG_DATATYPE_Double); } else { pTable->Add_Field(CSG_String::Format("FIELD%02d", 1 + pTable->Get_Field_Count()), SG_DATATYPE_Double); } sHead = sHead.AfterFirst('\t'); } if( pTable->Get_Field_Count() <= 0 ) { Error_Set(_TL("empty or corrupted file")); return( false ); } //----------------------------------------------------- int fLength = Stream.Length(); bool bOkay = true; do { sLine.Replace(Separator, "\t"); CSG_Table_Record *pRecord = pTable->Add_Record(); for(int i=0; bOkay && iGet_Field_Count(); i++) { double Value; sLine.Trim(); if( (bOkay = sLine.asDouble(Value)) == true ) { pRecord->Set_Value(i, Value); sLine = sLine.AfterFirst('\t'); } else { pTable->Del_Record(pTable->Get_Count() - 1); } } } while( bOkay && Stream.Read_Line(sLine) && Set_Progress(Stream.Tell(), fLength) ); return( pTable->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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|%s|"), _TL("mark breaks in first line"), _TL("specify fields with type"), _TL("from list") ), 2 ); Parameters.Add_Value( NULL , "NFIELDS" , _TL("Number of Fields"), _TL(""), PARAMETER_TYPE_Int , 1, 1, true ); CSG_Table *pList = Parameters.Add_FixedTable( NULL , "LIST" , _TL("List"), _TL("") )->asTable(); pList->Add_Field(_TL("Name") , SG_DATATYPE_String); pList->Add_Field(_TL("Size") , SG_DATATYPE_Int); pList->Add_Field(_TL("Numeric") , SG_DATATYPE_Byte); 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("")); } //--------------------------------------------------------- int CTable_Text_Import_Fixed_Cols::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FIELDDEF")) ) { // pParameters->Get_Parameter("BREAKS" )->Set_Enabled(pParameter->asInt() == 0); // pParameters->Get_Parameter("FIELDS" )->Set_Enabled(pParameter->asInt() == 1); pParameters->Get_Parameter("NFIELDS")->Set_Enabled(pParameter->asInt() == 1); pParameters->Get_Parameter("LIST" )->Set_Enabled(pParameter->asInt() == 2); } return( 1 ); } //--------------------------------------------------------- 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 = (int)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)); switch( Parameters("FIELDDEF")->asInt() ) { //----------------------------------------------------- case 0: { CSG_Parameters *pBreaks = Get_Parameters("BREAKS"); pBreaks->Del_Parameters(); for(i=0; iAdd_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; iGet_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; iGet_Count() && iFieldGet_Parameter(i)->asBool() ) { iFirst[iField++] = i + 1; } } //------------------------------------------------- for(iField=0; iFieldAdd_Field(bHeader ? sLine.Mid(iFirst[iField], iLength[iField]) : CSG_String::Format(SG_T("FIELD%03d"), iField + 1), SG_DATATYPE_String); } } break; //----------------------------------------------------- case 1: { CSG_Parameters *pFields = Get_Parameters("FIELDS"); pFields->Del_Parameters(); nFields = Parameters("NFIELDS")->asInt(); for(iField=0; iFieldAdd_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; iFieldGet_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; } } } break; //----------------------------------------------------- case 2: { CSG_Table *pList = Parameters("LIST")->asTable(); nFields = pList->Get_Count(); //------------------------------------------------- iFirst = new int[nFields]; iLength = new int[nFields]; iFirst[0] = 0; for(iField=0, i=0; iFieldGet_Record(iField)->asInt(1); i += iLength[iField]; CSG_String Name = bHeader ? sLine.Mid(iFirst[iField], iLength[iField]) : CSG_String(pList->Get_Record(iField)->asString(0)); switch( pList->Get_Record(iField)->asInt(2) ) { 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; default: case 4: pTable->Add_Field(Name, SG_DATATYPE_Double); break; } } } 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; iFieldSet_Value(iField, sLine.Mid(iFirst[iField], iLength[iField])); } } } while( Stream.Read_Line(sLine) && Set_Progress(Stream.Tell(), fLength) ); //----------------------------------------------------- delete[](iFirst); delete[](iLength); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_table/MLB_Interface.cpp0000664000175000017500000001137112565125414023321 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_table // // // //-------------------------------------------------------// // // // MLB_Interface.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Tables") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("SAGA User Group Associaton (c) 2002-10") ); case MLB_INFO_Description: return( _TL("Tools for the import and export of tables.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Tables") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "io_table_txt.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( 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 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.2.3/src/modules/io/io_table/Makefile.am0000664000175000017500000000115612565125414022257 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # 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) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_table.la libio_table_la_SOURCES =\ io_table_txt.cpp\ MLB_Interface.cpp\ io_table_txt.h\ MLB_Interface.h libio_table_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) saga-2.2.3/src/modules/io/io_table/MLB_Interface.h0000664000175000017500000000767312565125414023000 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_table // // // //-------------------------------------------------------// // // // MLB_Interface.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@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_table_H #define HEADER_INCLUDED__io_table_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_table_EXPORTS #define io_table_EXPORT _SAGA_DLL_EXPORT #else #define io_table_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_table_H saga-2.2.3/src/modules/io/io_shapes/0000775000175000017500000000000012634325743020420 5ustar00oconradoconrad00000000000000saga-2.2.3/src/modules/io/io_shapes/gstat.h0000664000175000017500000001121212565125414021704 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gstat.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO // // // //-------------------------------------------------------// // // // Gstat.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GSTAT_H #define HEADER_INCLUDED__GSTAT_H //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGStat_Export : public CSG_Module { public: CGStat_Export(void); virtual ~CGStat_Export(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Export") ); } protected: virtual bool On_Execute(void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGStat_Import : public CSG_Module { public: CGStat_Import(void); virtual ~CGStat_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute(void); private: bool Stream_Find_NextWhiteChar (FILE *Stream); bool Stream_Get_StringInQuota (FILE *Stream, CSG_String &String); }; #endif // #ifndef HEADER_INCLUDED__GSTAT_H saga-2.2.3/src/modules/io/io_shapes/atlas_bna.h0000664000175000017500000001140112565125414022506 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: atlas_bna.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // Atlas_BNA.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Atlas_BNA_H #define HEADER_INCLUDED__Atlas_BNA_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CAtlas_BNA_Import : public CSG_Module { public: CAtlas_BNA_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CAtlas_BNA_Export : public CSG_Module { public: CAtlas_BNA_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Atlas_BNA_H saga-2.2.3/src/modules/io/io_shapes/wasp_map.cpp0000664000175000017500000002701212565125414022731 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wasp_map.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // WASP_MAP.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "wasp_map.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWASP_MAP_Export::CWASP_MAP_Export(void) { Set_Name (_TL("Export WASP terrain map file")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "Reference:\n" "" "http://www.risoe.dk/vea/projects/nimo/WAsPHelp/Wasp8.htm#FileFormatofMAP.htm" )); //----------------------------------------------------- CSG_Parameter *pShapes = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Contour Lines"), _TL(""), PARAMETER_INPUT , SHAPE_TYPE_Line ); Parameters.Add_Table_Field( pShapes , "ELEVATION" , _TL("Map File"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File Name"), _TL(""), CSG_String::Format(SG_T("%s|*.map|%s|*.*"), _TL("WASP Map Files (*.map)"), _TL("All Files") ), NULL, true ); } //--------------------------------------------------------- bool CWASP_MAP_Export::On_Execute(void) { //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(Parameters("FILE")->asString(), SG_FILE_W) ) { return( false ); } CSG_Shapes *pLines = Parameters("SHAPES")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- // 1) Text string identifying the terrain map: + ... Stream.Printf(SG_T("+ %s\n"), pLines->Get_Name()); // 2) Fixed point #1 in user and metric [m] coordinates: // X1(user) Y1(user) X1(metric) Y1(metric) Stream.Printf(SG_T("%f %f %f %f\n"), 0.0, 0.0, 0.0, 0.0); // 3) Fixed point #2 in user and metric [m] coordinates: // X2(user) Y2(user) X2(metric) Y2(metric) Stream.Printf(SG_T("%f %f %f %f\n"), 1.0, 1.0, 1.0, 1.0); // 4) Scaling factor and offset for height scale (Z): // Zmetric = {scaling factor}(Zuser + {offset}) Stream.Printf(SG_T("%f %f\n"), 1.0, 0.0); int zField = Parameters("ELEVATION")->asInt(); //----------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { CSG_Shape *pLine = pLines->Get_Shape(iLine); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pLine->Get_Point_Count(iPart) > 1 ) { // 5a) Height contour: elevation (Z) and number of points (n) in line: // Z n Stream.Printf(SG_T("%f %d\n"), pLine->asDouble(zField), pLine->Get_Point_Count(iPart)); // 5b) Roughness change line: // roughness lengths to the left (z0l) and right (z0r) side of the line, // respectively, and number of points: // z0l z0r n // 5c) Roughness and contour line: // roughness lengths to the left and right of the line, // respectively, elevation and number of points: // z0l z0r Z n // 6–) Cartesian coordinates (X, Y) of line described in 5a, 5b or 5c: // X1 Y1 [... Xn Yn] // Xn+1 Yn+1 // ... where [] embrace optional numbers and n is > 0 for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pLine->Get_Point(iPoint, iPart); Stream.Printf(SG_T("%f\t%f\n"), p.x, p.y); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWASP_MAP_Import::CWASP_MAP_Import(void) { Set_Name (_TL("Import WASP terrain map file")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "Reference:\n" "" "http://www.risoe.dk/vea/projects/nimo/WAsPHelp/Wasp8.htm#FileFormatofMAP.htm" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Contour Lines"), _TL(""), PARAMETER_OUTPUT , SHAPE_TYPE_Line ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File Name"), _TL(""), CSG_String::Format(SG_T("%s|*.map|%s|*.*"), _TL("WASP Map Files (*.map)"), _TL("All Files") ), NULL, false ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Input Specification"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("elevation"), _TL("roughness"), _TL("elevation and roughness") ), 0 ); } //--------------------------------------------------------- bool CWASP_MAP_Import::On_Execute(void) { int n, Method, nLength; double z, dz, zMin, rLeft, rRight; FILE *Stream; TSG_Point p, pu[2], pm[2]; CSG_String fName, sLine; CSG_Shape *pLine; CSG_Shapes *pLines; //----------------------------------------------------- pLines = Parameters("SHAPES")->asShapes(); fName = Parameters("FILE" )->asString(); Method = Parameters("METHOD")->asInt(); //----------------------------------------------------- if( (Stream = fopen(fName.b_str(), "r")) != NULL ) { fseek(Stream, 0, SEEK_END); nLength = ftell(Stream); fseek(Stream, 0, SEEK_SET); pLines->Create(SHAPE_TYPE_Line, SG_File_Get_Name(fName, false)); switch( Method ) { case 0: // elevation pLines->Add_Field("Z" , SG_DATATYPE_Double); break; case 1: // roughness pLines->Add_Field("RLEFT" , SG_DATATYPE_Double); pLines->Add_Field("RRIGHT" , SG_DATATYPE_Double); break; case 2: // elevation and roughness pLines->Add_Field("Z" , SG_DATATYPE_Double); pLines->Add_Field("RLEFT" , SG_DATATYPE_Double); pLines->Add_Field("RRIGHT" , SG_DATATYPE_Double); break; } // 1) Text string identifying the terrain map: + ... SG_Read_Line(Stream, sLine); // 2) Fixed point #1 in user and metric [m] coordinates: // X1(user) Y1(user) X1(metric) Y1(metric) fscanf(Stream, "%lf %lf %lf %lf", &pu[0].x, &pu[0].y, &pm[0].x, &pm[0].y); // 3) Fixed point #2 in user and metric [m] coordinates: // X2(user) Y2(user) X2(metric) Y2(metric) fscanf(Stream, "%lf %lf %lf %lf", &pu[1].x, &pu[1].y, &pm[1].x, &pm[1].y); // 4) Scaling factor and offset for height scale (Z): // Zmetric = {scaling factor}(Zuser + {offset}) fscanf(Stream, "%lf %lf", &dz, &zMin); while( !feof(Stream) && Set_Progress(ftell(Stream), nLength) ) { pLine = NULL; switch( Method ) { case 0: // elevation // 5a) Height contour: elevation (Z) and number of points (n) in line: // Z n fscanf(Stream, "%lf %d", &z, &n); if( !feof(Stream) && n > 1 ) { pLine = pLines->Add_Shape(); pLine->Set_Value(0, zMin + dz * z); } break; case 1: // roughness // 5b) Roughness change line: // roughness lengths to the left (z0l) and right (z0r) side of the line, // respectively, and number of points: // z0l z0r n fscanf(Stream, "%lf %lf %d", &rLeft, &rRight, &n); if( !feof(Stream) && n > 1 ) { pLine = pLines->Add_Shape(); pLine->Set_Value(0, rLeft); pLine->Set_Value(1, rRight); } break; case 2: // elevation and roughness // 5c) Roughness and contour line: // roughness lengths to the left and right of the line, // respectively, elevation and number of points: // z0l z0r Z n fscanf(Stream, "%lf %lf %lf %d", &rLeft, &rRight, &z, &n); if( !feof(Stream) && n > 1 ) { pLine = pLines->Add_Shape(); pLine->Set_Value(0, zMin + dz * z); pLine->Set_Value(1, rLeft); pLine->Set_Value(2, rRight); } break; } // 6–) Cartesian coordinates (X, Y) of line described in 5a, 5b or 5c: // X1 Y1 [... Xn Yn] // Xn+1 Yn+1 // ... where [] embrace optional numbers and n is > 0 for(int i=0; iAdd_Point(p); } } fclose(Stream); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_shapes/pointcloud_from_file.h0000664000175000017500000001025612565125414024773 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pointcloud_from_file.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // pointcloud_from_file.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pointcloud_from_file_H #define HEADER_INCLUDED__pointcloud_from_file_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPointCloud_From_File : public CSG_Module { public: CPointCloud_From_File(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); private: bool Read_Shapefile (const CSG_String &fName); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pointcloud_from_file_H saga-2.2.3/src/modules/io/io_shapes/surfer_bln.h0000664000175000017500000001141112565125414022724 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: surfer_bln.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // Surfer_BLN.h // // // // 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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Surfer_BLN_H #define HEADER_INCLUDED__Surfer_BLN_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSurfer_BLN_Import : public CSG_Module { public: CSurfer_BLN_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSurfer_BLN_Export : public CSG_Module { public: CSurfer_BLN_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Surfer_BLN_H saga-2.2.3/src/modules/io/io_shapes/svg.h0000664000175000017500000001175512565125414021375 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: svg.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // svg.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__svg_H #define HEADER_INCLUDED__svg_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSVG_Export : public CSG_Module { public: CSVG_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Export") ); } protected: virtual bool On_Execute (void); private: double m_dStroke; bool Get_Points (CSG_Shape *pShape, int iPart, CSG_String &Points); void Add_Points (CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color, double Size, int Symbol); void Add_Line (CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color, double Size); void Add_Polygon (CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSVG_Import : public CSG_Module { public: CSVG_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("R:Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__svg_H saga-2.2.3/src/modules/io/io_shapes/surfer_bln.cpp0000664000175000017500000002644212565125414023271 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: surfer_bln.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // Surfer_BLN.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "surfer_bln.h" /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSurfer_BLN_Import::CSurfer_BLN_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import Surfer Blanking Files")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "Import polygons/polylines from Golden Software's Surfer Blanking File format.\n" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Table( NULL , "TABLE" , _TL("Look up table (Points)"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("Surfer Blanking Files (*.bln)|*.bln|All Files|*.*") ); pNode = Parameters.Add_Choice( NULL , "TYPE" , _TL("Shape Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("points"), _TL("lines"), _TL("polygons") ), 1 ); } //--------------------------------------------------------- bool CSurfer_BLN_Import::On_Execute(void) { bool bOk; int ID, Flag, iPoint, nPoints; double x, y; FILE *Stream; TSG_Shape_Type Type; CSG_String FileName, sLine, sName, sDesc, sTemp; CSG_Table_Record *pRecord; CSG_Table *pTable; CSG_Shape *pShape; CSG_Shapes *pShapes; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); pTable = Parameters("TABLE") ->asTable(); FileName = Parameters("FILE") ->asString(); switch( Parameters("TYPE")->asInt() ) { case 0: Type = SHAPE_TYPE_Point; break; case 1: default: Type = SHAPE_TYPE_Line; break; case 2: Type = SHAPE_TYPE_Polygon; break; } //----------------------------------------------------- if( (Stream = fopen(FileName.b_str(), "r")) != NULL ) { bOk = true; ID = 0; if( pShapes->Get_Type() != SHAPE_TYPE_Undefined && pShapes->Get_Type() != Type ) { pShapes = SG_Create_Shapes(Type, SG_File_Get_Name(FileName, false)); Parameters("SHAPES")->Set_Value(pShapes); DataObject_Add(pShapes); } else { pShapes->Create(Type, SG_File_Get_Name(FileName, false)); } if( Type == SHAPE_TYPE_Point ) { if( pTable == NULL ) { pTable = SG_Create_Table(); Parameters("TABLE")->Set_Value(pTable); } else { pTable->Destroy(); } pTable ->Add_Field("ID" , SG_DATATYPE_Int); pTable ->Add_Field("FLAG" , SG_DATATYPE_Int); pTable ->Add_Field("NAME" , SG_DATATYPE_String); pTable ->Add_Field("DESC" , SG_DATATYPE_String); pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("ID_LUT" , SG_DATATYPE_Int); pShapes->Add_Field("Z" , SG_DATATYPE_Double); } else { pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("FLAG" , SG_DATATYPE_Int); pShapes->Add_Field("NAME" , SG_DATATYPE_String); pShapes->Add_Field("DESC" , SG_DATATYPE_String); } //------------------------------------------------- while( bOk && SG_Read_Line(Stream, sLine) && sLine.BeforeFirst(',').asInt(nPoints) && nPoints > 0 && Process_Get_Okay(true) ) { Process_Set_Text(CSG_String::Format(SG_T("%d. %s"), ++ID, _TL("shape in process"))); sTemp = sLine.AfterFirst (','); sLine = sTemp; Flag = sLine.BeforeFirst(',').asInt(); sTemp = sLine.AfterFirst (','); sLine = sTemp; sTemp = sLine.BeforeFirst(','); sName = sTemp.AfterFirst('\"').BeforeLast('\"'); sTemp = sLine.AfterFirst (','); sLine = sTemp; sTemp = sLine.BeforeFirst(','); sDesc = sTemp.AfterFirst('\"').BeforeLast('\"'); if( Type == SHAPE_TYPE_Point ) { pRecord = pTable->Add_Record(); pRecord->Set_Value(0, ID); pRecord->Set_Value(1, Flag); pRecord->Set_Value(2, sName); pRecord->Set_Value(3, sDesc); for(iPoint=0; iPointAdd_Shape(); pShape->Set_Value(0, iPoint + 1); pShape->Set_Value(1, ID); pShape->Set_Value(2, sLine.AfterLast (',').asDouble()); x = sLine.BeforeFirst(',').asDouble(); y = sLine.AfterFirst (',').asDouble(); pShape->Add_Point(x, y); } } } else { pShape = pShapes->Add_Shape(); pShape->Set_Value(0, ID); pShape->Set_Value(1, Flag); pShape->Set_Value(2, sName); pShape->Set_Value(3, sDesc); for(iPoint=0; iPointAdd_Point(x, y); } } } } fclose(Stream); } //----------------------------------------------------- if( pShapes->is_Valid() && pShapes->Get_Count() > 0 ) { return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSurfer_BLN_Export::CSurfer_BLN_Export(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export Surfer Blanking File")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "Export shapes to Golden Software's Surfer Blanking File format.\n" )); //----------------------------------------------------- // 2. Parameters... CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field(pNode, "NAME", _TL("Name" ), _TL(""), true); Parameters.Add_Table_Field(pNode, "DESC", _TL("Description"), _TL(""), true); Parameters.Add_Table_Field(pNode, "ZVAL", _TL("z values" ), _TL(""), true); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|*bln|%s|*.*"), _TL("Surfer Blanking Files (*.bln)"), _TL("All Files") ), NULL, true ); } //--------------------------------------------------------- bool CSurfer_BLN_Export::On_Execute(void) { //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(Parameters("FILE")->asString(), SG_FILE_W) ) { return( false ); } CSG_Shapes *pShapes = Parameters("SHAPES")->asShapes(); if( !pShapes->is_Valid() || pShapes->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- int iName = Parameters("BNAME" )->asBool() ? Parameters("NAME")->asInt() : -1; int iDesc = Parameters("BDESC" )->asBool() ? Parameters("DESC")->asInt() : -1; int iZVal = Parameters("BZVAL" )->asBool() ? Parameters("ZVAL")->asInt() : -1; int Flag = 1; //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { Stream.Printf(SG_T("%d,%d"), pShape->Get_Point_Count(iPart), Flag); if( iName >= 0 ) { Stream.Printf(SG_T(",\"%s\""), pShape->asString(iName)); } if( iDesc >= 0 ) { Stream.Printf(SG_T(",\"%s\""), pShape->asString(iDesc)); } Stream.Printf(SG_T("\n")); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); if( iZVal >= 0 ) { Stream.Printf(SG_T("%f,%f,%f\n"), p.x, p.y, pShape->asDouble(iZVal)); } else { Stream.Printf(SG_T("%f,%f\n" ), p.x, p.y); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_shapes/svg.cpp0000664000175000017500000002723012565125414021723 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: svg.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // svg.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "svg.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { SYMBOL_POINT_CIRCLE = 0, SYMBOL_POINT_SQUARE }; /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSVG_Export::CSVG_Export(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export Scalable Vector Graphics (SVG) File")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "Export shapes to Scalable Vector Graphics (SVG) File.\n" "SVG specification at World Wide Web Consortium (W3C)\n" "Scalable Vector Graphics (SVG) 1.1" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|*.svg|%s|*.*"), _TL("Scalable Vector Graphics Files (*.svg)"), _TL("All Files") ), NULL, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSVG_Export::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Shapes_List *pList = Parameters("SHAPES")->asShapesList(); if( pList->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- int i, Width, Height; double Size_Point, Size_Line; CSG_Rect Extent; CSG_MetaData SVG, *pGroup; //----------------------------------------------------- Width = 800; Height = 800; Extent = pList->asShapes(0)->Get_Extent(); for(i=1; iGet_Count() && Process_Get_Okay(); i++) { Extent.Union(pList->asShapes(i)->Get_Extent()); } //----------------------------------------------------- SVG.Set_Name(SG_T("svg")); SVG.Add_Property(SG_T("xmlns") , SG_T("http://www.w3.org/2000/svg")); SVG.Add_Property(SG_T("xmlns:xlink"), SG_T("http://www.w3.org/1999/xlink")); SVG.Add_Property(SG_T("xmlns:ev") , SG_T("http://www.w3.org/2001/xml-events")); SVG.Add_Property(SG_T("version") , SG_T("1.1")); SVG.Add_Property(SG_T("baseProfile"), SG_T("tiny")); SVG.Add_Property(SG_T("width") , CSG_String::Format(SG_T("%d"), Width)); SVG.Add_Property(SG_T("height") , CSG_String::Format(SG_T("%d"), Height)); SVG.Add_Property(SG_T("viewBox") , CSG_String::Format(SG_T("%f %f %f %f"), Extent.Get_XMin(), -Extent.Get_YMax(), Extent.Get_XRange(), Extent.Get_YRange())); Size_Point = Extent.Get_XRange() / 200.0; Size_Line = Extent.Get_XRange() / 500.0; m_dStroke = Extent.Get_XRange() / 1000.0; //----------------------------------------------------- for(i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Shapes *pShapes = pList->asShapes(i); pGroup = SVG.Add_Child(SG_T("g")); pGroup->Add_Property(SG_T("id") , pShapes->Get_Name()); pGroup->Add_Property(SG_T("transform") , SG_T("scale(1,-1)")); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { switch( pShapes->Get_Type() ) { case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: Add_Points (*pGroup, pShape, iPart, SG_COLOR_RED , Size_Point, SYMBOL_POINT_SQUARE); break; case SHAPE_TYPE_Line: Add_Line (*pGroup, pShape, iPart, SG_COLOR_BLUE_DARK , Size_Line); break; case SHAPE_TYPE_Polygon: Add_Polygon (*pGroup, pShape, iPart, SG_COLOR_GREEN ); break; } } } } //----------------------------------------------------- return( SVG.Save(Parameters("FILE")->asString()) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSVG_Export::Get_Points(CSG_Shape *pShape, int iPart, CSG_String &Points) { Points.Clear(); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point Point = pShape->Get_Point(iPoint, iPart); if( iPoint > 0 ) { Points += SG_T(" "); } Points += CSG_String::Format(SG_T("%f,%f"), Point.x, Point.y); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSVG_Export::Add_Points(CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color, double Size, int Symbol) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point Point = pShape->Get_Point(0, 0); CSG_MetaData *pSVG = SVG.Add_Child(); switch( Symbol ) { case SYMBOL_POINT_CIRCLE: default: pSVG->Set_Name(SG_T("circle")); pSVG->Add_Property(SG_T("cx") , Point.x); pSVG->Add_Property(SG_T("cy") , Point.y); pSVG->Add_Property(SG_T("length") , Size); break; case SYMBOL_POINT_SQUARE: pSVG->Set_Name(SG_T("rect")); pSVG->Add_Property(SG_T("x") , Point.x - Size / 2.0); pSVG->Add_Property(SG_T("y") , Point.y - Size / 2.0); pSVG->Add_Property(SG_T("width") , Size); pSVG->Add_Property(SG_T("height") , Size); break; } pSVG->Add_Property(SG_T("fill") , CSG_String::Format(SG_T("rgb(%d,%d,%d)"), SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color))); pSVG->Add_Property(SG_T("stroke") , SG_T("black")); pSVG->Add_Property(SG_T("stroke-width") , m_dStroke); } } //--------------------------------------------------------- void CSVG_Export::Add_Line(CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color, double Size) { CSG_String Points; if( Get_Points(pShape, iPart, Points) ) { CSG_MetaData *pSVG = SVG.Add_Child(SG_T("polyline")); pSVG->Add_Property(SG_T("points") , Points); pSVG->Add_Property(SG_T("fill") , SG_T("none")); pSVG->Add_Property(SG_T("stroke") , CSG_String::Format(SG_T("rgb(%d,%d,%d)"), SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color))); pSVG->Add_Property(SG_T("stroke-width") , Size); } } //--------------------------------------------------------- void CSVG_Export::Add_Polygon(CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color) { CSG_String Points; if( Get_Points(pShape, iPart, Points) ) { CSG_MetaData *pSVG = SVG.Add_Child(SG_T("polygon")); pSVG->Add_Property(SG_T("points") , Points); pSVG->Add_Property(SG_T("fill") , CSG_String::Format(SG_T("rgb(%d,%d,%d)"), SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color))); pSVG->Add_Property(SG_T("stroke") , SG_T("black")); pSVG->Add_Property(SG_T("stroke-width") , m_dStroke); } } /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSVG_Import::CSVG_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import Scalable Vector Graphics (SVG) File")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|*.svg|%s|*.*"), _TL("Scalable Vector Graphics Files (*.svg)"), _TL("All Files") ) ); } //--------------------------------------------------------- bool CSVG_Import::On_Execute(void) { CSG_MetaData SVG; //----------------------------------------------------- CSG_Parameter_Shapes_List *pList = Parameters("SHAPES")->asShapesList(); //----------------------------------------------------- if( SVG.Load(Parameters("FILE")->asString()) ) { } //----------------------------------------------------- return( pList->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.2.3/src/modules/io/io_shapes/gpx.cpp0000664000175000017500000003477212565125414021733 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gpx.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // gpx.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., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gpx.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGPX_Import::CGPX_Import(void) { Set_Name (_TL("Import GPX")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "Imports GPS data from GPS eXchange format GPX.\n" "\n" "References:\n" "The GPS Exchange Format" )); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("GPX Import"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("GPS Exchange Format (*.gpx)") , SG_T("*.gpx"), _TL("All Files") , SG_T("*.*") ), NULL, false ); Parameters.Add_Value( NULL , "TIME" , _TL("Time Stamp without date"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGPX_Import::On_Execute(void) { CSG_Shapes *pWay; CSG_MetaData GPX; //----------------------------------------------------- m_Name = Parameters("FILE") ->asString(); m_pShapes = Parameters("SHAPES") ->asShapesList(); m_bTime = Parameters("TIME") ->asBool(); //----------------------------------------------------- if( !GPX.Create(m_Name) || GPX.Get_Name().CmpNoCase(SG_T("gpx")) ) { return( false ); } //----------------------------------------------------- pWay = SG_Create_Shapes(SHAPE_TYPE_Point, m_Name); m_Name = SG_File_Get_Name(m_Name, false); m_pShapes->Del_Items(); //----------------------------------------------------- for(int i=0; iGet_Name().CmpNoCase(SG_T("wpt")) == 0 ) { Add_Point(pChild, pWay); } else if( pChild->Get_Name().CmpNoCase(SG_T("rte")) == 0 ) { Add_Route(pChild); } else if( pChild->Get_Name().CmpNoCase(SG_T("trk")) == 0 ) { Add_Track(pChild); } } //----------------------------------------------------- if( pWay->Get_Count() > 0 ) { m_pShapes->Add_Item(pWay); } else { delete(pWay); } return( m_pShapes->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_CONTENT(node, child, default) (node->Get_Child(SG_T(child)) ? node->Get_Child(SG_T(child))->Get_Content() : SG_T(default)) //--------------------------------------------------------- bool CGPX_Import::Add_Route(CSG_MetaData *pRoute) { // xsd:string // xsd:string // xsd:string // xsd:string // linkType // xsd:nonNegativeInteger // xsd:string CSG_String Name(GET_CONTENT(pRoute, "name", "Route")); CSG_Shapes *pPoints = SG_Create_Shapes(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), m_Name.c_str(), Name.c_str())); m_pShapes->Add_Item(pPoints); for(int i=0; iGet_Children_Count(); i++) { CSG_MetaData *pChild = pRoute->Get_Child(i); if( pChild->Get_Name().CmpNoCase(SG_T("rtept")) == 0 ) { Add_Point(pChild, pPoints); } } return( true ); } //--------------------------------------------------------- bool CGPX_Import::Add_Track(CSG_MetaData *pTrack) { // xsd:string // xsd:string // xsd:string // xsd:string // linkType // xsd:nonNegativeInteger // xsd:string CSG_MetaData *pSegment = pTrack->Get_Child(SG_T("trkseg")); if( pSegment ) { CSG_String Name(GET_CONTENT(pTrack, "name", "Track Segment")); CSG_Shapes *pPoints = SG_Create_Shapes(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), m_Name.c_str(), Name.c_str())); m_pShapes->Add_Item(pPoints); for(int i=0; iGet_Children_Count(); i++) { CSG_MetaData *pChild = pSegment->Get_Child(i); if( pChild->Get_Name().CmpNoCase(SG_T("trkpt")) == 0 ) { Add_Point(pChild, pPoints); } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define ADD_FIELD(key, type) if( pNode->Get_Child(SG_T(key)) ) { pPoints->Add_Field(SG_T(key), type); } inline bool CGPX_Import::Add_Fields(CSG_MetaData *pNode, CSG_Shapes *pPoints) { if( pPoints->Get_Field_Count() == 0 ) { ADD_FIELD("ele" , SG_DATATYPE_Double); // xsd:decimal (Höhe) ADD_FIELD("time" , SG_DATATYPE_String); //