WSL/SLF GitLab Repository
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
snow-models
meteoio
Commits
19c29d0f
Commit
19c29d0f
authored
Aug 11, 2015
by
Mathias Bavay
Browse files
Rounding azimuths to 0.1 and preventing azi=360, prefering azi=0 instead
parent
8bba4407
Changes
2
Hide whitespace changes
Inline
Side-by-side
meteoio/IOUtils.cc
View file @
19c29d0f
...
...
@@ -489,30 +489,30 @@ bool convertString(Date& t, const std::string& str, const double& time_zone, std
//extract date/time
const
size_t
date_beg
=
s
.
find_first_of
(
NUM
);
if
(
date_beg
==
npos
||
date_beg
==
in_len
)
return
false
;
if
(
date_beg
==
npos
||
date_beg
==
in_len
)
return
false
;
size_t
date_end
=
s
.
find_first_not_of
(
NUM
,
date_beg
+
1
);
if
(
date_end
==
npos
)
date_end
=
in_len
;
if
(
date_end
==
npos
)
date_end
=
in_len
;
const
std
::
string
date
=
s
.
substr
(
date_beg
,
date_end
-
date_beg
);
//parse date/time
const
size_t
date_len
=
date
.
length
();
if
(
date_len
<
10
||
date_len
>
14
)
return
false
;
if
(
convertString
(
year
,
date
.
substr
(
0
,
4
))
==
false
)
return
false
;
if
(
convertString
(
month
,
date
.
substr
(
4
,
2
))
==
false
)
return
false
;
if
(
convertString
(
day
,
date
.
substr
(
6
,
2
))
==
false
)
return
false
;
if
(
convertString
(
hour
,
date
.
substr
(
8
,
2
))
==
false
)
return
false
;
if
(
date_len
==
10
)
if
(
date_len
<
10
||
date_len
>
14
)
return
false
;
if
(
convertString
(
year
,
date
.
substr
(
0
,
4
))
==
false
)
return
false
;
if
(
convertString
(
month
,
date
.
substr
(
4
,
2
))
==
false
)
return
false
;
if
(
convertString
(
day
,
date
.
substr
(
6
,
2
))
==
false
)
return
false
;
if
(
convertString
(
hour
,
date
.
substr
(
8
,
2
))
==
false
)
return
false
;
if
(
date_len
==
10
)
minute
=
0
;
else
{
if
(
date_len
>=
12
)
{
if
(
date_len
>=
12
)
{
if
(
convertString
(
minute
,
date
.
substr
(
10
,
2
))
==
false
)
return
false
;
}
else
return
false
;
if
(
date_len
==
12
)
if
(
date_len
==
12
)
second
=
0
;
else
{
if
(
date_len
==
14
)
{
if
(
convertString
(
second
,
date
.
substr
(
12
,
2
))
==
false
)
return
false
;
if
(
date_len
==
14
)
{
if
(
convertString
(
second
,
date
.
substr
(
12
,
2
))
==
false
)
return
false
;
}
else
return
false
;
}
...
...
@@ -521,9 +521,9 @@ bool convertString(Date& t, const std::string& str, const double& time_zone, std
//extract potential ISO time zone string
double
tz
=
time_zone
;
const
size_t
tz_beg
=
s
.
find_first_of
(
"+-"
,
date_end
);
if
(
tz_beg
!=
npos
&&
tz_beg
!=
in_len
)
{
if
(
tz_beg
!=
npos
&&
tz_beg
!=
in_len
)
{
size_t
tz_end
=
s
.
find_first_not_of
(
"0123456789:"
,
date_end
+
1
);
if
(
tz_end
==
npos
)
tz_end
=
in_len
;
if
(
tz_end
==
npos
)
tz_end
=
in_len
;
const
std
::
string
timezone_iso
=
s
.
substr
(
tz_beg
,
tz_end
-
tz_beg
);
if
(
!
timezone_iso
.
empty
())
tz
=
Date
::
parseTimeZone
(
timezone_iso
);
}
...
...
meteoio/dataClasses/DEMObject.cc
View file @
19c29d0f
...
...
@@ -779,17 +779,12 @@ double DEMObject::CalculateAspect(const double& o_Nx, const double& o_Ny, const
if
(
o_slope
>
0.
)
{
//there is some slope
if
(
o_Nx
==
0.
)
{
//no E-W slope, so it is purely N-S
if
(
o_Ny
<
0.
)
{
return
(
180.
);
// south facing
}
else
{
return
(
0.
);
// north facing
}
const
double
aspect
=
(
o_Ny
<
0.
)
?
180.
:
0.
;
return
aspect
;
}
else
{
//there is a E-W slope
if
(
o_Nx
>
0.
)
{
return
(
90.
-
atan
(
o_Ny
/
o_Nx
)
*
Cst
::
to_deg
);
}
else
{
return
(
270.
-
atan
(
o_Ny
/
o_Nx
)
*
Cst
::
to_deg
);
}
const
double
angle_deg
=
static_cast
<
double
>
(
Optim
::
round
(
atan2
(
o_Ny
,
o_Nx
)
*
Cst
::
to_deg
*
10.
))
/
10.
;
//round angle to 0.1
const
double
aspect
=
fmod
(
90.
-
angle_deg
+
360.
,
360.
);
//convert angle to bearing
return
aspect
;
}
}
else
{
// if slope = 0
return
(
no_slope
);
// undefined or plain surface
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment