WSL/SLF GitLab Repository

Commit 4b8fb99e authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The DEM object now calculates slope and azimuth in degrees. This is more...

The DEM object now calculates slope and azimuth in degrees. This is more consistent with the usage of bearings in degrees and of trigonometric angles in radiants.

A missing file has been added to the autotools compilation. A better comparison is performed for Coords objects.
parent 76a67163
......@@ -76,6 +76,7 @@ endif
######## Sources, objects, headers
METEOIO_OBJ = $(SRCDIR)/MeteoData.o \
$(SRCDIR)/StationData.o \
$(SRCDIR)/IOPlugin.o \
$(SRCDIR)/IOHandler.o \
$(SRCDIR)/IOInterface.o \
$(SRCDIR)/DynamicLibrary.o \
......@@ -101,6 +102,7 @@ METEOIO_OBJ = $(SRCDIR)/MeteoData.o \
METEOIO_OBJ_POPC = $(SRCDIR)/IOInterface_par.o \
$(SRCDIR)/IOInterface_par.o \
$(SRCDIR)/IOPlugin_par.o \
$(SRCDIR)/IOHandler.stub.o \
$(SRCDIR)/IOHandler_par.o \
$(SRCDIR)/BufferedIOHandler_par.o \
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for meteoio 0.1.
# Generated by GNU Autoconf 2.61 for meteoio 1.1.1.
#
# Report bugs to <bavay@slf.ch>.
#
......@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='meteoio'
PACKAGE_TARNAME='meteoio'
PACKAGE_VERSION='0.1'
PACKAGE_STRING='meteoio 0.1'
PACKAGE_VERSION='1.1.1'
PACKAGE_STRING='meteoio 1.1.1'
PACKAGE_BUGREPORT='bavay@slf.ch'
# Factoring default headers for most tests.
......@@ -1214,7 +1214,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures meteoio 0.1 to adapt to many kinds of systems.
\`configure' configures meteoio 1.1.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1275,7 +1275,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of meteoio 0.1:";;
short | recursive ) echo "Configuration of meteoio 1.1.1:";;
esac
cat <<\_ACEOF
......@@ -1384,7 +1384,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
meteoio configure 0.1
meteoio configure 1.1.1
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1398,7 +1398,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by meteoio $as_me 0.1, which was
It was created by meteoio $as_me 1.1.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -3985,6 +3985,95 @@ case ".$ax_cv_cflags_gcc_option__O3" in
;;
esac
{ echo "$as_me:$LINENO: checking OPTIM for gcc -ftree-vectorize" >&5
echo $ECHO_N "checking OPTIM for gcc -ftree-vectorize... $ECHO_C" >&6; }
if test "${ax_cv_cflags_gcc_option__ftree_vectorize+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ax_cv_cflags_gcc_option__ftree_vectorize="no, unknown"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_save_CFLAGS="$CFLAGS"
for ac_arg in "-pedantic -Werror % -ftree-vectorize" "-pedantic % -ftree-vectorize %% no, obsolete" #
do CFLAGS="$ac_save_CFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ax_cv_cflags_gcc_option__ftree_vectorize=`echo $ac_arg | sed -e 's,.*% *,,'` ; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
CFLAGS="$ac_save_CFLAGS"
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
fi
{ echo "$as_me:$LINENO: result: $ax_cv_cflags_gcc_option__ftree_vectorize" >&5
echo "${ECHO_T}$ax_cv_cflags_gcc_option__ftree_vectorize" >&6; }
case ".$ax_cv_cflags_gcc_option__ftree_vectorize" in
.ok|.ok,*) ;;
.|.no|.no,*) ;;
*)
if echo " $OPTIM " | grep " $ax_cv_cflags_gcc_option__ftree_vectorize " 2>&1 >/dev/null
then { (echo "$as_me:$LINENO: : OPTIM does contain \$ax_cv_cflags_gcc_option__ftree_vectorize") >&5
(: OPTIM does contain $ax_cv_cflags_gcc_option__ftree_vectorize) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
else { (echo "$as_me:$LINENO: : OPTIM=\"\$OPTIM \$ax_cv_cflags_gcc_option__ftree_vectorize\"") >&5
(: OPTIM="$OPTIM $ax_cv_cflags_gcc_option__ftree_vectorize") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
OPTIM="$OPTIM $ax_cv_cflags_gcc_option__ftree_vectorize"
fi
;;
esac
{ echo "$as_me:$LINENO: checking MAKE_OPTIM for gcc -combine" >&5
......@@ -7407,7 +7496,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by meteoio $as_me 0.1, which was
This file was extended by meteoio $as_me 1.1.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -7450,7 +7539,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
meteoio config.status 0.1
meteoio config.status 1.1.1
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
......@@ -90,16 +90,22 @@ bool Coords::initializeMaps() {
*/
bool Coords::operator==(const Coords& in) const {
//check that two Coords objects represent the same location
if(latitude==IOUtils::nodata || longitude==IOUtils::nodata || easting==IOUtils::nodata || northing==IOUtils::nodata) {
if(latitude!=IOUtils::nodata && longitude!=IOUtils::nodata) {
const bool comparison = ( IOUtils::checkEpsilonEquality(getLat(), in.getLat(), IOUtils::lat_epsilon) &&
IOUtils::checkEpsilonEquality(getLon(), in.getLon(), IOUtils::lon_epsilon) );
return comparison;
}
if(easting!=IOUtils::nodata && northing!=IOUtils::nodata) {
const bool comparison = ( IOUtils::checkEpsilonEquality(getEasting(), in.getEasting(), 5.) &&
IOUtils::checkEpsilonEquality(getNorthing(), in.getNorthing(), 5.) );
return comparison;
}
if(grid_i!=IOUtils::nodata && grid_j!=IOUtils::nodata && grid_k!=IOUtils::nodata) {
//only available information is grid indices
const bool comparison = ( grid_i==in.grid_i && grid_j==in.grid_j && grid_k==in.grid_k );
return comparison;
} else {
const bool comparison = ( IOUtils::checkEpsilonEquality(getLat(), in.getLat(), IOUtils::lat_epsilon) &&
IOUtils::checkEpsilonEquality(getLon(), in.getLon(), IOUtils::lon_epsilon) );
return comparison;
}
return false;
}
/**
......
......@@ -581,6 +581,7 @@ double DEMObject::CalculateAspect(const double& Nx, const double& Ny, const doub
//(direction of the normal pointing out of the surface, clockwise from north)
//This azimuth calculation is similar to Hodgson (1998)
//local_nodata is the value that we want to give to the aspect of points that don't have a slope
//The value is a bearing (ie: deg, clockwise, 0=North)
if(Nx==IOUtils::nodata || Ny==IOUtils::nodata || Nz==IOUtils::nodata || slope==IOUtils::nodata) {
return IOUtils::nodata;
......@@ -589,16 +590,16 @@ double DEMObject::CalculateAspect(const double& Nx, const double& Ny, const doub
if ( slope > 0. ) { //there is some slope
if ( Nx == 0. ) { //no E-W slope, so it is purely N-S
if ( Ny < 0. ) {
return (M_PI); // south facing
return(180.); // south facing
} else {
return (0.); // north facing
return (0.); // north facing
}
} else { //there is a E-W slope
const double N_norm = sqrt( Nx*Nx + Ny*Ny + Nz*Nz );
const double to_deg = 180./M_PI;
if ( Nx > 0. ) {
return (M_PI * 0.5 - atan( (Ny/N_norm) / (Nx/N_norm) ));
return (90. - atan(Ny/Nx)*to_deg);
} else {
return (M_PI * 1.5 - atan( (Ny/N_norm) / (Nx/N_norm) ));
return (270. - atan(Ny/Nx)*to_deg);
}
}
} else { // if slope = 0
......@@ -620,7 +621,8 @@ void DEMObject::CalculateHick(double A[4][4], double& slope, double& Nx, double&
Nz = IOUtils::nodata;
slope_failures++;
} else {
slope = atan( smax );
const double to_deg = 180./M_PI;
slope = atan(smax)*to_deg;
//Nx and Ny: x and y components of the normal pointing OUT of the surface
if ( smax > 0. ) { //ie: there is some slope
......@@ -651,7 +653,8 @@ void DEMObject::CalculateFleming(double A[4][4], double& slope, double& Nx, doub
Nx = 0.5 * (A[2][1] - A[2][3]) / cellsize;
Ny = 0.5 * (A[3][2] - A[1][2]) / cellsize;
Nz = 1.;
slope = atan( sqrt(Nx*Nx+Ny*Ny) );
const double to_deg = 180./M_PI;
slope = atan( sqrt(Nx*Nx+Ny*Ny) ) * to_deg;
} else {
CalculateHick(A, slope, Nx, Ny, Nz);
}
......@@ -669,7 +672,8 @@ void DEMObject::CalculateHorn(double A[4][4], double& slope, double& Nx, double&
//There is no difference between slope = acos(n_z/|n|) and slope = atan(sqrt(sx*sx+sy*sy))
//slope = acos( (Nz / sqrt( Nx*Nx + Ny*Ny + Nz*Nz )) );
slope = atan( sqrt(Nx*Nx+Ny*Ny) );
const double to_deg = 180./M_PI;
slope = atan( sqrt(Nx*Nx+Ny*Ny) ) * to_deg;
} else {
//steepest slope method (Dunn and Hickey, 1998)
CalculateHick(A, slope, Nx, Ny, Nz);
......@@ -685,7 +689,8 @@ void DEMObject::CalculateCorripio(double A[4][4], double& slope, double& Nx, dou
Nz = 1.;
//There is no difference between slope = acos(n_z/|n|) and slope = atan(sqrt(sx*sx+sy*sy))
//slope = acos( (Nz / sqrt( Nx*Nx + Ny*Ny + Nz*Nz )) );
slope = atan( sqrt(Nx*Nx+Ny*Ny) );
const double to_deg = 180./M_PI;
slope = atan( sqrt(Nx*Nx+Ny*Ny) ) * to_deg;
} else {
//steepest slope method (Dunn and Hickey, 1998)
CalculateHick(A, slope, Nx, Ny, Nz);
......
......@@ -443,7 +443,8 @@ void Interpol2D::SimpleDEMWindInterpolate(const DEMObject& dem, Grid2DObject& VW
double Ww; // Wind weighting
double Od; // Diverting factor
const double dem_min_slope=dem.min_slope, dem_range_slope=(dem.max_slope-dem_min_slope);
const double to_rad = M_PI/180.;
const double dem_min_slope=dem.min_slope*to_rad, dem_range_slope=(dem.max_slope-dem_min_slope)*to_rad;
const double dem_min_curvature=dem.min_curvature, dem_range_curvature=(dem.max_curvature-dem_min_curvature);
for (unsigned int j=0;j<VW.nrows-1;j++) {
......@@ -451,8 +452,8 @@ void Interpol2D::SimpleDEMWindInterpolate(const DEMObject& dem, Grid2DObject& VW
// Get input data
speed = VW.grid2D(i,j);
dir = DW.grid2D(i,j);
beta = dem.slope(i, j);
azi = dem.azi(i, j);
beta = dem.slope(i, j)*to_rad;
azi = dem.azi(i, j)*to_rad;
curvature = dem.curvature(i, j);
if(speed==IOUtils::nodata || dir==IOUtils::nodata || beta==IOUtils::nodata || azi==IOUtils::nodata || curvature==IOUtils::nodata) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment