Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main Repositories
otb
Commits
7da18a6f
Commit
7da18a6f
authored
8 years ago
by
Jordi Inglada
Browse files
Options
Downloads
Patches
Plain Diff
REFAC: move methods to cxx
parent
055be5ad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Modules/Radiometry/Simulation/include/otbSoilDataBase.h
+7
-94
7 additions, 94 deletions
Modules/Radiometry/Simulation/include/otbSoilDataBase.h
Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx
+0
-14
0 additions, 14 deletions
Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx
with
7 additions
and
108 deletions
Modules/Radiometry/Simulation/include/otbSoilDataBase.h
+
7
−
94
View file @
7da18a6f
...
@@ -22,18 +22,14 @@
...
@@ -22,18 +22,14 @@
#ifndef otbSoilDataBase_h
#ifndef otbSoilDataBase_h
#define otbSoilDataBase_h
#define otbSoilDataBase_h
#include
"OTBSimulationExport.h"
#include
<vector>
#include
<vector>
#include
<unordered_map>
#include
<unordered_map>
#include
<fstream>
#include
<sstream>
#include
<algorithm>
#include
<boost/algorithm/string.hpp>
#include
"itkMacro.h"
namespace
otb
namespace
otb
{
{
class
SoilDataBase
class
OTBSimulation_EXPORT
SoilDataBase
{
{
public:
public:
//wavelength in nm
//wavelength in nm
...
@@ -41,96 +37,13 @@ public:
...
@@ -41,96 +37,13 @@ public:
using
SoilData
=
std
::
unordered_map
<
WavelenghtType
,
double
>
;
using
SoilData
=
std
::
unordered_map
<
WavelenghtType
,
double
>
;
using
SoilDataVector
=
std
::
vector
<
SoilData
>
;
using
SoilDataVector
=
std
::
vector
<
SoilData
>
;
SoilDataBase
(
const
std
::
string
&
SoilFileName
,
double
wlfactor
)
:
SoilDataBase
(
const
std
::
string
&
SoilFileName
,
double
wlfactor
);
m_SoilFileName
(
SoilFileName
),
m_WlFactor
(
wlfactor
)
const
SoilDataVector
&
GetDB
()
const
;
{
double
GetReflectance
(
size_t
SoilIndex
,
WavelenghtType
wl
)
const
;
ParseSoilFile
();
};
const
SoilDataVector
&
GetDB
()
const
{
return
m_SoilDataVector
;
}
double
GetReflectance
(
size_t
SoilIndex
,
WavelenghtType
wl
)
{
assert
(
SoilIndex
<
m_SoilDataVector
.
size
());
// wl not in the set of measured ones
if
(
m_SoilDataVector
[
SoilIndex
].
find
(
wl
)
==
m_SoilDataVector
[
SoilIndex
].
end
())
{
const
auto
wlmin
=
m_Wavelengths
[
0
];
const
auto
wlmax
=
m_Wavelengths
[
m_Wavelengths
.
size
()
-
1
];
if
(
wl
<
wlmin
)
return
m_SoilDataVector
[
SoilIndex
][
wlmin
];
if
(
wl
>
wlmax
)
return
m_SoilDataVector
[
SoilIndex
][
wlmax
];
const
auto
p
=
std
::
partition_point
(
m_Wavelengths
.
cbegin
(),
m_Wavelengths
.
cend
(),
[
&
](
WavelenghtType
w
){
return
w
<
wl
;}
);
const
auto
wlinf
=
*
(
p
-
1
);
const
auto
wlsup
=
*
p
;
const
auto
factinf
=
wl
-
wlinf
;
const
auto
factsup
=
wlsup
-
wl
;
return
(
m_SoilDataVector
[
SoilIndex
][
wlinf
]
*
factinf
+
m_SoilDataVector
[
SoilIndex
][
wlsup
]
*
factsup
)
/
(
factinf
+
factsup
);
}
else
{
return
m_SoilDataVector
[
SoilIndex
][
wl
];
}
}
protected:
protected:
size_t
countColumns
(
std
::
string
fileName
)
size_t
countColumns
(
std
::
string
fileName
)
const
;
{
void
ParseSoilFile
();
std
::
ifstream
ifile
(
fileName
.
c_str
());
std
::
string
line
;
if
(
ifile
.
is_open
())
{
size_t
nbSpaces
=
0
;
getline
(
ifile
,
line
);
ifile
.
close
();
boost
::
trim
(
line
);
auto
found
=
line
.
find
(
' '
);
while
(
found
!=
std
::
string
::
npos
)
{
++
nbSpaces
;
while
(
line
[
found
+
1
]
==
' '
)
++
found
;
found
=
line
.
find
(
' '
,
found
+
1
);
}
return
nbSpaces
+
1
;
}
else
{
itkGenericExceptionMacro
(
<<
"Could not open file "
<<
fileName
);
}
}
void
ParseSoilFile
()
{
unsigned
int
number_of_soils
=
countColumns
(
m_SoilFileName
)
-
1
;
m_SoilDataVector
.
resize
(
number_of_soils
);
std
::
ifstream
sdb
(
m_SoilFileName
);
std
::
string
line
;
while
(
sdb
.
good
())
{
std
::
getline
(
sdb
,
line
);
if
(
line
.
size
()
>
3
)
{
std
::
stringstream
ss
(
line
);
double
tmpwl
;
ss
>>
tmpwl
;
WavelenghtType
wl
=
static_cast
<
WavelenghtType
>
(
m_WlFactor
*
tmpwl
);
for
(
size_t
i
=
0
;
i
<
number_of_soils
;
++
i
)
{
if
(
i
==
0
)
m_Wavelengths
.
push_back
(
wl
);
double
refl
;
ss
>>
refl
;
m_SoilDataVector
[
i
][
wl
]
=
refl
;
}
}
}
std
::
sort
(
m_Wavelengths
.
begin
(),
m_Wavelengths
.
end
());
}
std
::
string
m_SoilFileName
;
std
::
string
m_SoilFileName
;
double
m_WlFactor
;
double
m_WlFactor
;
...
...
This diff is collapsed.
Click to expand it.
Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx
+
0
−
14
View file @
7da18a6f
...
@@ -35,20 +35,6 @@ int otbSoilDataBaseParseFile(int argc, char * argv[])
...
@@ -35,20 +35,6 @@ int otbSoilDataBaseParseFile(int argc, char * argv[])
otb
::
SoilDataBase
sdb
(
sfn
,
1000
);
otb
::
SoilDataBase
sdb
(
sfn
,
1000
);
auto
db
=
sdb
.
GetDB
();
auto
db
=
sdb
.
GetDB
();
// auto wlmin = static_cast<unsigned int>(std::stoi(argv[2]));
// auto wlmax = static_cast<unsigned int>(std::stoi(argv[3]));
// auto wlstep = static_cast<unsigned int>(std::stoi(argv[4]));
// for(unsigned int wl=wlmin; wl<=wlmax; wl+=wlstep)
// {
// std::cout << wl << " ";
// for(size_t i=0; i<db.size(); ++i)
// {
// std::cout << db[i][wl] << " ";
// }
// std::cout << '\n';
// }
for
(
unsigned
int
i
=
5
;
i
<
static_cast
<
unsigned
int
>
(
argc
);
i
+=
3
)
for
(
unsigned
int
i
=
5
;
i
<
static_cast
<
unsigned
int
>
(
argc
);
i
+=
3
)
{
{
auto
wltest
=
std
::
stoi
(
argv
[
i
]);
auto
wltest
=
std
::
stoi
(
argv
[
i
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment